File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 11name : CI
22
3- on : [pull_request, workflow_dispatch]
3+ on :
4+ pull_request :
5+ workflow_dispatch :
6+ push :
7+ branches :
8+ - main
9+
10+ env :
11+ CODE_COVERAGE_FILE_NAME : " coverage.out" # must be the same as in Makefile
12+ CODE_COVERAGE_ARTIFACT_NAME : " code-coverage"
413
514jobs :
615 main :
2635 - name : Test
2736 run : make test
2837
38+ - name : Archive code coverage results
39+ uses : actions/upload-artifact@v4
40+ with :
41+ name : ${{ env.CODE_COVERAGE_ARTIFACT_NAME }}
42+ path : ${{ env.CODE_COVERAGE_FILE_NAME }}
43+
2944 config :
3045 name : Check GoReleaser config
46+ if : github.event_name == 'pull_request'
3147 runs-on : ubuntu-latest
3248 steps :
3349 - name : Checkout
3652 - name : Check GoReleaser
3753 uses : goreleaser/goreleaser-action@v6
3854 with :
39- args : check
55+ args : check
56+
57+ code_coverage :
58+ name : " Code coverage report"
59+ if : github.event_name == 'pull_request' # Do not run when workflow is triggered by push to main branch
60+ runs-on : ubuntu-latest
61+ needs : main
62+ permissions :
63+ contents : read
64+ actions : read # to download code coverage results from "main" job
65+ pull-requests : write # write permission needed to comment on PR
66+ steps :
67+ - uses : fgrosse/go-coverage-report@v1.1.1
68+ with :
69+ coverage-artifact-name : ${{ env.CODE_COVERAGE_ARTIFACT_NAME }}
70+ coverage-file-name : ${{ env.CODE_COVERAGE_FILE_NAME }}
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ lint: lint-golangci-lint lint-yamllint
2525# Test
2626test :
2727 @echo " >> Running tests for the CLI application"
28- @go test ./... -count=1
28+ @go test ./... -count=1 -coverprofile=coverage.out
2929
3030# Test coverage
3131coverage :
You can’t perform that action at this time.
0 commit comments