Skip to content

Commit fbd7212

Browse files
authored
Merge pull request #30 from superus8r/chore/DROID-12_FixJacocoUnifiedCoverageReport
DROID-12: Fix Jacoco Unified Coverage Report
2 parents 9708dc8 + 5670cba commit fbd7212

File tree

7 files changed

+107
-72
lines changed

7 files changed

+107
-72
lines changed

.circleci/config.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2.1
22
orbs:
3-
codecov: codecov/codecov@3.2.4
3+
codecov: codecov/codecov@5.4.3
44
ruby: circleci/[email protected]
55

66
commands:
@@ -9,7 +9,11 @@ commands:
99
- restore_cache:
1010
key: v1-gradle-wrapper-{{ arch }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
1111
- restore_cache:
12-
key: v1-gradle-cache-{{ arch }}-{{ checksum "build.gradle" }}
12+
key: v1-gradle-cache-{{ arch }}-{{ checksum "build.gradle" }}-{{ checksum "settings.gradle" }}-{{ checksum "gradle.properties" }}-{{ checksum "app/build.gradle.kts" }}
13+
restore_bundler_cache:
14+
steps:
15+
- restore_cache:
16+
key: v1-bundler-cache-{{ checksum "Gemfile.lock" }}
1317

1418
save_gradle_cache:
1519
steps:
@@ -20,7 +24,13 @@ commands:
2024
- save_cache:
2125
paths:
2226
- ~/.gradle/caches
23-
key: v1-gradle-cache-{{ arch }}-{{ checksum "build.gradle" }}
27+
key: v1-gradle-cache-{{ arch }}-{{ checksum "build.gradle" }}-{{ checksum "settings.gradle" }}-{{ checksum "gradle.properties" }}-{{ checksum "app/build.gradle.kts" }}
28+
save_bundler_cache:
29+
steps:
30+
- save_cache:
31+
paths:
32+
- vendor/bundle
33+
key: v1-bundler-cache-{{ checksum "Gemfile.lock" }}
2434

2535
executors:
2636
android-machine:
@@ -37,18 +47,20 @@ jobs:
3747
steps:
3848
- checkout
3949
- restore_gradle_cache
50+
- restore_bundler_cache
4051
- ruby/install-deps:
4152
with-cache: true
4253
- run:
4354
name: Fastlane - run all tests with coverage report
4455
command: |
4556
bundle exec fastlane testDev
4657
- save_gradle_cache
58+
- save_bundler_cache
4759
- run:
4860
name: Analyze on SonarCloud
4961
command: ./gradlew lintDebug sonar
5062
- codecov/upload:
51-
file: app/build/mergedReportDir/jacocoTestReport/jacocoTestReport.xml
63+
files: app/build/mergedReportDir/jacocoTestReport/jacocoTestReport.xml
5264
- store_test_results:
5365
path: app/build/test-results/testDebugUnitTest
5466
- store_artifacts:

.github/workflows/android.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,17 @@ jobs:
9696
with:
9797
api-level: 29
9898
script: ./gradlew connectedCheck
99+
100+
notify-slack:
101+
needs: unit-test
102+
runs-on: ubuntu-latest
103+
if: always() # Runs regardless of success or failure of unit-test
104+
steps:
105+
- name: Send Slack notification
106+
env:
107+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_GITHUB_BUILD_INFO }}
108+
run: |
109+
STATUS="${{ needs.unit-test.result }}"
110+
curl -X POST -H 'Content-type: application/json' \
111+
--data "{\"text\":\"Unit tests completed: $STATUS\"}" \
112+
$SLACK_WEBHOOK_URL

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
source "https://rubygems.org"
22

3-
gem "fastlane"
3+
gem "fastlane", ">= 2.220.0"
44
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
55
eval_gemfile(plugins_path) if File.exist?(plugins_path)

