Skip to content

Test and verify coverage only on debug variant #2556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@ jobs:
with:
cache-read-only: ${{ github.ref != 'refs/heads/develop' }}

- name: ⚙️ Run unit tests, debug and release
run: ./gradlew test $CI_GRADLE_ARG_PROPERTIES
- name: ⚙️ Run unit tests for debug variant
run: ./gradlew testDebugUnitTest $CI_GRADLE_ARG_PROPERTIES
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if ./gradlew testGplayDebugUnitTest would be enough.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. I kept it like that in case we add some fdroid only tests in the future. I'll change it and see if anything changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, that will only run :app:testGplayDebugUnitTest according to --dry-run, since the flavor only exists in that module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK 👍


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

- name: 📈Generate kover report and verify coverage
run: ./gradlew :app:koverHtmlReport :app:koverXmlReport :app:koverVerify $CI_GRADLE_ARG_PROPERTIES -Pci-build=true
run: ./gradlew :app:koverXmlReportGplayDebug :app:koverHtmlReportGplayDebug :app:koverVerifyGplayDebug $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/verify.err
app/build/reports/kover/verifyGplayDebug.err

- name: ✅ Upload kover report (disabled)
if: always()
Expand All @@ -85,5 +85,5 @@ jobs:
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
# with:
# files: build/reports/kover/xml/report.xml
files: app/build/reports/kover/reportGplayDebug.xml
verbose: true
23 changes: 1 addition & 22 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import extension.gitBranchName
import extension.gitRevision
import extension.koverDependencies
import extension.setupKover
import org.jetbrains.kotlin.cli.common.toBooleanLenient

plugins {
id("io.element.android-compose-application")
Expand Down Expand Up @@ -189,7 +188,7 @@ androidComponents {
val abiCode = abiVersionCodes[name] ?: 0
// Assigns the new version code to output.versionCode, which changes the version code
// for only the output APK, not for the variant itself.
output.versionCode.set((output.versionCode.get() ?: 0) * 10 + abiCode)
output.versionCode.set((output.versionCode.orNull ?: 0) * 10 + abiCode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
}
}
Expand All @@ -215,26 +214,6 @@ knit {
}
}

val ciBuildProperty = "ci-build"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter ci-build is also used in nightlyReports.yml, I think it can be removed from this file too.

val isCiBuild = if (project.hasProperty(ciBuildProperty)) {
val raw = project.property(ciBuildProperty) as? String
raw?.toBooleanLenient() == true || raw?.toIntOrNull() == 1
} else {
false
}

kover {
// When running on the CI, run only debug test variants
if (isCiBuild) {
excludeTests {
// Disable instrumentation for debug test tasks
tasks(
"testDebugUnitTest",
)
}
}
}

dependencies {
allLibrariesImpl()
allServicesImpl()
Expand Down
3 changes: 0 additions & 3 deletions plugins/src/main/kotlin/extension/KoverExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ fun Project.setupKover() {
defaults {
// add reports of both 'debug' and 'release' Android build variants to default reports
mergeWith("gplayDebug")
mergeWith("gplayRelease")

verify {
onCheck = true
Expand Down Expand Up @@ -203,8 +202,6 @@ fun Project.setupKover() {
}
}
}

androidReports("gplayRelease") {}
}
}

Expand Down