-
Notifications
You must be signed in to change notification settings - Fork 9
435 lines (391 loc) · 13.9 KB
/
dev.yml
File metadata and controls
435 lines (391 loc) · 13.9 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
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
# The primary point of this workflow is to ensure that the developer experience is good.
# We take a very vanilla ubuntu image, install all necessary dependencies via "normal" means,
# and then run the build and test steps as described in the README.md file.
# The artifacts produced by these builds are not intended to be used for anything other than
# ensuring that the developer experience is good.
# Production artifacts are produced via nix builds (in another CI workflow).
name: "dev.yml"
on:
pull_request: {}
push:
branches:
- "main"
tags:
- "v*"
merge_group:
types: ["checks_requested"]
workflow_dispatch:
inputs:
debug_enabled:
type: "boolean"
description: "Run with tmate enabled"
required: false
default: false
debug_justfile:
type: "boolean"
description: "enable to see debug statements from just recipes"
required: false
default: false
skip_vlab_tests:
type: "boolean"
description: "Skip VLAB tests (they run by default)"
required: false
default: false
run_hlab_tests:
type: "boolean"
description: "Run hybrid HLAB tests"
required: false
default: false
enable_release_tests:
type: "boolean"
description: "Enable release tests for VLAB/HLAB tests"
required: false
default: false
concurrency:
group: "${{ github.workflow }}:${{ github.event.pull_request.number || github.event.after || github.event.merge_group && github.run_id }}"
cancel-in-progress: true
permissions:
contents: "read"
packages: "write"
id-token: "write"
jobs:
check_changes:
name: "Deduce required tests from code changes"
permissions:
contents: "read"
pull-requests: "read"
runs-on: "ubuntu-latest"
outputs:
devfiles: "${{ steps.changes.outputs.devfiles }}"
steps:
- name: "Checkout"
if: "${{ !github.event.pull_request }}"
uses: "actions/checkout@v6"
with:
persist-credentials: "false"
fetch-depth: "0"
- name: "Check code changes"
uses: "dorny/paths-filter@v4"
id: "changes"
with:
filters: |
devfiles:
- '!(README.md|LICENSE|NOTICE|.zed/**|.vscode/**|CLAUDE.md|.rules|development/**|testing.md|workspace-deps.svg|codebook.toml|.markdownlint.json|.gitattributes|.gitignore|.github/**)'
- '.github/workflows/dev.yml'
version:
runs-on: lab
permissions:
contents: read
outputs:
version: "${{ steps.version-gen.outputs.version }}"
ref: "${{ steps.version-gen.outputs.ref }}"
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Generate temp artifacts version
id: version-gen
env:
commit_sha: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
echo "version=v0-${commit_sha::9}" >> "$GITHUB_OUTPUT"
echo "ref=${commit_sha}" >> "$GITHUB_OUTPUT"
build:
if: >-
${{
needs.check_changes.outputs.devfiles == 'true'
|| startsWith(github.event.ref, 'refs/tags/v')
|| github.event_name == 'workflow_dispatch'
}}
name: "${{matrix.nix-target}}/${{matrix.build.name}}"
continue-on-error: ${{ matrix.build.optional || false }}
runs-on: lab
needs:
- check_changes
- version
permissions:
checks: "write"
pull-requests: "write"
contents: "read"
packages: "write"
id-token: "write"
env:
USER: "runner"
strategy:
fail-fast: false
matrix:
nix-target:
- tests.all
- frr.dataplane
- dataplane
build:
- name: "debug"
profile: "debug"
sanitize: ""
instrument: "none"
- name: "release"
profile: "release"
sanitize: "" # TODO: enable cfi and safe-stack when possible
instrument: "none"
debug_justfile:
- "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_justfile || false }}"
steps:
- name: "login to ghcr.io"
uses: "docker/login-action@v4"
with:
registry: ghcr.io
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: "login to image cache"
run: |
echo "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USERNAME" --password-stdin "$REGISTRY_URL"
# it's temporarily needed to install skopeo
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: stable
cache: true
- name: "Checkout"
uses: "actions/checkout@v6"
with:
persist-credentials: "false"
fetch-depth: "0"
- name: "Install nix"
uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
nix_path: nixpkgs=channel:nixpkgs-unstable
- uses: "cachix/cachix-action@v17"
with:
name: "hedgehog"
# prettier-ignore
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
# prettier-ignore
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: "run pre-flight checks"
if: ${{ matrix.nix-target == 'tests.all' }}
run: |
nix-shell --run '
for features in "" "shuttle"; do
just \
docker_sock=/run/docker/docker.sock \
debug_justfile=${{matrix.debug_justfile}} \
profile="${{matrix.build.profile}}" \
sanitize="${{matrix.build.sanitize}}" \
instrument="${{matrix.build.instrument}}" \
features="${features}" \
oci_repo="ghcr.io" \
pre-flight
done
'
- name: "push container"
if: ${{ matrix.nix-target != 'tests.all' }}
run: |
nix-shell --run "just \
debug_justfile=${{matrix.debug_justfile}} \
check-dependencies"
for v in "" "version=${{ needs.version.outputs.version }}-${{ matrix.build.profile }}"; do
nix-shell --run "
just \
docker_sock=/run/docker/docker.sock \
debug_justfile=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_justfile || false }} \
profile=${{ matrix.build.profile }} \
sanitize=${{ matrix.build.sanitize }} \
instrument=${{ matrix.build.instrument }} \
oci_repo=ghcr.io \
$v \
push-container ${{ matrix.nix-target }}
"
done
- name: "Setup tmate session for debug"
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: "mxschmitt/action-tmate@v3"
timeout-minutes: 60
with:
limit-access-to-actor: true
vlab:
if: "${{ needs.check_changes.outputs.devfiles == 'true' || (startsWith(github.event.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/v')) && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}"
needs:
- check_changes
- build
- version
name: "${{ matrix.hybrid && 'h' || 'v' }}-${{ matrix.upgradefrom && 'up' || '' }}${{ matrix.upgradefrom }}${{ matrix.upgradefrom && '-' || '' }}${{ matrix.mesh && 'mesh-' || '' }}${{ matrix.gateway && 'gw-' || '' }}${{ matrix.includeonie && 'onie-' || '' }}${{ matrix.buildmode }}-${{ matrix.vpcmode }}"
uses: githedgehog/fabricator/.github/workflows/run-vlab.yaml@master
with:
# ci:+hlab is required to enable hybrid lab tests on PR
# ci:+vlab is required to enable virtual lab tests on PR
# ci:-upgrade disables upgrade tests on PR
# hlab is disabled for main and merge_queue till we have gateway tests for it
skip: >-
${{
github.event_name == 'pull_request'
&& (
matrix.hybrid && !contains(github.event.pull_request.labels.*.name, 'ci:+hlab')
|| !matrix.hybrid && !contains(github.event.pull_request.labels.*.name, 'ci:+vlab')
|| matrix.upgradefrom != '' && contains(github.event.pull_request.labels.*.name, 'ci:-upgrade')
)
|| github.event_name == 'workflow_dispatch'
&& (
matrix.hybrid && inputs.run_hlab_tests != true
|| !matrix.hybrid && inputs.skip_vlab_tests == true
)
|| (github.event_name == 'push' || github.event_name == 'merge_group')
&& matrix.hybrid
}}
fabricatorref: master
prebuild: |
just bump dataplane ${{ needs.version.outputs.version }}-release
just bump frr ${{ needs.version.outputs.version }}-release
fabricmode: ${{ matrix.fabricmode }}
gateway: ${{ matrix.gateway }}
includeonie: ${{ matrix.includeonie }}
buildmode: ${{ matrix.buildmode }}
vpcmode: ${{ matrix.vpcmode }}
releasetest: ${{ contains(github.event.pull_request.labels.*.name, 'ci:+release') || inputs.enable_release_tests == true }}
hybrid: ${{ matrix.hybrid }}
upgradefrom: ${{ matrix.upgradefrom }}
strategy:
fail-fast: false
matrix:
fabricmode:
- spine-leaf
gateway:
- true
includeonie:
- false
buildmode:
- iso
vpcmode:
- l2vni
hybrid:
- false
upgradefrom:
- ""
include:
# gateway l3vni
- fabricmode: spine-leaf
gateway: true
includeonie: false
buildmode: iso
vpcmode: l3vni
hybrid: false
upgradefrom: ""
# hlab gateway l2vni
- fabricmode: spine-leaf
gateway: true
includeonie: false
buildmode: iso
vpcmode: l2vni
hybrid: true
upgradefrom: ""
summary:
name: "Summary"
runs-on: "ubuntu-latest"
needs:
- build
- vlab
# Run always, except when the "build" job was skipped.
#
# When the build job is skipped, summary will be marked as skipped, and
# it's OK for CI (it's not a failure).
# Why don't we do the same for build jobs? Because their names depend on
# matrix values, and if we skip them the names won't be generated and
# GitHub won't be able to find skipped jobs for required status checks.
if: ${{ always() }}
steps:
- name: "Flag any build matrix failures"
if: ${{ needs.build.result != 'success' && needs.build.result != 'skipped' }}
run: |
echo '::error:: Some build job(s) failed'
exit 1
- name: "Flag any vlab matrix failures"
if: ${{ needs.vlab.result != 'success' && needs.vlab.result != 'skipped' }}
run: |
echo '::error:: Some vlab job(s) failed'
exit 1
publish:
runs-on: lab
if: startsWith(github.event.ref, 'refs/tags/v') && github.event_name == 'push'
needs:
- build
- vlab
permissions:
packages: write
contents: read
env:
USER: "runner"
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: stable
cache: true
- name: Login to ghcr.io
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Install nix"
uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
nix_path: nixpkgs=channel:nixpkgs-unstable
- uses: "cachix/cachix-action@v17"
with:
name: "hedgehog"
# prettier-ignore
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
# prettier-ignore
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: "push containers"
run: |
nix-shell --run "
just \
docker_sock=/run/docker/docker.sock \
oci_repo=ghcr.io \
version=${{ github.ref_name }} \
push
"
# Bump dataplane in the fabricator repository
- name: Checkout fabricator repository
uses: actions/checkout@v6
with:
repository: githedgehog/fabricator
path: fab-repo
persist-credentials: false
- name: Bump dataplane+frr in fabricator
working-directory: fab-repo
run: |
sed -i "s/^\tDataplaneVersion.*/\tDataplaneVersion=meta.Version(\"${{ github.ref_name }}\")/" pkg/fab/versions.go
sed -i "s/^\tFRRVersion.*/\tFRRVersion=meta.Version(\"${{ github.ref_name }}\")/" pkg/fab/versions.go
go fmt pkg/fab/versions.go
- name: Generate token for the fabricator repository
uses: actions/create-github-app-token@v3
id: fab-app-token
with:
app-id: ${{ secrets.FAB_APP_ID }}
private-key: ${{ secrets.FAB_PRIVATE_KEY }}
repositories: |
fabricator
- name: Create Pull Request for fabricator
uses: peter-evans/create-pull-request@v8
id: fab-pr
with:
token: ${{ steps.fab-app-token.outputs.token }}
path: fab-repo
branch: pr/auto/dataplane-bump
commit-message: |
bump: dataplane/frr to ${{ github.ref_name }}
This is an automated commit created by GitHub Actions workflow,
in the dataplane repository.
signoff: true
title: "bump: dataplane/frr to ${{ github.ref_name }}"
body: |
This is an automated Pull Request created by GitHub Actions workflow,
in the dataplane repository.