Gemfile.lock

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ GEM
1010
artifactory (3.0.17)
1111
atomos (0.1.3)
1212
aws-eventstream (1.3.2)
13-
aws-partitions (1.1095.0)
14-
aws-sdk-core (3.222.3)
13+
aws-partitions (1.1108.0)
14+
aws-sdk-core (3.224.1)
1515
aws-eventstream (~> 1, >= 1.3.0)
1616
aws-partitions (~> 1, >= 1.992.0)
1717
aws-sigv4 (~> 1.9)
1818
base64
1919
jmespath (~> 1, >= 1.6.1)
2020
logger
21-
aws-sdk-kms (1.99.0)
21+
aws-sdk-kms (1.101.0)
2222
aws-sdk-core (~> 3, >= 3.216.0)
2323
aws-sigv4 (~> 1.5)
24-
aws-sdk-s3 (1.184.0)
25-
aws-sdk-core (~> 3, >= 3.216.0)
24+
aws-sdk-s3 (1.187.0)
25+
aws-sdk-core (~> 3, >= 3.224.1)
2626
aws-sdk-kms (~> 1)
2727
aws-sigv4 (~> 1.5)
2828
aws-sigv4 (1.11.0)
@@ -70,14 +70,14 @@ GEM
7070
faraday_middleware (1.2.1)
7171
faraday (~> 1.0)
7272
fastimage (2.4.0)
73-
fastlane (2.218.0)
73+
fastlane (2.227.2)
7474
CFPropertyList (>= 2.3, < 4.0.0)
7575
addressable (>= 2.8, < 3.0.0)
7676
artifactory (~> 3.0)
7777
aws-sdk-s3 (~> 1.0)
7878
babosa (>= 1.0.3, < 2.0.0)
7979
bundler (>= 1.12.0, < 3.0.0)
80-
colored
80+
colored (~> 1.2)
8181
commander (~> 4.6)
8282
dotenv (>= 2.1.1, < 3.0.0)
8383
emoji_regex (>= 0.1, < 4.0)
@@ -86,9 +86,11 @@ GEM
8686
faraday-cookie_jar (~> 0.0.6)
8787
faraday_middleware (~> 1.0)
8888
fastimage (>= 2.1.0, < 3.0.0)
89+
fastlane-sirp (>= 1.0.0)
8990
gh_inspector (>= 1.1.2, < 2.0.0)
9091
google-apis-androidpublisher_v3 (~> 0.3)
9192
google-apis-playcustomapp_v1 (~> 0.1)
93+
google-cloud-env (>= 1.6.0, < 2.0.0)
9294
google-cloud-storage (~> 1.31)
9395
highline (~> 2.0)
9496
http-cookie (~> 1.0.5)
@@ -97,64 +99,61 @@ GEM
9799
mini_magick (>= 4.9.4, < 5.0.0)
98100
multipart-post (>= 2.0.0, < 3.0.0)
99101
naturally (~> 2.2)
100-
optparse (>= 0.1.1)
102+
optparse (>= 0.1.1, < 1.0.0)
101103
plist (>= 3.1.0, < 4.0.0)
102104
rubyzip (>= 2.0.0, < 3.0.0)
103-
security (= 0.1.3)
105+
security (= 0.1.5)
104106
simctl (~> 1.6.3)
105107
terminal-notifier (>= 2.0.0, < 3.0.0)
106108
terminal-table (~> 3)
107109
tty-screen (>= 0.6.3, < 1.0.0)
108110
tty-spinner (>= 0.8.0, < 1.0.0)
109111
word_wrap (~> 1.0.0)
110112
xcodeproj (>= 1.13.0, < 2.0.0)
111-
xcpretty (~> 0.3.0)
112-
xcpretty-travis-formatter (>= 0.0.3)
113-
fastlane-plugin-firebase_app_distribution (0.9.1)
113+
xcpretty (~> 0.4.1)
114+
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
115+
fastlane-plugin-firebase_app_distribution (0.10.1)
114116
google-apis-firebaseappdistribution_v1 (~> 0.3.0)
115117
google-apis-firebaseappdistribution_v1alpha (~> 0.2.0)
118+
fastlane-sirp (1.0.0)
119+
sysrandom (~> 1.0)
116120
gh_inspector (1.1.3)
117-
google-apis-androidpublisher_v3 (0.78.0)
118-
google-apis-core (>= 0.15.0, < 2.a)
119-
google-apis-core (0.17.0)
121+
google-apis-androidpublisher_v3 (0.54.0)
122+
google-apis-core (>= 0.11.0, < 2.a)
123+
google-apis-core (0.11.3)
120124
addressable (~> 2.5, >= 2.5.1)
121-
googleauth (~> 1.9)
122-
httpclient (>= 2.8.3, < 3.a)
125+
googleauth (>= 0.16.2, < 2.a)
126+
httpclient (>= 2.8.1, < 3.a)
123127
mini_mime (~> 1.0)
124-
mutex_m
125128
representable (~> 3.0)
126129
retriable (>= 2.0, < 4.a)
130+
rexml
127131
google-apis-firebaseappdistribution_v1 (0.3.0)
128132
google-apis-core (>= 0.11.0, < 2.a)
129133
google-apis-firebaseappdistribution_v1alpha (0.2.0)
130134
google-apis-core (>= 0.11.0, < 2.a)
131-
google-apis-iamcredentials_v1 (0.23.0)
132-
google-apis-core (>= 0.15.0, < 2.a)
133-
google-apis-playcustomapp_v1 (0.16.0)
134-
google-apis-core (>= 0.15.0, < 2.a)
135-
google-apis-storage_v1 (0.50.0)
136-
google-apis-core (>= 0.15.0, < 2.a)
135+
google-apis-iamcredentials_v1 (0.17.0)
136+
google-apis-core (>= 0.11.0, < 2.a)
137+
google-apis-playcustomapp_v1 (0.13.0)
138+
google-apis-core (>= 0.11.0, < 2.a)
139+
google-apis-storage_v1 (0.31.0)
140+
google-apis-core (>= 0.11.0, < 2.a)
137141
google-cloud-core (1.8.0)
138142
google-cloud-env (>= 1.0, < 3.a)
139143
google-cloud-errors (~> 1.0)
140-
google-cloud-env (2.3.0)
141-
base64 (~> 0.2)
142-
faraday (>= 1.0, < 3.a)
144+
google-cloud-env (1.6.0)
145+
faraday (>= 0.17.3, < 3.0)
143146
google-cloud-errors (1.5.0)
144-
google-cloud-storage (1.56.0)
147+
google-cloud-storage (1.47.0)
145148
addressable (~> 2.8)
146149
digest-crc (~> 0.4)
147-
google-apis-core (~> 0.13)
148-
google-apis-iamcredentials_v1 (~> 0.18)
149-
google-apis-storage_v1 (>= 0.42)
150+
google-apis-iamcredentials_v1 (~> 0.1)
151+
google-apis-storage_v1 (~> 0.31.0)
150152
google-cloud-core (~> 1.6)
151-
googleauth (~> 1.9)
153+
googleauth (>= 0.16.2, < 2.a)
152154
mini_mime (~> 1.0)
153-
google-logging-utils (0.2.0)
154-
googleauth (1.14.0)
155-
faraday (>= 1.0, < 3.a)
156-
google-cloud-env (~> 2.2)
157-
google-logging-utils (~> 0.1)
155+
googleauth (1.8.1)
156+
faraday (>= 0.17.3, < 3.a)
158157
jwt (>= 1.4, < 3.0)
159158
multi_json (~> 1.11)
160159
os (>= 0.9, < 2.0)
@@ -165,7 +164,7 @@ GEM
165164
httpclient (2.9.0)
166165
mutex_m
167166
jmespath (1.6.2)
168-
json (2.11.3)
167+
json (2.12.2)
169168
jwt (2.10.1)
170169
base64
171170
logger (1.7.0)
@@ -188,10 +187,10 @@ GEM
188187
uber (< 0.2.0)
189188
retriable (3.1.2)
190189
rexml (3.4.1)
191-
rouge (2.0.7)
190+
rouge (3.28.0)
192191
ruby2_keywords (0.0.5)
193192
rubyzip (2.4.1)
194-
security (0.1.3)
193+
security (0.1.5)
195194
signet (0.20.0)
196195
addressable (~> 2.8)
197196
faraday (>= 0.17.5, < 3.a)
@@ -200,6 +199,7 @@ GEM
200199
simctl (1.6.10)
201200
CFPropertyList
202201
naturally
202+
sysrandom (1.0.5)
203203
terminal-notifier (2.0.0)
204204
terminal-table (3.0.2)
205205
unicode-display_width (>= 1.1.1, < 3)
@@ -218,8 +218,8 @@ GEM
218218
colored2 (~> 3.1)
219219
nanaimo (~> 0.4.0)
220220
rexml (>= 3.3.6, < 4.0)
221-
xcpretty (0.3.0)
222-
rouge (~> 2.0.7)
221+
xcpretty (0.4.1)
222+
rouge (~> 3.28.0)
223223
xcpretty-travis-formatter (1.0.1)
224224
xcpretty (~> 0.2, >= 0.0.7)
225225

