{"id":20208118,"url":"https://github.com/clearlyip/code-coverage-report-action","last_synced_at":"2025-04-10T12:55:02.424Z","repository":{"id":60006858,"uuid":"538706389","full_name":"clearlyip/code-coverage-report-action","owner":"clearlyip","description":"Provides Code Coverage reports in Github Actions","archived":false,"fork":false,"pushed_at":"2025-04-02T17:42:39.000Z","size":7368,"stargazers_count":8,"open_issues_count":1,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-02T18:44:32.722Z","etag":null,"topics":["coverage","github-actions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/clearlyip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-19T21:39:27.000Z","updated_at":"2025-04-02T17:59:43.000Z","dependencies_parsed_at":"2023-01-11T17:23:31.712Z","dependency_job_id":"215ad62b-74d9-4adc-9863-b3ef48bcd4b5","html_url":"https://github.com/clearlyip/code-coverage-report-action","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":0.4444444444444444,"last_synced_commit":"08f140d1ababe3ee4f3786a97dbe231cd9c63dde"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearlyip%2Fcode-coverage-report-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearlyip%2Fcode-coverage-report-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearlyip%2Fcode-coverage-report-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clearlyip%2Fcode-coverage-report-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clearlyip","download_url":"https://codeload.github.com/clearlyip/code-coverage-report-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248221748,"owners_count":21067619,"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":["coverage","github-actions"],"created_at":"2024-11-14T05:34:12.707Z","updated_at":"2025-04-10T12:55:02.416Z","avatar_url":"https://github.com/clearlyip.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Code Coverage Report\n\n[![ci](https://github.com/clearlyip/code-coverage-report-action/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/clearlyip/code-coverage-report-action/actions/workflows/ci.yml)\n\nThis action looks for a defined `clover` or `cobertura` file and parses that to give you feedback not only about current coverage but also coverage against the base a pull request might be merging into. It uses Github's workflow artifacts to store the raw coverage files for later comparison and it generates a markdown file that is appended to the [job summary](https://github.com/clearlyip/code-coverage-report-action/actions/runs/3109427303) and that can also be used in something like [marocchino/sticky-pull-request-comment](https://github.com/marocchino/sticky-pull-request-comment). (See our workflows for examples)\n\n![Example Comment](/images/image1.png?raw=true 'Example Comment')\n\n## Why this action?\n\nI couldn't find any action that did comparisons between branches in a pull request (without committing back to the repository). Plus I like the idea of this being written in typescript which compiles down to javascript since it's supported in all of Github's runner environments\n\n## Usage\n\n#### Default Usage\n\nThis example will execute when any pull request is made against the branch `main` or if any code is pushed to the branch `main`. It then uses `marocchino/sticky-pull-request-comment` to post a comment with the coverage back to the Pull Request\n\n**ci.yml**\n\n```yml\nname: 'ci'\non:\n  pull_request:\n    branches:\n      - main\n  push:\n    branches:\n      - main\n\n#Cancel previous run multiple runs\nconcurrency:\n  group: ${{ github.ref }}\n  cancel-in-progress: true\n\n#https://github.com/marocchino/sticky-pull-request-comment/tree/v2/#basic\npermissions: write-all\njobs:\n  ci:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      #Step to generate coverage file\n      - name: Generate Coverage Report\n        uses: clearlyip/code-coverage-report-action@v5\n        id: code_coverage_report_action\n        #Dont run for dependabot unless you fix PR comment permissions\n        if: ${{ github.actor != 'dependabot[bot]'}}\n        with:\n          #Location of the generate coverage file\n          filename: 'coverage/clover.xml'\n          fail_on_negative_difference: true\n          artifact_download_workflow_names: 'ci,cron'\n      - name: Add Coverage PR Comment\n        uses: marocchino/sticky-pull-request-comment@v2\n        #Make sure the report was generated and that the event is actually a pull request, run if failed or success\n        if: steps.code_coverage_report_action.outputs.file != '' \u0026\u0026 github.event_name == 'pull_request' \u0026\u0026 (success() || failure())\n        with:\n          recreate: true\n          path: code-coverage-results.md\n```\n\n**cron.yml**\n\n```yml\nname: 'cron'\non:\n  #Allows for manual runs\n  workflow_dispatch:\n  #Runs at 00:00, on day 1 of the month (every ~30 days)\n  schedule:\n    - cron: '0 0 1 * *'\n\njobs:\n  cron:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      #Step to generate coverage file\n      - uses: clearlyip/code-coverage-report-action@v5\n        with:\n          #Location of the generated coverage file\n          filename: 'coverage/clover.xml'\n```\n\n### Inputs\n\nSee [action.yml](action.yml)\n\n### Outputs\n\nThe following outputs are returned from the action. You can utilize these outputs in other steps as long as you set an `id` against the step that uses this action (see the `Default Usage` example)\n\n#### file\n\nThe generated markdown file path\n\n#### coverage\n\nThe overall coverage of the project as a percentage\n\n## Development\n\n### Installation\n\n```shell\nnpm install\n```\n\n### Dev Watch\n\n```shell\nmake watch\n```\n\n### Test Drive using ACT (https://github.com/nektos/act)\n\n```shell\nmake act\n```\n\n### Packaging for marketplace\n\n```shell\nmake\n```\n\n## FAQ\n\n### Artifacts\n\nThis action uses artifacts to store the coverage files so they can be referenced later for differences when using pull requests. The benefits of this are that you don't have to run any type of hosted server. However Github has retenion limits on artifacts. As a result there are a couple of things you need to know\n\n#### Retention\n\nGithub states the following:\n\n- The retention period for artifacts for public repositories is anywhere **_between 1 day or 90 days_**.\n- The retention period for artifacts for private repositories is _**between 1 day or 400 days**_.\n\nAs a result of this you will need to setup a job to run that will process your coverage files less than your retention period. Otherwise you wont get diffs when made against branches.\n\nThe example below uses two workflow actions. `workflow_dispatch` which allows you to manually run this workflow and `schedule` which is set to run monthly (~30 days).\n\nIn the job steps we setup our environment and then we run our test suite which generates our coverage file, then we process this file. Since the event name is not `pull_request` the action simply takes the coverage file and places it inside the artifact\n\n```yml\nname: 'cron'\non:\n  #Allows for manual runs\n  workflow_dispatch:\n  #Runs at 00:00, on day 1 of the month (every ~30 days)\n  schedule:\n    - cron: '0 0 1 * *'\n\njobs:\n  cron:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      #Step to generate coverage file\n      - uses: clearlyip/code-coverage-report-action@v5\n        with:\n          #Location of the generated coverage file\n          filename: 'coverage/clover.xml'\n```\n\nAfter this is done you will need to modify any job that uses this action to reference itself and additionally the `cron` workflow above by name using `artifact_download_workflow_names`:\n\n```yml\n- uses: clearlyip/code-coverage-report-action@v5\n  with:\n    filename: 'coverage/clover.xml'\n    fail_on_negative_difference: true\n    artifact_download_workflow_names: 'ci,cron'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclearlyip%2Fcode-coverage-report-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclearlyip%2Fcode-coverage-report-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclearlyip%2Fcode-coverage-report-action/lists"}