You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/github_action.md
+32-13Lines changed: 32 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# go-test-coverage GitHub Action
2
2
3
3
4
-
# Usage
4
+
##Usage
5
5
6
6
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.
7
7
@@ -27,7 +27,7 @@ Alternatively, if you don't need advanced configuration options from a config fi
27
27
28
28
Note: When using a config file alongside action properties, specifying these parameters will override the corresponding values in the config file.
29
29
30
-
# Action Outputs
30
+
## Action Outputs
31
31
32
32
The GitHub Action will set the following outputs, which can be used later in your workflow:
33
33
@@ -40,7 +40,22 @@ The GitHub Action will set the following outputs, which can be used later in you
40
40
41
41
Note: Action outputs and inputs are also documented in [action.yml](/action.yml) file.
42
42
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
44
59
45
60
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).
46
61
@@ -50,7 +65,7 @@ Here is an example of how to post comments with the coverage report to your pull
50
65
uses: vladopajic/go-test-coverage@v2
51
66
continue-on-error: true # Should fail after coverage comment is posted
52
67
with:
53
-
config: ./.github/.testcoverage.yml
68
+
config: ./.github/.testcoverage.yml
54
69
55
70
# Post coverage report as comment (in 3 steps)
56
71
- 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
69
84
uses: peter-evans/find-comment@v3
70
85
id: fc
71
86
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:'
75
90
- name: post coverage report
76
91
if: env.pull_request_id
77
92
uses: peter-evans/create-or-update-comment@v4
78
93
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: |
83
98
go-test-coverage report:
84
99
```
85
100
${{ fromJSON(steps.coverage.outputs.report) }}
86
101
```
87
-
edit-mode: replace
102
+
edit-mode: replace
88
103
89
104
- name: "finally check coverage"
90
105
if: steps.coverage.outcome == 'failure'
91
106
shell: bash
92
107
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