-
Notifications
You must be signed in to change notification settings - Fork 103
166 lines (159 loc) · 5.1 KB
/
tests.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
159
160
161
162
163
164
165
166
name: Tests
# **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
- release/v*
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: ["app", "types", "x/data", "x/ecocredit", "x/intertx"]
steps:
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
**/**.go
**/go.mod
**/go.sum
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- run: make test-app
if: |
(env.GIT_DIFF && matrix.module == 'app') ||
github.ref == 'refs/heads/main'
- run: make test-types
if: |
(env.GIT_DIFF && matrix.module == 'types') ||
github.ref == 'refs/heads/main'
- run: make test-x-data
if: |
(env.GIT_DIFF && matrix.module == 'x/data') ||
github.ref == 'refs/heads/main'
- run: make test-x-ecocredit
if: |
(env.GIT_DIFF && matrix.module == 'x/ecocredit') ||
github.ref == 'refs/heads/main'
- run: make test-x-intertx
if: |
(env.GIT_DIFF && matrix.module == 'x/intertx') ||
github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v3
with:
name: coverage-app
path: coverage-app.out
if: |
(env.GIT_DIFF && matrix.module == 'app') ||
github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v3
with:
name: coverage-types
path: coverage-types.out
if: |
(env.GIT_DIFF && matrix.module == 'types') ||
github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v3
with:
name: coverage-x-data
path: coverage-x-data.out
if: |
(env.GIT_DIFF && matrix.module == 'x/data') ||
github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v3
with:
name: coverage-x-ecocredit
path: coverage-x-ecocredit.out
if: |
(env.GIT_DIFF && matrix.module == 'x/ecocredit') ||
github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v3
with:
name: coverage-x-intertx
path: coverage-x-intertx.out
if: |
(env.GIT_DIFF && matrix.module == 'x/intertx') ||
github.ref == 'refs/heads/main'
integration:
runs-on: ubuntu-latest
permissions:
pull-requests: read # for technote-space/get-diff-action to get git reference
steps:
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
**/**.go
**/go.mod
**/go.sum
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- run: make test-integration
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: actions/upload-artifact@v3
with:
name: coverage-integration
path: coverage-integration.out
if: env.GIT_DIFF || 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, integration]
steps:
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
**/**.go
**/go.mod
**/go.sum
- uses: actions/download-artifact@v3
with:
name: coverage-app
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: actions/download-artifact@v3
with:
name: coverage-types
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: actions/download-artifact@v3
with:
name: coverage-x-data
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: actions/download-artifact@v3
with:
name: coverage-x-ecocredit
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: actions/download-artifact@v3
with:
name: coverage-x-intertx
if: env.GIT_DIFF || github.ref == 'refs/heads/main'
- uses: actions/download-artifact@v3
with:
name: coverage-integration
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'