@@ -230,7 +230,7 @@ PLATFORMS
230230
x86_64-linux
231231

232232
DEPENDENCIES
233-
fastlane
233+
fastlane (>= 2.220.0)
234234
fastlane-plugin-firebase_app_distribution
235235

236236
BUNDLED WITH

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ More info on official Sonar docs: [SonarScanner for Gradle](https://docs.sonarcl
7474

7575

7676
## Knows Issues
77+
- Jacoco coverage report is incorrect
7778
- Please feel free inform me about new issues
7879

7980

app/build.gradle.kts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ android {
7070

7171
animationsDisabled = true
7272

73+
@Suppress("UnstableApiUsage")
7374
managedDevices {
74-
devices {
75+
allDevices {
7576
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel2api30").apply {
7677
device = "Pixel 2"
7778
apiLevel = 30
@@ -109,16 +110,25 @@ tasks.register<JacocoReport>("jacocoTestReport") {
109110
csv.required.set(false)
110111
}
111112

112-
val fileFilter = listOf("**/R.class", "**/R$*.class", "**/BuildConfig.*", "**/Manifest*.*", "**/*Test*.*", "android/**/*.*")
113-
val debugTree = fileTree("${layout.buildDirectory}/tmp/kotlin-classes/debug") { exclude(fileFilter) }
114-
val mainSrc = "${layout.projectDirectory}/src/main/kotlin"
115-
116-
sourceDirectories.from(files(setOf(mainSrc)))
117-
classDirectories.from(files(setOf(debugTree)))
118-
executionData.from(fileTree(layout.buildDirectory) { include(setOf(
119-
"outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec",
120-
"outputs/managed_device_code_coverage/pixel2api30/coverage.ec"
121-
))})
113+
val fileFilter = listOf(
114+
"**/R.class", "**/R$*.class", "**/BuildConfig.*", "**/Manifest*.*",
115+
"**/*Test*.*", "android/**/*.*",
116+
"**/Dagger*.*", "**/*_Hilt*.*", "**/*Hilt*.*",
117+
"**/ui/**" // Exclude UI files from coverage
118+
)
119+
val javaDebugTree = fileTree(layout.buildDirectory.dir("intermediates/javac/debug/classes")) { exclude(fileFilter) }
120+
val kotlinDebugTree = fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/debug")) { exclude(fileFilter) }
121+
val mainJavaSrc = layout.projectDirectory.dir("src/main/java")
122+
val mainKotlinSrc = layout.projectDirectory.dir("src/main/kotlin")
123+
sourceDirectories.from(files(mainJavaSrc, mainKotlinSrc))
124+
classDirectories.from(files(javaDebugTree, kotlinDebugTree))
125+
executionData.from(fileTree(layout.buildDirectory) {
126+
include(
127+
"outputs/unit_test_code_coverage/**/*.exec",
128+
"outputs/managed_device_code_coverage/**/*.ec",
129+
"outputs/managed_device_code_coverage/**/*.exec"
130+
)
131+
})
122132
}
123133

124134
sonarqube {
@@ -284,4 +294,4 @@ dependencies {
284294

285295
// Android Serial Controller
286296
implementation("com.github.superus8r:UsbSerial:6.1.1")
287-
}
297+
}

build.gradle

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,20 @@ plugins {
2323
}
2424

2525
task clean(type: Delete) {
26-
delete rootProject.buildDir
26+
delete layout.buildDirectory
2727
}
2828

2929
sonarqube {
3030
properties {
31-
property "sonar.organization", "superus8r"
32-
property "sonar.projectKey", "superus8r_arduino-usb-terminal"
33-
property "sonar.projectName", "arduino-usb-terminal"
34-
property "sonar.sourceEncoding", "UTF-8"
35-
property "sonar.host.url", "https://sonarcloud.io"
31+
property("sonar.organization", "superus8r")
32+
property("sonar.projectKey", "superus8r_arduino-usb-terminal")
33+
property("sonar.projectName", "arduino-usb-terminal")
34+
property("sonar.sourceEncoding", "UTF-8")
35+
property("sonar.host.url", "https://sonarcloud.io")
3636

37-
// sonar requires relative path for sources and binaries
38-
property "sonar.sources", "/app/src/main/java"
39-
property "sonar.binaries", "/app/build/tmp/kotlin-classes/debug"
37+
property("sonar.binaries", project(":app").layout.buildDirectory.dir("tmp/kotlin-classes/debug").get().asFile.absolutePath)
4038
// sonar requires absolute path for lint and jacoco reports!
41-
property "sonar.androidLint.reportPaths", "$rootDir/app/build/reports/lint-results-debug.xml"
42-
property "sonar.coverage.jacoco.xmlReportPaths", "$rootDir/app/build/mergedReportDir/jacocoTestReport/jacocoTestReport.xml"
39+
property("sonar.androidLint.reportPaths", project(":app").layout.buildDirectory.dir("reports/lint-results-debug.xml").get().asFile.absolutePath)
40+
property("sonar.coverage.jacoco.xmlReportPaths", project(":app").layout.buildDirectory.dir("mergedReportDir/jacocoTestReport/jacocoTestReport.xml").get().asFile.absolutePath)
4341
}
44-
}
42+
}

0 commit comments

Comments
 (0)