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

feat: Add Jacoco coverage and report generation #227

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

albendz
Copy link
Contributor

@albendz albendz commented Oct 27, 2024

Contributor checklist


Description

This change adds the Jacoco plugin to the app/gradle.build.kts file with configuration to generate coverage reports.

Additionally, this adds a step to the unit test Github workflow to use the generated coverage XML to create a comment on PRs. This is not configured to fail the PR build. Details: https://github.com/marketplace/actions/jacoco-report

One thing I wasn't able to configure is coverage verification checks and build time.

I followed details provided in this Medium article on adding coverage to Android projects: https://medium.com/@nachare.reena8/measure-your-codes-reach-integrating-jacoco-code-coverage-in-android-apps-with-kotlin-dsl-382d577864e7

Testing

./gradlew tasks output:

Reporting tasks
---------------
jacocoCoreDebugCodeCoverage - Generate Jacoco coverage reports for the CoreDebug build
jacocoCoreReleaseCodeCoverage - Generate Jacoco coverage reports for the CoreRelease build
jacocoFdroidDebugCodeCoverage - Generate Jacoco coverage reports for the FdroidDebug build
jacocoFdroidReleaseCodeCoverage - Generate Jacoco coverage reports for the FdroidRelease build

Verified ./gradlew jacocoCoreDebugCodeCoverage generates files with expected content:

  • build/reports/jacoco/jacocoCoreDebugCodeCoverage/jacocoCoreDebugCodeCoverage.xml
  • build/reports/jacoco/jacocoCoreDebugCodeCoverage/html/index.html

The github action/workflow fails to post a comment to the PR when run. I'm not sure what's causing that. I've enabled debug logging on the action/workflow but someone with repo management permissions may need to help me understand what's going wrong with the token permissions.

Related issue

Copy link

Thank you for the pull request!

The Scribe team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)

If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Android rooms once you're in. Also consider joining our bi-weekly Saturday dev syncs. It'd be great to have you!

Maintainer checklist

  • The linting and formatting workflows within the PR checks do not indicate new errors in the files changed

  • The CHANGELOG has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

@albendz albendz marked this pull request as ready for review October 31, 2024 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant