Add JaCoCo test results in the push and pull request events. Inspired by Madrapps/jacoco-report and expanded some functionalities.
report-paths
- [required] comma-separated list of JaCoCo report pathsmin-overall-instructions-coverage
- [optional, default: 0] minimum required for INSTRUCTION coverage for the project, both average and per filemin-overall-branch-coverage
- [optional, default: 0] minimum required for BRANCH coverage for the project, both average and per filemin-modified-files-instructions-coverage
- [optional, default: 0] minimum required for INSTRUCTION coverage for the modified files, both average and per filemin-modified-files-branch-coverage
- [optional, default: 0] minimum required for BRANCH coverage for the modified files, both average and per filepull-request-title
- [optional, default: ''] title of the pull request comment to be madeupdate-previous-comment
- [optional, default: false] whether to update the previous comment or not; this takes higher precendence than delete-previous-comment optiondelete-previous-comment
- [optional, default: false] whether to delete the previous comment or notgithub-token
- [required] token to use to be used for GitHub API
overall-instructions-coverage
- the overall coverage of the project for INSTRUCTIONS counteroverall-branch-coverage
- the overall coverage of the project for BRANCH countermodified-files-instructions-coverage
- the overall coverage of the modified files for INSTRUCTIONS countermodified-files-branch-coverage
- the overall coverage of the modified files for BRANCH counter
name: Jacoco Code Coverage
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out Code
uses: actions/checkout@v3
- name: Set up JDK 17.0
uses: actions/setup-java@v3
with:
distribution: "corretto"
java-version: 17.0
cache: "gradle"
- name: Run Coverage
run: |
chmod +x gradlew
./gradlew jacocoTestReport
- name: Add coverage to PR
id: jacoco
uses: juliusiglesia/[email protected]
with:
report-paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
github-token: ${{ secrets.GITHUB_TOKEN }}
min-overall-instructions-coverage: 50
min-overall-branch-coverage: 50
min-modified-files-instructions-coverage: 70
min-modified-files-branch-coverage: 70
Prerequisistes:
- node v16+
Install the dependencies
$ npm install
Build the typescript and package it for distribution
$ npm run build && npm run package
Run the tests ✔️
$ npm test
PASS ./index.test.js
✓ throws invalid number (3ms)
✓ wait 500 ms (504ms)
✓ test runs (95ms)
...
Auto-fix linting issues ✔️
$ npm run format
Actions are run from GitHub repos so we will checkin the packed dist folder.
Then run ncc and push the results:
$ npm run package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1
Note: We recommend using the --license
option for ncc, which will create a license file for all of the production node modules used in your project.
Your action is now published! 🚀
See the versioning documentation
You can now validate the action by referencing ./
in a workflow in your repo (see test.yml)
uses: ./
with:
report-paths: report
github-token: token
min-overall-instructions-coverage: 50
min-overall-branch-coverage: 50
min-modified-files-instructions-coverage: 70
min-modified-files-branch-coverage: 70
See the actions tab for runs of this action! 🚀
After testing you can create a v1 tag to reference the stable and latest V1 action