Skip to content

Commit fd96233

Browse files
committed
Add CI
1 parent 463a4ad commit fd96233

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Android CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: set up JDK 17
15+
uses: actions/setup-java@v4
16+
with:
17+
java-version: '17'
18+
distribution: 'temurin'
19+
cache: gradle
20+
21+
- name: Grant execute permission for gradlew
22+
run: chmod +x gradlew
23+
24+
- name: Run Unit Tests and Generate Coverage
25+
run: ./gradlew testFreeVersionDebugUnitTest jacocoTestReport
26+
27+
- name: Upload Coverage Report
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: coverage-report
31+
path: app/build/reports/jacoco/jacocoTestReport/html/

app/build.gradle

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
id 'org.jetbrains.kotlin.plugin.serialization'
55
id 'com.google.devtools.ksp'
66
id 'org.jetbrains.kotlin.plugin.compose'
7+
id 'jacoco'
78
}
89

910
kotlin {
@@ -36,6 +37,9 @@ android {
3637
shrinkResources = true
3738
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
3839
}
40+
debug {
41+
enableUnitTestCoverage true
42+
}
3943
}
4044
flavorDimensions += "version"
4145
productFlavors {
@@ -101,3 +105,23 @@ dependencies {
101105
implementation 'ru.gildor.coroutines:kotlin-coroutines-okhttp:1.0'
102106
implementation 'io.github.rburgst:okhttp-digest:3.1.1'
103107
}
108+
109+
tasks.register('jacocoTestReport', JacocoReport) {
110+
dependsOn 'testFreeVersionDebugUnitTest'
111+
112+
reports {
113+
xml.required = true
114+
html.required = true
115+
}
116+
117+
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
118+
def debugTree = fileTree(dir: "${project.layout.buildDirectory.get().asFile}/intermediates/javac/freeVersionDebug/classes", excludes: fileFilter)
119+
def kotlinDebugTree = fileTree(dir: "${project.layout.buildDirectory.get().asFile}/tmp/kotlin-classes/freeVersionDebug", excludes: fileFilter)
120+
def mainSrc = "${project.projectDir}/src/main/java"
121+
122+
sourceDirectories.setFrom(files([mainSrc]))
123+
classDirectories.setFrom(files([debugTree, kotlinDebugTree]))
124+
executionData.setFrom(fileTree(dir: project.layout.buildDirectory.get().asFile, includes: [
125+
"jacoco/testFreeVersionDebugUnitTest.exec"
126+
]))
127+
}

0 commit comments

Comments
 (0)