https://github.com/frango9000/test-coverage-report
Github Action that displays results form popular coverage frameworks in Github's Pull Requests, Checks and Commits
https://github.com/frango9000/test-coverage-report
action actions github-actions typescript
Last synced: 2 months ago
JSON representation
Github Action that displays results form popular coverage frameworks in Github's Pull Requests, Checks and Commits
- Host: GitHub
- URL: https://github.com/frango9000/test-coverage-report
- Owner: frango9000
- License: mit
- Created: 2022-01-20T17:07:07.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-05-12T01:10:55.000Z (about 3 years ago)
- Last Synced: 2026-02-11T09:31:17.996Z (4 months ago)
- Topics: action, actions, github-actions, typescript
- Language: TypeScript
- Homepage:
- Size: 5.24 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
[](https://github.com/frango9000/test-coverage-report/releases/latest)
[](MIT) 
# Test Coverage Report
A Github Action that publishes Test Coverage Reports as a check and a comment in
the commit/pull request, with a customizable coverage requirements.
If there is already a comment on the PR, it will be updated instead of posting
multiple comments. This uses the provided title input as identifier, so if you
want multiple reports publishing multiple comments and not overwriting one
another provide different titles to each action configuration
## Usage
### Requirements
Create a workflow `.yml` file in your repositories `.github/workflows`
directory. An [example workflow](#example-workflow) is available below. For more
information, reference the GitHub Help Documentation
for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file)
.
### Inputs
- `token` - [**required**] Github personal token to add commits to Pull Request
- `title` - [*optional*] Title of the comment to post on the check/commit/pull
request
- `disable-comment` - [*optional*] set to true if you do not want to post a
comment
- `report-paths` - [**required**] List of paths to the coverage report files
- `enable-build-fail` - [*optional*] set to true if want to enforce provided
minimum coverage failing the build if not met.
- `file-coverage-error-min` - [*optional*] The minimum code coverage that is
required per file. Will fail if it is less
- `file-coverage-warn-min` - [*optional*] The minimum code coverage that is
recommended per file. Will warn if it is less
- `report-coverage-error-min` - [*optional*] The minimum code coverage that is
required per report. Will fail if it is less
- `report-coverage-warn-min` - [*optional*] The minimum code coverage that is
recommended per report. Will warn if it is less
- `global-coverage-error-min` - [*optional*] The minimum code coverage that is
required per global. Will fail if it is less
- `global-coverage-warn-min` - [*optional*] The minimum code coverage that is
recommended per global. Will warn if it is less
### Workflow Example with a Single Report
```yaml
name: Measure coverage
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
-
- name: Use Java 11
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
check-latest: true
- name: Run Coverage
run: |
chmod +x gradlew
./gradlew testCoverage
- name: Coverage Report
uses: frango9000/test-coverage-report@v0.0.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "App Name"
report-paths: ./targer/target/site/jacoco-ut/jacoco.xml
# report-types: jacoco #not needed, if jacoco report has .xml extension or lcov report has .info
file-coverage-error-min: 60
file-coverage-warn-min: 80
report-coverage-error-min: 50
report-coverage-warn-min: 70
```
### Workflow Example with Multiple Reports
```yaml
name: Measure coverage
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
-
- name: Use Java 11
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
check-latest: true
- name: Use Node 16
uses: actions/setup-node@v2.5.1
with:
node-version: '16'
- run: npm install
- name: Run Coverage
run: |
chmod +x gradlew
./gradlew testCoverage
- run: npm test --codeCoverage
- name: Coverage Report
uses: frango9000/test-coverage-report@v0.0.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "Frontend and Backend"
disable-comment: ${{ github.event_name == 'push' }} # Only post on pull request, not on commit
report-paths: |
./targer/target/site/jacoco-ut/jacoco.xml
./targer/target/site/jacoco-it/jacoco.xml
./coverage/frontend/lcov.info
report-types: |
jacoco
jacoco
lcov
report-titles: |
'Backend Unit Tests'
'Backend Integration Tests'
'Frontend Tests'
enable-build-fail: true
file-coverage-error-min: 60
file-coverage-warn-min: 80
report-coverage-error-min: 50
report-coverage-warn-min: 70
global-coverage-error-min: 40
global-coverage-warn-min: 60
```
### Example
#### Single Report

#### Multiple Reports

### Example Pull Request
[Here](https://github.com/frango9000/test-coverage-report/blob/main/.github/workflows/test.yml)
is an example of several configurations.
[Here](https://github.com/frango9000/test-coverage-report/blob/main/.github/workflows/test.yml)
is an example of output comments.
## License
The scripts and documentation in this project are released under
the [MIT License](LICENSE)