-
Notifications
You must be signed in to change notification settings - Fork 267
489 lines (446 loc) · 14.2 KB
/
cicd.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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
---
name: CICD
on:
push:
branches:
- main
- docs-publish
tags:
- "v*"
pull_request:
workflow_dispatch:
env:
GO_VER: "1.20.2"
CGO_ENABLED: 0
MKDOCS_INS_VER: 9.5.9-insiders-4.52.2-hellt
GORELEASER_VER: v1.11.4
PY_VER: "3.10"
jobs:
file-changes:
runs-on: ubuntu-22.04
outputs:
code: ${{ steps.filter.outputs.code }}
docs: ${{ steps.filter.outputs.docs }}
# exporting env vars to be used in invoked workflows
py_ver: ${{ env.PY_VER }}
go_ver: ${{ env.GO_VER }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code:
- 'clab/**'
- 'runtime/**'
- 'cmd/**'
- 'tests/**'
- 'nodes/**'
- 'links/**'
- 'types/**'
- 'utils/**'
- 'netconf/**'
- 'labels/**'
- 'internal/**'
- 'errors/**'
- 'cert/**'
- 'virt/**'
- 'git/**'
- 'border0_api/**'
- '.github/workflows/cicd.yml'
- 'go.mod'
- 'Makefile'
docs:
- "docs/**"
- "lab-examples/**"
- "mkdocs.yml"
- "README.md"
- '.github/workflows/cicd.yml'
build-containerlab:
needs: file-changes
if: needs.file-changes.outputs.code == 'true' || startsWith(github.ref, 'refs/tags/v')
uses: ./.github/workflows/build-containerlab.yml
with:
go_ver: ${{ needs.file-changes.outputs.go_ver }}
staticcheck:
runs-on: ubuntu-22.04
needs: file-changes
if: needs.file-changes.outputs.code == 'true' || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- uses: WillAbides/[email protected]
with:
go-version: ${{ env.GO_VER }}
- name: Cache go modules
uses: actions/cache@v4
with:
# In order:
# * Module download cache
# * Build cache (Linux)
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Staticcheck
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck ./...
unit-test:
runs-on: ubuntu-22.04
needs: file-changes
if: needs.file-changes.outputs.code == 'true' || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- uses: WillAbides/[email protected]
with:
go-version: ${{ env.GO_VER }}
- name: Cache go modules
uses: actions/cache@v4
with:
# In order:
# * Module download cache
# * Build cache (Linux)
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: make test
# upload coverage report from unit tests, as they are then
# merged with e2e tests coverage
- name: Upload coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-unit-test
path: /tmp/clab-tests/coverage/*
retention-days: 7
smoke-tests:
uses: ./.github/workflows/smoke-tests.yml
with:
py_ver: ${{ needs.file-changes.outputs.py_ver }}
needs:
- file-changes
- build-containerlab
ext-container-tests:
runs-on: ubuntu-22.04
strategy:
matrix:
runtime:
- "docker"
needs:
- build-containerlab
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: containerlab
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_VER }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
- name: Install robotframework
run: |
pip install -r tests/requirements.txt
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: |
bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/06-ext-container
# upload test reports as a zip file
- name: Upload test reports
uses: actions/upload-artifact@v4
if: always()
with:
name: 06-ext-container-log-${{ matrix.runtime }}
path: ./tests/out/*.html
# upload coverage report from unit tests, as they are then
# merged with e2e tests coverage
- name: upload coverage reports
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-ext-container-test-${{ matrix.runtime }}
path: /tmp/clab-tests/coverage/*
retention-days: 7
ceos-basic-tests:
runs-on: ubuntu-22.04
strategy:
matrix:
runtime:
- "docker"
needs:
- build-containerlab
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: containerlab
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_VER }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
- name: Install robotframework
run: |
pip install -r tests/requirements.txt
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull ceos image
run: docker pull ghcr.io/srl-labs/ceos:4.28.0F && docker tag ghcr.io/srl-labs/ceos:4.28.0F ceos:4.28.0F
- name: Run ceos tests
run: |
bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/03-basic-ceos
# upload test reports as a zip file
- uses: actions/upload-artifact@v4
if: always()
with:
name: 03-basic-ceos-log-${{ matrix.runtime }}
path: ./tests/out/*.html
# upload coverage report from unit tests, as they are then
# merged with e2e tests coverage
- name: Upload coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-ceos-tests-${{ matrix.runtime }}
path: /tmp/clab-tests/coverage/*
retention-days: 7
srlinux-basic-tests:
uses: ./.github/workflows/srlinux-tests.yml
with:
py_ver: ${{ needs.file-changes.outputs.py_ver }}
needs:
- file-changes
- build-containerlab
ixiac-one-basic-tests:
runs-on: ubuntu-22.04
strategy:
matrix:
runtime:
- "docker"
needs:
- build-containerlab
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: containerlab
- name: Move containerlab to usr/bin
run: sudo mv ./containerlab /usr/bin/containerlab && sudo chmod a+x /usr/bin/containerlab
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_VER }}
cache: pip
cache-dependency-path: "tests/requirements.txt"
- name: Install robotframework
run: |
pip install -r tests/requirements.txt
- name: Run keysight_ixia-c-one tests
run: |
bash ./tests/rf-run.sh ${{ matrix.runtime }} ./tests/04-basic-ixiacone
# upload test reports as a zip file
- uses: actions/upload-artifact@v4
if: always()
with:
name: 04-basic-ixiacone-log-${{ matrix.runtime }}
path: ./tests/out/*.html
# upload coverage report from unit tests, as they are then
# merged with e2e tests coverage
- name: Upload coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-ixiac-one-tests-${{ matrix.runtime }}
path: /tmp/clab-tests/coverage/*
retention-days: 7
vxlan-tests:
uses: ./.github/workflows/vxlan-tests.yml
needs:
- file-changes
- build-containerlab
with:
py_ver: ${{ needs.file-changes.outputs.py_ver }}
kind-tests:
uses: ./.github/workflows/kind-tests.yml
needs:
- file-changes
- build-containerlab
with:
py_ver: ${{ needs.file-changes.outputs.py_ver }}
sros-tests:
uses: ./.github/workflows/sros-tests.yml
needs:
- file-changes
- build-containerlab
with:
py_ver: ${{ needs.file-changes.outputs.py_ver }}
# a job that downloads coverage artifact and uses codecov to upload it
coverage:
runs-on: ubuntu-22.04
needs:
- unit-test
- smoke-tests
- ext-container-tests
- ceos-basic-tests
- srlinux-basic-tests
- ixiac-one-basic-tests
- vxlan-tests
- kind-tests
- sros-tests
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: WillAbides/[email protected]
with:
go-version: ${{ env.GO_VER }}
- uses: actions/download-artifact@v4
with:
pattern: coverage*
path: /tmp/clab-tests/coverage
merge-multiple: true
- run: ls -R /tmp/clab-tests/coverage
- name: Convert Go's binary coverage to text coverage
run: make convert-coverage
- name: Upload coverage to codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
docs-test:
runs-on: ubuntu-22.04
needs: file-changes
if: needs.file-changes.outputs.docs == 'true' || startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/docs-publish'
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: docker run -v $(pwd):/docs --user $(id -u):$(id -g) --entrypoint mkdocs ghcr.io/srl-labs/mkdocs-material-insiders:$MKDOCS_INS_VER build --clean --strict
- name: Cache htmltest external links
uses: actions/cache@v4
with:
path: tmp/.htmltest
# key will contain hash of all md files to check if files have changed
# when files are changed, a new key name is formed, and thus a new cache will be saved
key: htmltest-${{ hashFiles('docs/**/*.md') }}
# the restore key will fetch any previously saved cache even if there is no match on key
# this allows to use cache from prev runs and update it
restore-keys: |
htmltest-
- name: htmltest
uses: wjdp/htmltest-action@master
with:
config: docs/htmltest.yml
build-and-release:
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/v')
needs:
- docs-test
- unit-test
- smoke-tests
- ceos-basic-tests
- srlinux-basic-tests
- ixiac-one-basic-tests
- ext-container-tests
- vxlan-tests
- kind-tests
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: WillAbides/[email protected]
with:
go-version: ${{ env.GO_VER }}
- name: Cache go modules
uses: actions/cache@v4
with:
# In order:
# * Module download cache
# * Build cache (Linux)
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: ${{ env.GORELEASER_VER }}
args: release --rm-dist --debug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FURY_TOKEN: ${{ secrets.FURYPUSHTOKEN }}
publish-docs:
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-') != true
needs: build-and-release
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: docker run -v $(pwd):/docs --user $(id -u):$(id -g) --entrypoint mkdocs ghcr.io/srl-labs/mkdocs-material-insiders:$MKDOCS_INS_VER gh-deploy --force --strict
# update docs allows to make the docs changes outside of the release cycle
# it skips the code build/release and proceeds with docs publishing
# the intended usage is to provide fixes/updates to docs, which do not require code changes
update-docs:
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/docs-publish'
needs: docs-test
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: docker run -v $(pwd):/docs --user $(id -u):$(id -g) --entrypoint mkdocs ghcr.io/srl-labs/mkdocs-material-insiders:$MKDOCS_INS_VER gh-deploy --force --strict