Skip to content

Commit 4c1cb99

Browse files
author
Deo Kim
authored
Merge pull request #1 from mcauto/ci
Ci
2 parents e710b9b + 3737433 commit 4c1cb99

15 files changed

Lines changed: 8448 additions & 17 deletions

File tree

.editorconfig

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[*.{kt,kts}]
2+
# possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely)
3+
indent_size=4
4+
# true (recommended) / false
5+
insert_final_newline=true
6+
# possible values: number (e.g. 120) (package name, imports & comments are ignored), "off"
7+
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
8+
max_line_length=off
9+
10+
# Comma-separated list of rules to disable (Since 0.34.0)
11+
# Note that rules in any ruleset other than the standard ruleset will need to be prefixed
12+
# by the ruleset identifier.
13+
disabled_rules=no-wildcard-imports,experimental:annotation,my-custom-ruleset:my-custom-rule
14+
15+
# Defines the imports layout. The layout can be composed by the following symbols:
16+
# "*" - wildcard. There must be at least one entry of a single wildcard to match all other imports. Matches anything after a specified symbol/import as well.
17+
# "|" - blank line. Supports only single blank lines between imports. No blank line is allowed in the beginning or end of the layout.
18+
# "^" - alias import, e.g. "^android.*" will match all android alias imports, "^" will match all other alias imports.
19+
# import paths - these can be full paths, e.g. "java.util.List.*" as well as wildcard paths, e.g. "kotlin.**"
20+
# Examples (we use ij_kotlin_imports_layout to set an imports layout for both ktlint and IDEA via a single property):
21+
ij_kotlin_imports_layout=* # alphabetical with capital letters before lower case letters (e.g. Z before a), no blank lines
22+
ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^ # default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list
23+
ij_kotlin_imports_layout=android.**,|,^org.junit.**,kotlin.io.Closeable.*,|,*,^ # custom imports layout
24+
25+
[**/test/**.kt]
26+
ktlint_ignore_back_ticked_identifier=true
27+
28+
[*.{kt,kts}]
29+
disabled_rules=import-ordering
30+
31+
# Note that in this case 'import-ordering' rule will be active and 'indent' will be disabled
32+
[api/*.{kt,kts}]
33+
disabled_rules=indent

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @mcauto

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Issue
2+
3+
# Changelog
4+
5+
---
6+
7+
<details open> <summary>스크린샷</summary>
8+
9+
</details>

.github/workflows/android.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build android
2+
on: [push]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v2
8+
- uses: actions/setup-java@v1
9+
with:
10+
java-version: 11
11+
- name: Make Gradle executable
12+
run: chmod +x ./gradlew
13+
- name: Kotlin Lint with Gradle
14+
run: ./gradlew ktlint
15+
- name: Kotlin static code analysis with Gradle
16+
run: ./gradlew detekt
17+
- name: Test Debug APK
18+
run: ./gradlew test
19+
- name: Build with Gradle
20+
run: ./gradlew build
21+
- name: Build Debug APK
22+
run: ./gradlew assembleDebug

.github/workflows/changelog.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Changelog
3+
4+
on: [push]
5+
6+
jobs:
7+
changelog:
8+
name: Make changelog
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- run: |
13+
git fetch --prune --unshallow
14+
- uses: actions/setup-node@v1
15+
with:
16+
node-version: 10.20.1
17+
- name: Show current changelog
18+
run: |
19+
npm ci
20+
npx standard-version --dry-run --silent | grep -v Done | grep -v "\-\-\-" | grep -v standard-version

.github/workflows/release.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
name: Release
3+
4+
on:
5+
pull_request:
6+
types: [ closed ]
7+
branches:
8+
- main
9+
10+
jobs:
11+
release:
12+
if: github.event.pull_request.merged == true
13+
name: Release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- run: |
18+
git fetch --prune --unshallow
19+
- uses: actions/setup-node@v1
20+
with:
21+
node-version: 10.20.1
22+
- name: set up java 11
23+
uses: actions/setup-java@v1
24+
with:
25+
java-version: 11
26+
- name: Make Gradle executable
27+
run: chmod +x ./gradlew
28+
- name: Install dependencies
29+
run: |
30+
npm ci
31+
- name: Commit files
32+
run: |
33+
git config --local user.email "action@github.com"
34+
git config --local user.name "GitHub Action"
35+
export VERSION=$(npx next-standard-version)
36+
export DESCRIPTION=$(npx standard-version --dry-run --silent | grep -v yarn | grep -v Done | grep -v "\-\-\-" | grep -v standard-version)
37+
echo "DESCRIPTION<<EOF" >> $GITHUB_ENV
38+
echo "$DESCRIPTION" >> $GITHUB_ENV
39+
echo "EOF" >> $GITHUB_ENV
40+
echo "VERSION=$VERSION" >> $GITHUB_ENV
41+
sed -i "s/versionCode .*/versionCode ${GITHUB_RUN_NUMBER}/g" app/build.gradle
42+
sed -i "s/versionName .*/versionName \"${VERSION}\"/g" app/build.gradle
43+
git add app/build.gradle
44+
git commit --no-verify -m "chore(release): ${VERSION}"
45+
npx standard-version
46+
git tag -d v$VERSION
47+
git reset --soft HEAD~~ && git commit --no-verify --no-edit -m "chore(release): ${VERSION}"
48+
git tag v$VERSION
49+
- name: Push changes
50+
uses: ad-m/github-push-action@master
51+
with:
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
tags: true
54+
- name: Create Github Release
55+
id: create_release
56+
uses: actions/create-release@v1
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
with:
60+
tag_name: v${{ env.VERSION }}
61+
release_name: Release v${{ env.VERSION }}
62+
body: |
63+
${{ env.DESCRIPTION }}
64+
draft: false
65+
prerelease: false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
.externalNativeBuild
1414
.cxx
1515
local.properties
16+
node_modules

app/build.gradle

Lines changed: 123 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
plugins {
22
id 'com.android.application'
33
id 'kotlin-android'
4+
id "io.gitlab.arturbosch.detekt" version "1.16.0"
45
}
56

7+
apply plugin: "io.gitlab.arturbosch.detekt"
8+
69
android {
710
compileSdkVersion 30
811
buildToolsVersion "30.0.3"
@@ -24,8 +27,8 @@ android {
2427
}
2528
}
2629
compileOptions {
27-
sourceCompatibility JavaVersion.VERSION_1_8
28-
targetCompatibility JavaVersion.VERSION_1_8
30+
sourceCompatibility JavaVersion.VERSION_11
31+
targetCompatibility JavaVersion.VERSION_11
2932
}
3033
kotlinOptions {
3134
jvmTarget = '1.8'
@@ -34,12 +37,125 @@ android {
3437

3538
dependencies {
3639

37-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
38-
implementation 'androidx.core:core-ktx:1.3.1'
40+
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.32"
41+
implementation 'androidx.core:core-ktx:1.3.2'
3942
implementation 'androidx.appcompat:appcompat:1.2.0'
40-
implementation 'com.google.android.material:material:1.2.1'
41-
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
42-
testImplementation 'junit:junit:4.+'
43+
implementation 'com.google.android.material:material:1.3.0'
44+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
45+
testImplementation 'junit:junit:4.13.2'
4346
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
4447
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
48+
49+
// Detekt
50+
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.16.0"
51+
// Memory leak detection
52+
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
53+
}
54+
55+
// detekt
56+
detekt {
57+
// Version of Detekt that will be used. When unspecified the latest detekt
58+
// version found will be used. Override to stay on the same version.
59+
toolVersion = "1.16.0"
60+
61+
// The directories where detekt looks for source files.
62+
// Defaults to `files("src/main/java", "src/main/kotlin")`.
63+
input = files(
64+
"src/main/kotlin",
65+
"gensrc/main/kotlin"
66+
)
67+
68+
// Builds the AST in parallel. Rules are always executed in parallel.
69+
// Can lead to speedups in larger projects. `false` by default.
70+
parallel = false
71+
72+
// Define the detekt configuration(s) you want to use.
73+
// Defaults to the default detekt configuration.
74+
config = files("../config/detekt.yml")
75+
76+
// Applies the config files on top of detekt's default config file. `false` by default.
77+
buildUponDefaultConfig = false
78+
79+
// Turns on all the rules. `false` by default.
80+
allRules = false
81+
82+
// Specifying a baseline file. All findings stored in this file in subsequent runs of detekt.
83+
baseline = file("../config/baseline.xml")
84+
85+
// Disables all default detekt rulesets and will only run detekt with custom rules
86+
// defined in plugins passed in with `detektPlugins` configuration. `false` by default.
87+
disableDefaultRuleSets = false
88+
89+
// Adds debug output during task execution. `false` by default.
90+
debug = false
91+
92+
// If set to `true` the build does not fail when the
93+
// maxIssues count was reached. Defaults to `false`.
94+
ignoreFailures = false
95+
96+
// Android: Don't create tasks for the specified build types (e.g. "release")
97+
ignoredBuildTypes = ["release"]
98+
99+
// Android: Don't create tasks for the specified build flavor (e.g. "production")
100+
ignoredFlavors = ["production"]
101+
102+
// Android: Don't create tasks for the specified build variants (e.g. "productionRelease")
103+
ignoredVariants = ["productionRelease"]
104+
105+
// Specify the base path for file paths in the formatted reports.
106+
// If not set, all file paths reported will be absolute file path.
107+
basePath = projectDir
108+
109+
reports {
110+
// Enable/Disable XML report (default: true)
111+
xml {
112+
enabled = true
113+
destination = file("build/reports/detekt.xml")
114+
}
115+
// Enable/Disable HTML report (default: true)
116+
html {
117+
enabled = true
118+
destination = file("build/reports/detekt.html")
119+
}
120+
// Enable/Disable TXT report (default: true)
121+
txt {
122+
enabled = true
123+
destination = file("build/reports/detekt.txt")
124+
}
125+
// Enable/Disable SARIF report (default: false)
126+
sarif {
127+
enabled = true
128+
destination = file("build/reports/detekt.sarif")
129+
}
130+
custom {
131+
// The simple class name of your custom report.
132+
reportId = "CustomJsonReport"
133+
destination = file("build/reports/detekt.json")
134+
}
135+
}
136+
}
137+
tasks.detekt.jvmTarget = "1.8"
138+
139+
// ktlint
140+
repositories {
141+
mavenCentral()
142+
}
143+
configurations {
144+
ktlint
145+
}
146+
dependencies {
147+
ktlint "com.pinterest:ktlint:0.41.0"
148+
}
149+
task ktlint(type: JavaExec, group: "verification") {
150+
description = "Check Kotlin code style."
151+
classpath = configurations.ktlint
152+
main = "com.pinterest.ktlint.Main"
153+
args "src/**/*.kt", "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
154+
}
155+
check.dependsOn ktlint
156+
task ktlintFormat(type: JavaExec, group: "formatting") {
157+
description = "Fix Kotlin code style deviations."
158+
classpath = configurations.ktlint
159+
main = "com.pinterest.ktlint.Main"
160+
args "-F", "src/**/*.kt"
45161
}

app/src/androidTest/java/com/deo/android_template/ExampleInstrumentedTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ package com.deo.android_template
22

33
import androidx.test.platform.app.InstrumentationRegistry
44
import androidx.test.ext.junit.runners.AndroidJUnit4
5-
5+
import org.junit.Assert.assertEquals
66
import org.junit.Test
77
import org.junit.runner.RunWith
88

9-
import org.junit.Assert.*
10-
119
/**
1210
* Instrumented test, which will execute on an Android device.
1311
*
@@ -21,4 +19,4 @@ class ExampleInstrumentedTest {
2119
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
2220
assertEquals("com.deo.android_template", appContext.packageName)
2321
}
24-
}
22+
}

app/src/main/java/com/deo/android_template/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ class MainActivity : AppCompatActivity() {
88
super.onCreate(savedInstanceState)
99
setContentView(R.layout.activity_main)
1010
}
11-
}
11+
}

0 commit comments

Comments
 (0)