-
Notifications
You must be signed in to change notification settings - Fork 2
273 lines (235 loc) · 6.73 KB
/
Copy pathtest.yaml
File metadata and controls
273 lines (235 loc) · 6.73 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# SPDX-FileCopyrightText: 2024 Tobias Böhm <code@aibor.de>
#
# SPDX-License-Identifier: GPL-3.0-or-later
name: Test
on:
push:
branches:
- "main"
- "dev/*"
pull_request:
branches:
- "main"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
go-setup:
name: Go setup
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Go mod tidy
run: go mod tidy && git diff --exit-code
- name: Go mod verify
run: go mod verify
go-vuln-check:
name: Go vulnerability check
runs-on: ubuntu-latest
needs:
- go-setup
steps:
- name: Go vulnerability check
uses: golang/govulncheck-action@v1
with:
go-version-file: go.mod
go-package: -test ./...
go-gen-check:
name: Go generate check
runs-on: ubuntu-latest
needs:
- go-setup
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Go generate
run: go generate ./... && git diff --exit-code
go-lint:
name: Go lint
runs-on: ubuntu-latest
needs:
- go-setup
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Run vet with all constraints
run: go vet -tags integration,integration_sysinit ./...
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: "v2.12"
args: "--build-tags integration,integration_sysinit ./..."
reuse-lint:
name: FSFE REUSE Compliance Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v6
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
goreleaser-lint:
name: Goreleaser check
runs-on: ubuntu-latest
needs:
- go-setup
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
version: latest
args: check
integration-tests:
name: Run integration tests
runs-on: ubuntu-latest
container:
image: ghcr.io/aibor/virtrun-test:${{ matrix.arch }}
strategy:
matrix:
arch:
- amd64
- arm64
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Run go generate testdata
run: go generate -tags testdata ./internal/sys/gen_test.go
- name: Run go generate integration tests
env:
GOARCH: ${{ matrix.arch }}
run: go generate -tags integration ./internal/cmd/run_integration_test.go
- name: Run tests
env:
SKIP: ${{ matrix.arch != 'amd64' && 'TestIntegration/linked' || '' }}
VIRTRUN_ARGS: "-kernel /kernel/vmlinuz-virt \
-transport pci \
-memory 128 \
-verbose \
-debug"
run: |
go test -v \
-tags integration \
-skip "${{ env.SKIP }}" \
-race \
-covermode atomic \
-coverprofile coverage.txt \
-coverpkg $(go list ./internal/... | tr '\n' ,) \
./internal/... \
| go-junit-report -set-exit-code -iocopy -out junit-report.xml
- name: Run go-cobertura
run: gocover-cobertura -by-files < coverage.txt > coverage.xml
- name: Upload test output
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results-integration-${{ matrix.arch }}
path: junit-report.xml
retention-days: 2
- name: Upload coverage data
uses: actions/upload-artifact@v7
if: ${{ matrix.arch == 'amd64' }}
with:
name: go-coverage
path: coverage*
integration-tests-sysinit:
name: Run integration tests of sysinit package and binaries
runs-on: ubuntu-latest
container:
image: ghcr.io/aibor/virtrun-test:${{ matrix.arch }}
strategy:
matrix:
arch:
- amd64
- arm64
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Build virtrun
run: go build -buildvcs=false -o /virtrun .
- name: Run sysinit test
env:
GOARCH: "${{ matrix.arch }}"
RACE: ${{ matrix.arch == 'amd64' && '-race' || '' }}
VIRTRUN_ARGS: "-kernel /kernel/vmlinuz-virt \
-addModule /kernel/tun.ko.gz \
-addModule /kernel/veth.ko.gz \
-transport pci \
-standalone \
-verbose \
-debug"
run: |
go test -v \
-tags integration_sysinit \
-exec /virtrun \
${{ env.RACE }} \
-covermode atomic \
-coverprofile coverage.txt \
-coverpkg ./sysinit \
./sysinit \
./internal/pidone/cmd \
-testModules tun,veth \
| go-junit-report -set-exit-code -iocopy -out junit-report-sysinit.xml
- name: Run go-cobertura
run: gocover-cobertura -by-files < coverage.txt > coverage.xml
- name: Upload test output
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results-integration-sysinit-${{ matrix.arch }}
path: junit-report*.xml
retention-days: 2
- name: Upload coverage data
uses: actions/upload-artifact@v7
if: ${{ matrix.arch == 'amd64' }}
with:
name: go-coverage-sysinit
path: coverage*
results:
if: always()
runs-on: ubuntu-latest
name: Test Results
needs:
- go-vuln-check
- go-gen-check
- go-lint
- integration-tests
- integration-tests-sysinit
- reuse-lint
- goreleaser-lint
steps:
- run: exit 1
if: |
contains(needs.*.result, 'failure') ||
contains(needs.*.result, 'cancelled')