Skip to content

Commit ebfca76

Browse files
feat: Add Spotless configuration and CI workflows
- Implement Spotless plugin configuration for code formatting in Java and Kotlin files. - Add GitHub Actions workflows for build and Spotless check to ensure code quality. - Update project dependencies and versioning in build scripts. - Include changelog template and configuration for automated changelog generation. - Add necessary environment variables and secrets for CI/CD processes. - Ensure consistent code style and formatting across the project.
1 parent e5eff08 commit ebfca76

File tree

21 files changed

+225
-36
lines changed

21 files changed

+225
-36
lines changed

.chglog/CHANGELOG.tpl.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{ range .Versions }}
2+
<a name="{{ .Tag.Name }}"></a>
3+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
4+
5+
{{ range .CommitGroups -}}
6+
### {{ .Title }}
7+
8+
{{ range .Commits -}}
9+
* {{ .Subject }}
10+
{{ end }}
11+
{{ end -}}
12+
13+
{{- if .RevertCommits -}}
14+
### Reverts
15+
16+
{{ range .RevertCommits -}}
17+
* {{ .Revert.Header }}
18+
{{ end }}
19+
{{ end -}}
20+
21+
{{- if .MergeCommits -}}
22+
### Pull Requests
23+
24+
{{ range .MergeCommits -}}
25+
* {{ .Header }}
26+
{{ end }}
27+
{{ end -}}
28+
29+
{{- if .NoteGroups -}}
30+
{{ range .NoteGroups -}}
31+
### {{ .Title }}
32+
33+
{{ range .Notes }}
34+
{{ .Body }}
35+
{{ end }}
36+
{{ end -}}
37+
{{ end -}}
38+
{{ end -}}

.chglog/config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
style: github
2+
template: CHANGELOG.tpl.md
3+
info:
4+
title: CHANGELOG
5+
repository_url: https://github.com/doananhtuan22111996/android-networking
6+
options:
7+
commits:
8+
filters:
9+
Type:
10+
- feat
11+
- fix
12+
- perf
13+
- refactor
14+
commit_groups:
15+
title_maps:
16+
feat: Features
17+
fix: Bug Fixes
18+
perf: Performance Improvements
19+
refactor: Code Refactoring
20+
header:
21+
pattern: "^(\\w*)\\:\\s(.*)$"
22+
pattern_maps:
23+
- Type
24+
- Subject
25+
notes:
26+
keywords:
27+
- BREAKING CHANGE

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
trim_trailing_whitespace = true
7+
8+
[*.{kt,kts}]
9+
indent_size = 4
10+
ktlint_standard = enabled
11+
ktlint_experimental = enabled
12+
ktlint_code_style = intellij_idea
13+
ktlint_standard_comment-spacing = disabled
14+
ktlint_standard_package-name = disabled
15+
ktlint_experimental_package-naming = enabled
16+
ij_kotlin_allow_trailing_comma = true
17+
ij_kotlin_allow_trailing_comma_on_call_site = true
18+
ktlint_standard_backing-property-naming = disabled
19+
ktlint_function_naming_ignore_when_annotated_with=Composable

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
name: Build Source
12+
runs-on: ubuntu-latest
13+
env:
14+
GH_USERNAME: ${{ secrets.GH_USERNAME }}
15+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
16+
GH_REPO_NAME: ${{ secrets.GH_REPO_NAME }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up JDK 21
20+
uses: actions/setup-java@v3
21+
with:
22+
java-version: '21'
23+
distribution: 'temurin'
24+
cache: gradle
25+
26+
- name: Grant execute permission for gradlew
27+
run: chmod +x gradlew
28+
29+
- name: Build
30+
run: ./gradlew :provider:finance:build
31+
32+
- name: Sending report to Telegram
33+
uses: appleboy/telegram-action@master
34+
with:
35+
to: ${{ secrets.TELEGRAM_TO }}
36+
token: ${{ secrets.TELEGRAM_TOKEN }}
37+
message: 🚀 Group com.feature.template build successfully!

.github/workflows/spotless.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Spotless Check
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
name: Spotless Check
12+
runs-on: ubuntu-latest
13+
env:
14+
GH_USERNAME: ${{ secrets.GH_USERNAME }}
15+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
16+
GH_REPO_NAME: ${{ secrets.GH_REPO_NAME }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up JDK 21
20+
uses: actions/setup-java@v3
21+
with:
22+
java-version: '21'
23+
distribution: 'temurin'
24+
cache: gradle
25+
26+
- name: Grant execute permission for gradlew
27+
run: chmod +x gradlew
28+
29+
- name: Spotless Check
30+
run: ./gradlew :spotlessCheck

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ deploymentTargetDropDown.xml
2323
render.experimental.xml
2424

2525
# Keystore files
26-
*.jks
2726
*.keystore
2827

2928
# Google Services (e.g. APIs or Firebase)

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
<a name="1.0.0"></a>
3+
## 1.0.0 (2024-11-23)
4+
5+
### Features
6+
7+
* migrate to Kotlin 2xx ([#2](https://github.com/doananhtuan22111996/android-networking/issues/2))
8+

build.gradle.kts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
1+
import com.diffplug.gradle.spotless.SpotlessExtension
2+
13
// Top-level build file where you can add configuration options common to all sub-projects/modules.
24
plugins {
35
alias(mobilex.plugins.androidHilt) apply false
4-
}
6+
alias(mobilex.plugins.spotless) apply false
7+
}
8+
9+
allprojects {
10+
apply {
11+
plugin(rootProject.mobilex.plugins.spotless.get().pluginId)
12+
}
13+
14+
configure<SpotlessExtension> {
15+
// Configuration for Java files
16+
java {
17+
target("**/*.java")
18+
googleJavaFormat().aosp() // Use Android Open Source Project style
19+
removeUnusedImports() // Automatically remove unused imports
20+
trimTrailingWhitespace() // Remove trailing whitespace
21+
}
22+
23+
// Configuration for Kotlin files
24+
kotlin {
25+
target("**/*.kt")
26+
targetExclude("${layout.buildDirectory}/**/*.kt") // Exclude files in the build directory
27+
ktlint("1.5.0").setEditorConfigPath(rootProject.file(".editorconfig").path) // Use ktlint with version 1.2.1 and custom .editorconfig
28+
toggleOffOn() // Allow toggling Spotless off and on within code files using comments
29+
trimTrailingWhitespace()
30+
}
31+
32+
// Additional configuration for Kotlin Gradle scripts
33+
kotlinGradle {
34+
target("*.gradle.kts")
35+
ktlint("1.5.0") // Apply ktlint to Gradle Kotlin scripts
36+
}
37+
}
38+
}

buildSrc/src/main/java/vn/core/buildSrc/Configs.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Configs {
1010
object Finance {
1111
const val GROUP_ID = "vn.core.provider"
1212
const val ARTIFACT_ID = "finance-networking"
13-
const val VERSION = "1.0.0"
13+
const val VERSION = "1.0.1"
1414
}
1515
}
1616
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
corePlugins = "1.0.1"
2+
corePlugins = "1.0.2"
33
coreDomain = "1.0.0"
44
coreData = "1.0.0"
55

0 commit comments

Comments
 (0)