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 1
1
name : CI
2
2
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"
4
13
5
14
jobs :
6
15
main :
26
35
- name : Test
27
36
run : make test
28
37
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
+
29
44
config :
30
45
name : Check GoReleaser config
46
+ if : github.event_name == 'pull_request'
31
47
runs-on : ubuntu-latest
32
48
steps :
33
49
- name : Checkout
36
52
- name : Check GoReleaser
37
53
uses : goreleaser/goreleaser-action@v6
38
54
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
+
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
25
25
# Test
26
26
test :
27
27
@echo " >> Running tests for the CLI application"
28
- @go test ./... -count=1
28
+ @go test ./... -count=1 -coverprofile=coverage.out
29
29
30
30
# Test coverage
31
31
coverage :
You can’t perform that action at this time.
0 commit comments