From 799fba8bcb0e697ece0b21c8068bc00d5595a26a Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Sun, 29 May 2022 11:52:43 +0200 Subject: [PATCH 1/9] Add JaCoCo plugin --- app/build.gradle | 2 +- build.gradle | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 6bbd0b5..7832b65 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,6 +54,7 @@ android { debug { minifyEnabled true shrinkResources true + testCoverageEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', 'proguard-rules-debug.pro' } release { @@ -211,5 +212,4 @@ dependencies { // https://github.com/square/leakcanary/releases debugImplementation "com.squareup.leakcanary:leakcanary-android:2.9.1" - } \ No newline at end of file diff --git a/build.gradle b/build.gradle index d12e6f0..5d1530e 100644 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,8 @@ buildscript { plugins { // https://plugins.gradle.org/plugin/org.sonarqube id "org.sonarqube" version "3.3" + // https://plugins.gradle.org/plugin/nl.neotech.plugin.rootcoverage + id "nl.neotech.plugin.rootcoverage" version "1.5.1" } task clean(type: Delete) { @@ -47,4 +49,8 @@ sonarqube { property "sonar.host.url", "https://sonarcloud.io" property "sonar.androidLint.reportPaths", "build/reports/lint-results-debug.xml" } +} + +rootCoverage { + includeNoLocationClasses true } \ No newline at end of file From 2e44a6e446f193d8cd935cd0ccd772575aaaead9 Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Fri, 3 Jun 2022 17:19:46 +0200 Subject: [PATCH 2/9] Add jacoco test report tasks to Check pipeline --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index ce8571b..0fb2381 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -28,7 +28,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew check sonarqube --no-daemon + run: ./gradlew check jacocoTestReportDebug jacocoTestReportRelease sonarqube --no-daemon - name: Publish test reports uses: mikepenz/action-junit-report@v2 From fcf1608099284ab5c3d4e46b3a0e4debef6171aa Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Fri, 3 Jun 2022 17:46:11 +0200 Subject: [PATCH 3/9] Specify includeNoLocationClasses in another way --- app/build.gradle | 6 ++++++ build.gradle | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7832b65..93a7947 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,6 +72,12 @@ android { testOptions { unitTests { includeAndroidResources = true + all { + jacoco { + includeNoLocationClasses = true + excludes = ['jdk.internal.*'] + } + } } } diff --git a/build.gradle b/build.gradle index 5d1530e..ba8a700 100644 --- a/build.gradle +++ b/build.gradle @@ -49,8 +49,4 @@ sonarqube { property "sonar.host.url", "https://sonarcloud.io" property "sonar.androidLint.reportPaths", "build/reports/lint-results-debug.xml" } -} - -rootCoverage { - includeNoLocationClasses true } \ No newline at end of file From 237d3bbf0209a7474b727bf2450d59d2713f66b5 Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Fri, 3 Jun 2022 18:12:53 +0200 Subject: [PATCH 4/9] Fix gradle task name --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 0fb2381..15714ee 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -28,7 +28,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew check jacocoTestReportDebug jacocoTestReportRelease sonarqube --no-daemon + run: ./gradlew check :rootCoverageReport sonarqube --no-daemon - name: Publish test reports uses: mikepenz/action-junit-report@v2 From c719a9204f34e2c3e4ba07164f5dd93e3eadc928 Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Sun, 5 Jun 2022 15:41:25 +0200 Subject: [PATCH 5/9] Remove firebase-perf to calculate coverage https://issuetracker.google.com/issues/191774966#comment2 --- app/build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 93a7947..ac21c8c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,7 +7,6 @@ plugins { id 'org.jetbrains.kotlin.plugin.serialization' id 'com.google.gms.google-services' id 'com.google.firebase.crashlytics' - id 'com.google.firebase.firebase-perf' // https://plugins.gradle.org/plugin/com.guardsquare.appsweep id "com.guardsquare.appsweep" version "1.0.0" } @@ -185,7 +184,6 @@ dependencies { implementation platform("com.google.firebase:firebase-bom:30.0.2") implementation "com.google.firebase:firebase-analytics-ktx" implementation "com.google.firebase:firebase-crashlytics-ktx" - implementation "com.google.firebase:firebase-perf-ktx" // https://github.com/junit-team/junit4/releases testImplementation "junit:junit:4.13.2" From 76f3084f9d7cecda8149b2446aa28696ef2bd71c Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Fri, 3 Jun 2022 17:47:49 +0200 Subject: [PATCH 6/9] Update rootCoverage plugin --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ba8a700..59ce817 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ plugins { // https://plugins.gradle.org/plugin/org.sonarqube id "org.sonarqube" version "3.3" // https://plugins.gradle.org/plugin/nl.neotech.plugin.rootcoverage - id "nl.neotech.plugin.rootcoverage" version "1.5.1" + id "nl.neotech.plugin.rootcoverage" version "1.5.2" } task clean(type: Delete) { From 97900e6e755ae97dc8754a8010c35ace8fbfa207 Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Sun, 5 Jun 2022 15:50:27 +0200 Subject: [PATCH 7/9] Publish code coverage to sonarcloud --- build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.gradle b/build.gradle index 59ce817..5f430b9 100644 --- a/build.gradle +++ b/build.gradle @@ -48,5 +48,10 @@ sonarqube { property "sonar.organization", "kirmanak" property "sonar.host.url", "https://sonarcloud.io" property "sonar.androidLint.reportPaths", "build/reports/lint-results-debug.xml" + property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco.xml" } +} + +rootCoverage { + generateXml true } \ No newline at end of file From 53b4c2b41c0a8273e960a3701b95b4d5360eb81c Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Sun, 5 Jun 2022 16:00:54 +0200 Subject: [PATCH 8/9] Ignore java management invalid packages --- lint.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lint.xml b/lint.xml index 04a6f06..509af15 100644 --- a/lint.xml +++ b/lint.xml @@ -2,5 +2,7 @@ + + \ No newline at end of file From 2f0587187389d436046c7c4de1193ddcb4b976f5 Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Sun, 5 Jun 2022 16:16:09 +0200 Subject: [PATCH 9/9] Enable coverage calculation for all modules --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 15714ee..a225869 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -28,7 +28,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew check :rootCoverageReport sonarqube --no-daemon + run: ./gradlew check coverageReport sonarqube --no-daemon - name: Publish test reports uses: mikepenz/action-junit-report@v2