Skip to content
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

ci: generate code coverage summary using Kover #33

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 23 additions & 1 deletion .github/actions/android-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,29 @@ runs:
${{ inputs.exclude-ci-info == 'false' && format('CI (N. {0} ID {1} from: {2})',
github.run_number, github.run_id, github.head_ref || github.ref_name) || '' }}
RELEASE_DEBUG_OPT: ${{ inputs.release-debug-opt }}
run: ./gradlew --parallel ${{ inputs.check-build == 'true' && 'build' || 'assemble' }}
run: |
./gradlew --parallel \
${{ inputs.check-build == 'true' && 'build koverHtmlReportDebug koverXmlReportDebug' || 'assemble' }}
- name: Generate code coverage summary
if: inputs.check-build == 'true'
id: coverage
uses: PavanMudigonda/[email protected]
with:
coverage_results_path: build/reports/kover/reportDebug.xml
github_token: ${{ github.token }}
skip_check_run: true
minimum_coverage: 80
fail_below_threshold: false
- name: Add coverage report to workflow run summary
shell: bash
run: |
echo "## Coverage (Kover)" >> $GITHUB_STEP_SUMMARY
echo "| Outcome | Value |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
echo "| Code Coverage % | ${{ steps.coverage.outputs.coverage_percentage }} |" >> $GITHUB_STEP_SUMMARY
echo "| :heavy_check_mark: Number of Lines Covered | ${{ steps.coverage.outputs.covered_lines }} |" >> $GITHUB_STEP_SUMMARY
echo "| :x: Number of Lines Missed | ${{ steps.coverage.outputs.missed_lines }} |" >> $GITHUB_STEP_SUMMARY
echo "| Total Number of Lines | ${{ steps.coverage.outputs.total_lines }} |" >> $GITHUB_STEP_SUMMARY
- name: Post Build with Gradle
shell: bash
run: ./.github/scripts/post-build-with-gradle.sh
Expand Down
1 change: 1 addition & 0 deletions .github/scripts/post-build-with-gradle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mkdir -vp "$artifacts_dir"

# Move artifacts into a dedicated directory
mv -v build/outputs/apk/{debug,release}/*.apk "$artifacts_dir"
mv -v build/reports/kover/htmlDebug/ "$artifacts_dir/koverDebug" || true
mv -v build/reports/lint-results-debug.html "$artifacts_dir" || true

# NOTE: MD5/SHA256sum commands output as '<hash> <path/to/file>', so we should
Expand Down
34 changes: 34 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ plugins {
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
// https://mvnrepository.com/artifact/net.ltgt.errorprone/net.ltgt.errorprone.gradle.plugin
id 'net.ltgt.errorprone' version '4.0.1' apply false
// https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kover-gradle-plugin
id 'org.jetbrains.kotlinx.kover' version '0.8.3' apply false
}

allprojects {
Expand Down Expand Up @@ -101,6 +103,7 @@ apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android'
apply plugin: 'kotlin-kapt'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'org.jetbrains.kotlinx.kover'

final def versionNameCommon = [file('version.txt').text.trim()]
if (System.getenv('EXTRA_VERSION_BUILD_INFO') == null) {
Expand Down Expand Up @@ -233,6 +236,37 @@ kapt {
correctErrorTypes true
}

kover {
reports {
filters {
excludes {
// excludes class by fully-qualified JVM class name, wildcards
// '*' and '?' are available
classes(
'*BuildConfig',
// '*\$Factory',
'*.Hilt_*',
'*_ComponentTreeDeps',
'*_HiltComponents*',
'*_Impl',
'*_Impl\$*',
)
// excludes all classes located in specified package and it
// subpackages, wildcards '*' and '?' are available
packages(
'com.github.iusmac.sevensim.inject',
'hilt_aggregated_deps',
'dagger.hilt.internal.*',
)
// excludes all classes and functions, annotated by specified
// annotations, wildcards '*' and '?' are available
annotatedBy('*Generated*')
annotatedBy('*AssistedFactory')
}
}
}
}

/**
* Describe the tag relative to a commit-ish using "git describe".
*
Expand Down