Skip to content

Commit

Permalink
Adds a check with code coverage report: (#50)
Browse files Browse the repository at this point in the history
- With a check it's possible to always see the code coverage results regardless  of the workflow event type
- Code Coverage threshold status is always reported on the check regardless of `fail_below_threshold` setting. This allows setting branch protection checks regardless of workflow status
- supports push event as well

No longer fails workflow if PR cannot be determined.
  • Loading branch information
tspascoal authored Nov 1, 2021
1 parent 61b3b14 commit 273e3f1
Show file tree
Hide file tree
Showing 9 changed files with 699 additions and 6,969 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ artifacts to circumvent this. See the workflows in this project for an implement

## How it looks like

A comment is added to the pull request with the coverage report.

![alt text](img/comment.png "Pull request comment with metrics")

A check is added to the workflow run.

![alt text](img/check.png "Check with metrics")

The check will suceed or fail based on your threshold, this allows you to mandate coverage checks pass on your [protected branches](https://docs.github.com/en/github/administering-a-repository/defining-the-mergeability-of-pull-requests/about-protected-branches).

## Inputs

### `repo_token` **Required**
Expand Down Expand Up @@ -79,6 +87,8 @@ Use a unique name for the report and comment.

Pull request number associated with the report. This property should be used when workflow trigger is different than `pull_request`.

If no pull request can determine the action will skip adding the comment.

## Example usage

```yaml
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ inputs:
required: false
default: ''
only_changed_files:
description: 'Only show coverage for changed files.'
description: 'Only show coverage for changed files. (only if a PR is present)'
required: true
default: false
pull_request_number:
Expand Down
647 changes: 525 additions & 122 deletions dist/index.js

Large diffs are not rendered by default.

Binary file added img/check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ const { action } = require("./src/action");

action(github.context.payload).catch((error) => {
// Action threw an error. Fail the action with the error message.
core.debug(error.stack);
core.setFailed(error.message);
});
Loading

0 comments on commit 273e3f1

Please sign in to comment.