-
Notifications
You must be signed in to change notification settings - Fork 2
158 lines (152 loc) · 4.85 KB
/
test.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Test
# **What it does**: Runs unit and integration tests when go files
# have been modified and provides code coverage reports.
#
# **Why we have it**: Ensures the application is production ready.
#
# **What does it impact**: Application stability.
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
unit:
runs-on: ubuntu-latest
permissions:
pull-requests: read # for technote-space/get-diff-action to get git reference
strategy:
matrix:
module: ["admin", "agent", "content", "governor", "validator", "voucher"]
steps:
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
**/**.go
**/go.mod
**/go.sum
- uses: actions/setup-go@v5
with:
go-version: '1.22'
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- run: make test-admin
if: |
(env.GIT_DIFF && matrix.module == 'admin') ||
github.ref == 'refs/heads/main'
- run: make test-agent
if: |
(env.GIT_DIFF && matrix.module == 'agent') ||
github.ref == 'refs/heads/main'
- run: make test-content
if: |
(env.GIT_DIFF && matrix.module == 'content') ||
github.ref == 'refs/heads/main'
- run: make test-governor
if: |
(env.GIT_DIFF && matrix.module == 'governor') ||
github.ref == 'refs/heads/main'
- run: make test-validator
if: |
(env.GIT_DIFF && matrix.module == 'validator') ||
github.ref == 'refs/heads/main'
- run: make test-voucher
if: |
(env.GIT_DIFF && matrix.module == 'voucher') ||
github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v4
with:
name: coverage-admin
path: coverage-admin.out
overwrite: true
if: |
(env.GIT_DIFF && matrix.module == 'admin') ||
github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v4
with:
name: coverage-agent
path: coverage-agent.out
overwrite: true
if: |
(env.GIT_DIFF && matrix.module == 'agent') ||
github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v4
with:
name: coverage-content
path: coverage-content.out
overwrite: true
if: |
(env.GIT_DIFF && matrix.module == 'content') ||
github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v4
with:
name: coverage-governor
path: coverage-governor.out
overwrite: true
if: |
(env.GIT_DIFF && matrix.module == 'governor') ||
github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v4
with:
name: coverage-validator
path: coverage-validator.out
overwrite: true
if: |
(env.GIT_DIFF && matrix.module == 'validator') ||
github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v4
with:
name: coverage-voucher
path: coverage-voucher.out
overwrite: true
if: |
(env.GIT_DIFF && matrix.module == 'voucher') ||
github.ref == 'refs/heads/main'
coverage:
runs-on: ubuntu-latest
permissions:
pull-requests: read # for technote-space/get-diff-action to get git reference
needs: [unit]
steps:
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
**/**.go
**/go.mod
**/go.sum
- uses: actions/download-artifact@v4
with:
name: coverage-admin
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: actions/download-artifact@v4
with:
name: coverage-agent
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: actions/download-artifact@v4
with:
name: coverage-content
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: actions/download-artifact@v4
with:
name: coverage-governor
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: actions/download-artifact@v4
with:
name: coverage-validator
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: actions/download-artifact@v4
with:
name: coverage-voucher
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- run: make test-coverage
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: codecov/codecov-action@v3
with:
file: coverage.txt
if: env.GIT_DIFF || github.ref == 'refs/heads/main'