-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (71 loc) · 2.2 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: CI
on:
pull_request:
push:
branches:
- 'main'
jobs:
unit_tests:
name: "Unit tests"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ^1.22
- name: Test
run: go test -v -cover -coverprofile=coverage.txt -covermode=count -mod=readonly ./...
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: coverage.txt
code_coverage:
name: "Code coverage report"
runs-on: ubuntu-latest
needs: unit_tests
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
steps:
- name: Install go-coverage-report
run: |
go env
go install github.com/fgrosse/[email protected]
ls -l $HOME/go/bin
ls -l $GOPATH/bin
- name: Determine changed files
id: changed-files
uses: tj-actions/changed-files@v42
with:
write_output_files: true
json: true
files: |
**.go
files_ignore: |
**_test.go
vendor/**
- name: Verify the contents of the .github/outputs/added_files.txt file
run: |
cat .github/outputs/all_changed_files.json
- name: Download code coverage results from target branch # TODO: download from latest successful run on the target branch instead of main branch
run: |
gh run download --name=code-coverage
mv coverage.txt old-coverage.txt
- name: Download code coverage results
uses: actions/download-artifact@v4
with:
name: code-coverage
path: new-coverage.txt
- name: Compare code coverage results
run: |
go-coverage-report \
-prefix=github.com/fgrosse/prioqueue \
old-coverage.txt \
new-coverage.txt \
.github/outputs/all_changed_files.json \
> coverage-comment.md
- name: Comment on pull request
run: gh pr comment ${{ github.event.number }} --body-file=coverage-comment.md