Small fixes and tweaks to the workflow file

Change-Id: I0b9d4dec4625ebbc769aa32e53f6e2af3603eb1f
ja/coverage_agp_gha_demo_remove
Jose Alcérreca 9 months ago
parent 3d65db67c9
commit e5d06a50d5

@ -101,7 +101,7 @@ jobs:
commit_message: "🤖 Updates screenshots"
# Run local tests after screenshot tests to avoid wrong UP-TO-DATE. TODO: Ignore screenshots.
- name: Run local tests
- name: Run local tests and create report
if: always()
run: ./gradlew testDemoDebug :lint:test
# Replace task exclusions with `-Pandroidx.baselineprofile.skipgeneration` when
@ -128,16 +128,6 @@ jobs:
name: local-test-results
path: '**/build/test-results/test*UnitTest/**.xml'
- name: Upload local coverage reports (XML + HTML)
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-reports
if-no-files-found: error
compression-level: 1
overwrite: false
path: '**/build/reports/coverage/*'
- name: Check lint
run: ./gradlew :app:lintProdRelease :app-nia-catalog:lintRelease :lint:lint
@ -226,7 +216,18 @@ jobs:
id: jacoco
uses: madrapps/jacoco-report@v1.6.1
with:
title: Local test coverage report
title: Combined test coverage report
paths: |
${{ github.workspace }}/**/build/reports/jacoco/**/*Report.xml
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload local coverage reports (XML + HTML)
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-reports
if-no-files-found: error
compression-level: 1
overwrite: false
path: |
'**/build/reports/jacoco/**/*Report.xml'

@ -50,6 +50,15 @@ private fun String.capitalize() = replaceFirstChar {
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
}
/**
* Creates a new task that generates a combined coverage report with data from local and
* instrumented tests.
*
* `create{variant}CombinedCoverageReport`
*
* Note that coverage data must exist before running the task. This allows us to run device
* tests on CI using a different Github Action or an external device farm.
*/
internal fun Project.configureJacoco(
androidComponentsExtension: AndroidComponentsExtension<*, *, *>,
) {
@ -58,8 +67,6 @@ internal fun Project.configureJacoco(
}
androidComponentsExtension.onVariants { variant ->
val testTaskName = "test${variant.name.capitalize()}UnitTest"
val androidtestTaskName = "connected${variant.name.capitalize()}AndroidTest"
val myObjFactory = project.objects
val buildDir = layout.buildDirectory.get().asFile
val allJars: ListProperty<RegularFile> = myObjFactory.listProperty(RegularFile::class.java)
@ -67,12 +74,6 @@ internal fun Project.configureJacoco(
val reportTask =
tasks.register("create${variant.name.capitalize()}CombinedCoverageReport", JacocoReport::class) {
// if (tasks.findByName(testTaskName) != null) {
// dependsOn(testTaskName)
// }
// if (tasks.findByName(androidtestTaskName) != null) {
// dependsOn(androidtestTaskName)
// }
classDirectories.setFrom(
allJars,
allDirectories.map { dirs ->

Loading…
Cancel
Save