Skip to content

Commit fbeef4f

Browse files
committed
docs: github action improvements
1 parent a284939 commit fbeef4f

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

docs/github_action.md

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# go-test-coverage GitHub Action
22

33

4-
# Usage
4+
## Usage
55

66
Here’s an example of how to integrate `go-test-coverage` in a GitHub workflow that uses a config file. This is the preferred way because the same config file can be used for running coverage checks locally.
77

@@ -27,7 +27,7 @@ Alternatively, if you don't need advanced configuration options from a config fi
2727
2828
Note: When using a config file alongside action properties, specifying these parameters will override the corresponding values in the config file.
2929
30-
# Action Outputs
30+
## Action Outputs
3131
3232
The GitHub Action will set the following outputs, which can be used later in your workflow:
3333
@@ -40,7 +40,22 @@ The GitHub Action will set the following outputs, which can be used later in you
4040

4141
Note: Action outputs and inputs are also documented in [action.yml](/action.yml) file.
4242

43-
# Post Coverage Report to PR
43+
## Liberal Coverage Check
44+
45+
The `go-test-coverage` GitHub Action can be configured to report the current test coverage without enforcing specific thresholds. To enable this functionality in your GitHub workflow, include the `continue-on-error: true` property in the job step configuration. This ensures that the workflow proceeds even if the coverage check fails.
46+
47+
Below is an example that reports files with coverage below 80% without causing the workflow to fail:
48+
```yml
49+
- name: check test coverage
50+
id: coverage
51+
uses: vladopajic/go-test-coverage@v2
52+
continue-on-error: true
53+
with:
54+
profile: cover.out
55+
threshold-file: 80
56+
```
57+
58+
## Post Coverage Report to PR
4459

4560
Here is an example of how to post comments with the coverage report to your pull request. The same logic is used in workflow in [this repo](/.github/workflows/test.yml).
4661

@@ -50,7 +65,7 @@ Here is an example of how to post comments with the coverage report to your pull
5065
uses: vladopajic/go-test-coverage@v2
5166
continue-on-error: true # Should fail after coverage comment is posted
5267
with:
53-
config: ./.github/.testcoverage.yml
68+
config: ./.github/.testcoverage.yml
5469
5570
# Post coverage report as comment (in 3 steps)
5671
- name: find pull request ID
@@ -69,25 +84,29 @@ Here is an example of how to post comments with the coverage report to your pull
6984
uses: peter-evans/find-comment@v3
7085
id: fc
7186
with:
72-
issue-number: ${{ env.pull_request_id }}
73-
comment-author: 'github-actions[bot]'
74-
body-includes: 'go-test-coverage report:'
87+
issue-number: ${{ env.pull_request_id }}
88+
comment-author: 'github-actions[bot]'
89+
body-includes: 'go-test-coverage report:'
7590
- name: post coverage report
7691
if: env.pull_request_id
7792
uses: peter-evans/create-or-update-comment@v4
7893
with:
79-
token: ${{ secrets.GITHUB_TOKEN }}
80-
issue-number: ${{ env.pull_request_id }}
81-
comment-id: ${{ steps.fc.outputs.comment-id }}
82-
body: |
94+
token: ${{ secrets.GITHUB_TOKEN }}
95+
issue-number: ${{ env.pull_request_id }}
96+
comment-id: ${{ steps.fc.outputs.comment-id }}
97+
body: |
8398
go-test-coverage report:
8499
```
85100
${{ fromJSON(steps.coverage.outputs.report) }}
86101
```
87-
edit-mode: replace
102+
edit-mode: replace
88103

89104
- name: "finally check coverage"
90105
if: steps.coverage.outcome == 'failure'
91106
shell: bash
92107
run: echo "coverage check failed" && exit 1
93-
```
108+
```
109+
110+
## Generate Coverage Badge
111+
112+
Instructions for badge creation are available [here](./badge.md).

0 commit comments

Comments
 (0)