Skip to content

Commit 8ab8224

Browse files
committed
add report comment
1 parent 3759743 commit 8ab8224

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

.github/workflows/build.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,26 @@ jobs:
2020
run: go mod tidy
2121
- name: Run tests with coverage
2222
run: go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...
23+
- name: Upload coverage
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: code-coverage
27+
path: cover.out # Make sure to use the same file name you chose for the "-coverprofile" in the "Test" step
2328
- name: Check coverage
2429
uses: vladopajic/go-test-coverage@v2
2530
with:
26-
config: ./.testcoverage.yml
31+
config: ./.testcoverage.yml
32+
code_coverage:
33+
name: "Code coverage report"
34+
if: github.event_name == 'pull_request' # Do not run when workflow is triggered by push to main branch
35+
runs-on: ubuntu-latest
36+
needs: test # Depends on the artifact uploaded by the "unit_tests" job
37+
permissions:
38+
contents: read
39+
actions: read # to download code coverage results from "test" job
40+
pull-requests: write # write permission needed to comment on PR
41+
steps:
42+
- uses: fgrosse/[email protected] # Consider using a Git revision for maximum security
43+
with:
44+
coverage-artifact-name: "code-coverage" # can be omitted if you used this default value
45+
coverage-file-name: "cover.out" # can be omitted if you used this default value

0 commit comments

Comments
 (0)