Skip to content

Commit

Permalink
Merge unit, screenshot tests and coverage in a single CI call (#3593)
Browse files Browse the repository at this point in the history
* Merge unit, screenshot tests and coverage tasks in a single CI call

* Disable gradle daemon too since it's all in a single gradle call now

* Make Kover upload the HTML reports on failure too
  • Loading branch information
jmartinesp authored Oct 3, 2024
1 parent f8fa218 commit 4d6b37f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
# Enrich gradle.properties for CI/CD
env:
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx7g -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options=-Xmx2g -XX:+UseG1GC
CI_GRADLE_ARG_PROPERTIES: --stacktrace -Dsonar.gradle.skipCompile=true
CI_GRADLE_ARG_PROPERTIES: --stacktrace -Dsonar.gradle.skipCompile=true --no-daemon

jobs:
tests:
Expand Down Expand Up @@ -56,22 +56,16 @@ jobs:
with:
cache-read-only: ${{ github.ref != 'refs/heads/develop' }}

- name: ⚙️ Run unit tests for debug variant
run: ./gradlew testDebugUnitTest $CI_GRADLE_ARG_PROPERTIES

- name: 📸 Run screenshot tests
run: ./gradlew verifyPaparazziDebug $CI_GRADLE_ARG_PROPERTIES

- name: 📈Generate kover report and verify coverage
run: ./gradlew :app:koverXmlReportGplayDebug :app:koverHtmlReportGplayDebug :app:koverVerifyAll $CI_GRADLE_ARG_PROPERTIES
- name: ⚙️ Check coverage for debug variant (includes unit & screenshot tests)
run: ./gradlew :tests:uitests:verifyPaparazziDebug :app:koverXmlReportGplayDebug :app:koverHtmlReportGplayDebug :app:koverVerifyAll $CI_GRADLE_ARG_PROPERTIES

- name: 🚫 Upload kover failed coverage reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: kover-error-report
path: |
app/build/reports/kover/verifyGplayDebug.err
app/build/reports/kover
- name: ✅ Upload kover report (disabled)
if: always()
Expand Down
10 changes: 0 additions & 10 deletions tests/uitests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ android {
namespace = "ui"
}

// Workaround: `kover` tasks somehow trigger the screenshot tests with a broken configuration, removing
// any previous test results and not creating new ones. This is a workaround to disable the screenshot tests
// when the `kover` tasks are detected.
tasks.withType<Test> {
if (project.gradle.startParameter.taskNames.any { it.contains("kover", ignoreCase = true) }) {
println("WARNING: Kover task detected, disabling screenshot test task $name.")
isEnabled = false
}
}

dependencies {
// Paparazzi 1.3.2 workaround (see https://github.com/cashapp/paparazzi/blob/master/CHANGELOG.md#132---2024-01-13)
constraints.add("testImplementation", "com.google.guava:guava") {
Expand Down

0 comments on commit 4d6b37f

Please sign in to comment.