{"id":23157913,"url":"https://github.com/madrapps/jacoco-report","last_synced_at":"2025-04-12T03:48:32.135Z","repository":{"id":37038149,"uuid":"336253473","full_name":"Madrapps/jacoco-report","owner":"Madrapps","description":"Github action that publishes the JaCoCo report as a comment in the Pull Request","archived":false,"fork":false,"pushed_at":"2024-10-14T03:44:15.000Z","size":5562,"stargazers_count":151,"open_issues_count":18,"forks_count":63,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-20T09:09:24.446Z","etag":null,"topics":["actions","analysis","android","code-coverage","code-quality","codecoverage","coverage","github-actions","jacoco","jacoco-coverage","jacoco-report","jacoco-reports","java","javascript","kotlin","report","reporting","workflow"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/jacoco-report","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Madrapps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-05T11:33:41.000Z","updated_at":"2024-10-14T12:56:27.000Z","dependencies_parsed_at":"2024-04-30T07:00:44.143Z","dependency_job_id":"7c65133e-ba24-4fa7-828f-59f16385a07a","html_url":"https://github.com/Madrapps/jacoco-report","commit_stats":{"total_commits":162,"total_committers":11,"mean_commits":"14.727272727272727","dds":"0.28395061728395066","last_synced_commit":"c9acaa1b36f995c60841aaf1455420af1ddb8b9b"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Madrapps%2Fjacoco-report","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Madrapps%2Fjacoco-report/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Madrapps%2Fjacoco-report/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Madrapps%2Fjacoco-report/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Madrapps","download_url":"https://codeload.github.com/Madrapps/jacoco-report/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514210,"owners_count":21116899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","analysis","android","code-coverage","code-quality","codecoverage","coverage","github-actions","jacoco","jacoco-coverage","jacoco-report","jacoco-reports","java","javascript","kotlin","report","reporting","workflow"],"created_at":"2024-12-17T22:16:16.878Z","updated_at":"2025-04-12T03:48:32.096Z","avatar_url":"https://github.com/Madrapps.png","language":"JavaScript","readme":"# jacoco-report\n\n[![Tests](https://github.com/Madrapps/jacoco-report/actions/workflows/check.yml/badge.svg)](https://github.com/Madrapps/jacoco-report/actions/workflows/check.yml)\n\nA Github action that publishes the JaCoCo report as a comment in the Pull Request with customizable pass percentage for\nmodified modules, files and the overall project. You can view the coverage of just the changed files in your pull request.\n\n## Usage\n\n### Pre-requisites\n\nCreate a workflow `.yml` file in your repositories `.github/workflows` directory.\nAn [example workflow](#example-workflow) is available below. For more information, reference the GitHub Help\nDocumentation\nfor [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).\n\n### Inputs\n\n- `paths` - [**required**] Comma separated paths of the generated jacoco xml files (supports wildcard glob pattern)\n- `token` - [**required**] Github personal token to add comments to Pull Request\n- `min-coverage-overall` - [*optional* {default: 80%}] The minimum code coverage that is required to pass for overall project\n- `min-coverage-changed-files` - [*optional* {default: 80%}] The minimum code coverage that is required to pass for changed files\n- `update-comment` - [*optional* {default: false}] If true, updates the previous coverage report comment instead of creating new one.\n  Requires `title` to work properly\n- `title` - [*optional*] Title for the Pull Request comment\n- `skip-if-no-changes` - [*optional* {default: false}] If true, comment won't be added if there is no coverage information present for\n  the files changed\n- `pass-emoji` - [*optional* {default: :green_apple:}] Emoji to use for pass status shown when 'coverage \u003e= min coverage' (should be a Github supported emoji).\n- `fail-emoji` - [*optional* {default: :x:}] Emoji to use for fail status shown when 'coverage \u003c min coverage' (should be a Github supported emoji).\n- `continue-on-error` - [*optional* {default: true}] If true, then do not fail the action on error, but log a warning\n- `debug-mode` - [*optional* {default: false}] If true, run the action in debug mode and get debug logs printed in console\n\n### Outputs\n\n- `coverage-overall` - The overall coverage of the project\n- `coverage-changed-files` - The total coverage of all changed files\n\n### Example Workflow\n\n```yaml\nname: Measure coverage\n\non:\n  pull_request:\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    permissions:\n      pull-requests: write\n    steps:\n      - uses: actions/checkout@v2\n      - name: Set up JDK 1.8\n        uses: actions/setup-java@v1\n        with:\n          java-version: 1.8\n      - name: Run Coverage\n        run: |\n          chmod +x gradlew\n          ./gradlew testCoverage\n\n      - name: Add coverage to PR\n        id: jacoco\n        uses: madrapps/jacoco-report@v1.7.1\n        with:\n          paths: |\n            ${{ github.workspace }}/**/build/reports/jacoco/prodNormalDebugCoverage/prodNormalDebugCoverage.xml,\n            ${{ github.workspace }}/**/build/reports/jacoco/**/debugCoverage.xml\n          token: ${{ secrets.GITHUB_TOKEN }}\n          min-coverage-overall: 40\n          min-coverage-changed-files: 60\n```\n\n\u003cbr\u003e\n\u003cimg src=\"/preview/single-module-screenshot.png\" alt=\"single module screenshot\" title=\"single module screenshot\" width=\"700\" /\u003e\n\u003cbr\u003e\n\u003cimg src=\"/preview/multi-module-screenshot.png\" alt=\"multi-module screenshot\" title=\"multi-module screenshot\" width=\"700\" /\u003e\n\n### Understanding the Coverage Report\n\n- The \"delta\" (the negative value next to the coverage) represents the percentage of newly added or modified lines of code that are not covered by unit tests.\n  It calculates the difference in test coverage based solely on the changes made in the current commit or pull request.\n  For example, if 10 lines of code are modified or added, and 8 of those lines are covered by unit tests, the \"delta\"\n  would be -20%, indicating 20% of the newly changed code is untested. However, the \"delta\" has limitations. It can never\n  be positive, meaning if you add more unit tests to cover existing, unmodified code, this additional coverage is\n  not reflected in the delta. The metric only considers lines directly changed in the current set of modifications,\n  as there is no mechanism to track improvements in coverage for pre-existing code that hasn't been altered.\n\n### Example Project\n\nFor a working project refer to [jacoco-playgound](https://github.com/thsaravana/jacoco-playground). Check out the PR's\nin the project to get an idea on how the report is shown on a pull request comment.\nFor multi module gradle project,\nrefer [jacoco-android-playground](https://github.com/thsaravana/jacoco-android-playground)\n\n## Example Cases\n\n1. If you want to fail your workflow when the minimum coverage is not met\n\n   \u003e You can write an additional step that uses\n   \u003e the Outputs for the jacoco-report action and fail the workflow.\n   \u003e Refer [sample pull request](https://github.com/thsaravana/jacoco-playground/pull/16) and\n   \u003e its [workflow](https://github.com/thsaravana/jacoco-playground/blob/pr-failure-on-threshold/.github/workflows/coverage.yml)\n\n   ```yaml\n   - name: Fail PR if overall coverage is less than 80%\n     if: ${{ steps.jacoco.outputs.coverage-overall \u003c 80.0 }}\n     uses: actions/github-script@v6\n     with:\n       script: |\n         core.setFailed('Overall coverage is less than 80%!')\n   ```\n\n2. If you don't want to add the coverage comment everytime you push a commit to a pull request, but update the existing\n   coverage comment instead\n\n   \u003e Set the `update-comment` input to true and also set a `title` input.\n   \u003e Refer [sample pull request](https://github.com/thsaravana/jacoco-playground/pull/15) and\n   \u003e its [workflow](https://github.com/thsaravana/jacoco-playground/blob/update-comment/.github/workflows/coverage.yml)\n\n   ```yaml\n   - name: Jacoco Report to PR\n     id: jacoco\n     uses: madrapps/jacoco-report@v1.7.1\n     with:\n       paths: ${{ github.workspace }}/build/reports/jacoco/testCoverage/testCoverage.xml\n       token: ${{ secrets.GITHUB_TOKEN }}\n       min-coverage-overall: 40\n       min-coverage-changed-files: 60\n       title: Code Coverage\n       update-comment: true\n   ```\n\n3. If you have a multi-module project like `android`, with multiple modules each with its own jacoco report\n\n   \u003e Set the `paths` input with wildcard glob pattern (as shown in the Example workflow). This will pick all the files\n   \u003e matching the pattern. Ensure your pattern matches only one report per module, since for the same module, you could\n   \u003e have `debugCoverage.xml` and `releaseCoverage.xml`.\n   \u003e Refer [sample pull request](https://github.com/thsaravana/jacoco-android-playground/pull/9) and\n   \u003e its [workflow](https://github.com/thsaravana/jacoco-android-playground/blob/testing-multi-module-support/.github/workflows/coverage.yml)\n\n   ```yaml\n   - name: Jacoco Report to PR\n     id: jacoco\n     uses: madrapps/jacoco-report@v1.7.1\n     with:\n       paths: |\n         ${{ github.workspace }}/**/build/reports/jacoco/**/prodNormalDebugCoverage.xml,\n         ${{ github.workspace }}/**/build/reports/jacoco/**/debugCoverage.xml\n       token: ${{ secrets.GITHUB_TOKEN }}\n       min-coverage-overall: 40\n       min-coverage-changed-files: 60\n   ```\n\n4. When you need to customize the pass/fail emojis or the style of title in the comment\n\n   \u003e Set the `pass-emoji` and `fail-emoji` to a valid emoji supported in Github. You can add `#` to choose the style of\n   \u003e title from H1 to H6. If you don't choose, the default is H3.\n   \u003e Refer [sample pull request](https://github.com/thsaravana/jacoco-android-playground/pull/10) and\n   \u003e its [workflow](https://github.com/thsaravana/jacoco-android-playground/blob/testing-custom-emoji-support/.github/workflows/coverage.yml)\n\n   ```yaml\n   - name: Jacoco Report to PR\n     id: jacoco\n     uses: madrapps/jacoco-report@v1.7.1\n     with:\n       paths: ${{ github.workspace }}/build/reports/jacoco/testCoverage/testCoverage.xml\n       token: ${{ secrets.GITHUB_TOKEN }}\n       min-coverage-overall: 40\n       min-coverage-changed-files: 60\n       title: '# :lobster: Coverage Report'\n       pass-emoji: ':green_circle:'\n       fail-emoji: ':red_circle:'\n   ```\n\n## Troubleshooting\n\n1. If the PR is created by bots like _dependabot_, then the GITHUB_TOKEN won't have sufficient access to write the\n   coverage comment. So add the appropriate permission to your job (as shown in the Example workflow). More information\n   [here](https://github.com/Madrapps/jacoco-report/issues/24).\n\n## Contributing\n\nWe welcome contributions, and if you're interested, have a look at the [CONTRIBUTING](CONTRIBUTING.md) document.\n\n## License\n\nThe scripts and documentation in this project are released under the [MIT License](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadrapps%2Fjacoco-report","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadrapps%2Fjacoco-report","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadrapps%2Fjacoco-report/lists"}