-
Notifications
You must be signed in to change notification settings - Fork 373
431 lines (363 loc) · 12.5 KB
/
go.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
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
name: Go build
on:
push:
branches:
- main
- release-*
paths-ignore:
- 'docs/**'
- 'examples/**'
- '**.md'
- LICENSE
- '**.svg'
- '.github/workflows/docs.yml'
- '.github/workflows/mkdocs-set-default-version.yml'
- 'mkdocs.yml'
pull_request:
branches:
- main
- release-*
paths-ignore:
- 'docs/**'
- 'examples/**'
- '**.md'
- LICENSE
- '**.svg'
- '.github/workflows/docs.yml'
- '.github/workflows/mkdocs-set-default-version.yml'
- 'mkdocs.yml'
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
smoketest-matrix: ${{ steps.generate-smoketest-matrix.outputs.smoketests }}
autopilot-matrix: ${{ steps.generate-autopilot-matrix.outputs.matrix }}
steps:
- name: "Workflow run :: Checkout"
uses: actions/checkout@v3
with:
persist-credentials: false
- name: "Generate :: Smoke test matrix"
id: generate-smoketest-matrix
run: |
./vars.sh FROM=inttest smoketests | jq --raw-input --raw-output \
'split(" ") | [ .[] | select(. != "") ] | "smoketests=" + tojson' >>$GITHUB_OUTPUT
- name: "Generate :: Autopilot test matrix"
id: generate-autopilot-matrix
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
k8sVersion="$(./vars.sh kubernetes_version)"
majorVersion="${k8sVersion%%.*}"
minorVersion=${k8sVersion#$majorVersion.}
minorVersion="${minorVersion%%.*}"
{
printf matrix=
hack/tools/gen-matrix.sh "$majorVersion.$(($minorVersion - 1))" "$majorVersion.$minorVersion"
} >> "$GITHUB_OUTPUT"
build-k0s:
strategy:
matrix:
target-os: [linux, windows]
target-arch: [amd64]
name: "Build :: k0s :: ${{ matrix.target-os }}-${{ matrix.target-arch }}"
uses: ./.github/workflows/build-k0s.yml
with:
target-os: ${{ matrix.target-os }}
target-arch: ${{ matrix.target-arch }}
build-airgap-image-bundle:
name: "Build :: Airgap image bundle"
needs: [build-k0s]
uses: ./.github/workflows/build-airgap-image-bundle.yml
with:
target-os: linux
target-arch: amd64
unittests-k0s-linux-amd64:
name: "Unit tests :: linux-amd64"
runs-on: ubuntu-22.04
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Cache GOCACHE
uses: actions/cache@v3
with:
key: unittests-k0s-linux-amd64-gocache-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
unittests-k0s-linux-amd64-gocache-${{ github.ref_name }}-
build-k0s-linux-amd64-gocache-${{ github.ref_name }}-
path: |
build/cache/go/build
- name: Cache GOMODCACHE
uses: actions/cache@v3
with:
key: unittests-k0s-linux-amd64-gomodcache-${{ hashFiles('go.sum') }}
restore-keys: |
build-k0s-linux-amd64-gomodcache-${{ hashFiles('go.sum') }}
path: |
build/cache/go/mod
- name: Run unit tests
env:
EMBEDDED_BINS_BUILDMODE: none
run: |
make bindata
make --touch codegen
make check-unit
- name: Validate OCI images manifests
run: make check-image-validity
unittests-k0s-windows-amd64:
name: "Unit tests :: windows-amd64"
runs-on: windows-2022
defaults:
run:
shell: bash
steps:
- name: Check out
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Prepare build environment
run: .github/workflows/prepare-build-env.sh
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache GOCACHE
uses: actions/cache@v3
with:
key: unittests-k0s-windows-amd64-gocache-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
unittests-k0s-windows-amd64-gocache-${{ github.ref_name }}-
path: |
~\AppData\Local\go-build
- name: Cache GOMODCACHE
uses: actions/cache@v3
with:
key: unittests-k0s-windows-amd64-gomodcache-${{ hashFiles('go.sum') }}
restore-keys: |
build-k0s-windows-amd64-gomodcache-${{ hashFiles('go.sum') }}
path: |
~\go\pkg\mod
- name: Run unit tests
env:
EMBEDDED_BINS_BUILDMODE: none
TARGET_OS: windows
GO: go
GO_ENV: ''
run: |
make --touch .k0sbuild.docker-image.k0s go.sum
make bindata
make --touch codegen
make check-unit
smoketests:
strategy:
fail-fast: false
matrix:
smoke-suite: ${{ fromJson(needs.prepare.outputs.smoketest-matrix) }}
name: "Smoke tests :: ${{ matrix.smoke-suite }}"
needs: [prepare, build-k0s, build-airgap-image-bundle]
runs-on: ubuntu-22.04
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Prepare build environment
run: .github/workflows/prepare-build-env.sh
- name: Prepare docker for ipv6 dualstack tests
if: contains(matrix.smoke-suite, 'dualstack')
run: .github/workflows/prepare-docker-ipv6.sh
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Download compiled executable
uses: actions/download-artifact@v3
with:
name: k0s-linux-amd64
- name: k0s sysinfo
run: |
chmod +x k0s
./k0s sysinfo
- name: Cache airgap image bundle
id: cache-airgap-image-bundle
if: contains(matrix.smoke-suite, 'airgap')
uses: actions/cache@v3
with:
key: ${{ needs.build-airgap-image-bundle.outputs.cache-key }}
path: airgap-image-bundle-linux-amd64.tar
- name: Run inttest
env:
NEEDS_AIRGAP_IMAGE_BUNDLE: ${{ contains(matrix.smoke-suite, 'airgap') }}
run: |
[ "$NEEDS_AIRGAP_IMAGE_BUNDLE" != true ] || [ -f airgap-image-bundle-linux-amd64.tar ] || {
echo Airgap image bundle file missing!
exit 1
}
make -C inttest ${{ matrix.smoke-suite }}
- name: Collect k0s logs and support bundle
if: failure()
uses: actions/upload-artifact@v3
with:
name: smoketests-${{ matrix.smoke-suite }}-files
path: |
/tmp/*.log
/tmp/support-bundle.tar.gz
- name: Collect sonobuoy results
if: failure() && contains(matrix.smoke-suite, 'conformance')
uses: actions/upload-artifact@v3
with:
name: smoketests-${{ matrix.smoke-suite }}-sonobuoy-results
path: /tmp/*_sonobuoy_*.tar.gz
autopilot-tests:
strategy:
fail-fast: false
matrix:
version: ${{fromJson(needs.prepare.outputs.autopilot-matrix)}}
name: "Autopilot tests :: ${{ matrix.version }}"
needs: [prepare, build-k0s]
runs-on: ubuntu-22.04
env:
K0S_VERSION: ${{ matrix.version }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Prepare build environment
run: .github/workflows/prepare-build-env.sh
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Download compiled executable
uses: actions/download-artifact@v3
with:
name: k0s-linux-amd64
- name: Download latest release
run: |
curl -L -o "k0s-$K0S_VERSION" "https://github.com/k0sproject/k0s/releases/download/$K0S_VERSION/k0s-$K0S_VERSION-amd64"
chmod +x "k0s-$K0S_VERSION"
- name: k0s sysinfo
run: |
chmod +x k0s
./k0s sysinfo
- name: Run inttest
run: |
make -C inttest check-ap-ha3x3 K0S_UPDATE_FROM_BIN="../k0s-$K0S_VERSION"
- name: Collect k0s logs and support bundle
if: failure()
uses: actions/upload-artifact@v3
with:
name: autopilot-tests-${{ matrix.version }}-files
path: |
/tmp/*.log
/tmp/support-bundle.tar.gz
smoketest-arm:
name: Smoke test on armv7/arm64
if: github.repository == 'k0sproject/k0s'
strategy:
fail-fast: false
matrix:
arch:
- arm # this is armv7
- arm64
runs-on:
- self-hosted
- linux
- ${{ matrix.arch }}
steps:
# https://github.com/actions/checkout/issues/273#issuecomment-642908752 (see below)
- name: "Pre: Fixup directories"
run: find . -type d -not -perm /u+w -exec chmod u+w '{}' \;
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
fetch-depth: 0 # for `git describe`
persist-credentials: false
- name: Prepare build environment
run: .github/workflows/prepare-build-env.sh
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Cache embedded binaries
uses: actions/cache@v3
with:
key: ${{ runner.os }}-embedded-bins-${{ matrix.arch }}-${{ hashFiles('**/embedded-bins/**/*') }}
path: |
.bins.linux.stamp
bindata_linux
embedded-bins/staging/linux/bin/
embedded-bins/Makefile.variables
pkg/assets/zz_generated_offsets_linux.go
- name: Cache GOCACHE
uses: actions/cache@v3
with:
key: ${{ runner.os }}-smoketest-arm-gocache-${{ matrix.arch }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-smoketest-arm-gocache-${{ matrix.arch }}-${{ github.ref_name }}-
path: |
build/cache/go/build
- name: Cache GOMODCACHE
uses: actions/cache@v3
with:
key: ${{ runner.os }}-smoketest-arm-gomodcache-${{ matrix.arch }}-${{ hashFiles('go.sum') }}
path: |
build/cache/go/mod
- name: Disable race checker
if: matrix.arch == 'arm'
run: echo GO_TEST_RACE= >>"$GITHUB_ENV"
- name: Build
run: |
make bindata
make --touch codegen
make build
- name: Upload compiled executable
uses: actions/upload-artifact@v3
with:
name: k0s-${{ matrix.arch }}
path: k0s
- name: Unit tests
run: make check-unit
- name: k0s sysinfo
run: ./k0s sysinfo
- name: Run smoketest
run: make check-basic
- name: Create airgap image list
run: make airgap-images.txt
- name: Cache airgap image bundle
id: cache-airgap-image-bundle
uses: actions/cache@v3
with:
key: airgap-image-bundle-linux-${{ matrix.arch }}-${{ hashFiles('Makefile', 'airgap-images.txt', 'hack/image-bundler/*') }}
path: |
airgap-images.txt
airgap-image-bundle-linux-${{ matrix.arch }}.tar
- name: Create airgap image bundle if not cached
if: steps.cache-airgap-image-bundle.outputs.cache-hit != 'true'
run: make airgap-image-bundle-linux-${{ matrix.arch }}.tar
- name: Run airgap test
run: |
make --touch airgap-image-bundle-linux-${{ matrix.arch }}.tar
make check-airgap
- name: Collect k0s logs and support bundle
if: failure()
uses: actions/upload-artifact@v3
with:
name: smoketest-${{ matrix.arch }}-check-basic-files
path: |
/tmp/*.log
/tmp/support-bundle.tar.gz
# https://github.com/actions/checkout/issues/273#issuecomment-642908752
# Golang mod cache tends to set directories to read-only, which breaks any
# attempts to simply remove those directories. The `make clean-gocache`
# target takes care of this, but the mod cache can't be deleted here,
# since it shall be cached across builds, and caching takes place as a
# post build action. So, as a workaround, ensure that all subdirectories
# are writable.
- name: "Post: Fixup directories"
if: always()
run: find . -type d -not -perm /u+w -exec chmod u+w '{}' \;
- name: "Docker prune"
if: always()
run: docker system prune --force --filter "until=$((24*7))h"