Repository navigation
243 lines (220 loc) · 7.96 KB
/
Copy pathrun-vlab.yaml
File metadata and controls
243 lines (220 loc) · 7.96 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
name: Run VLAB
on:
workflow_call:
inputs:
skip:
description: "Skip"
type: boolean
required: false
default: false
fabricatorref:
description: "Fabricator reference to use"
type: string
required: true
prebuild:
description: "Pre-build script (e.g. 'just bump fabric v0.42.0')"
type: string
required: false
default: "echo 'Noop pre-build'"
fabricmode:
description: "Fabric mode (e.g. spine-leaf, collapsed-core)"
type: string
required: false
default: "spine-leaf"
mesh:
description: "Use spine-leaf with mesh-only connections"
type: boolean
required: false
default: false
gateway:
description: "Enable gateway"
type: boolean
required: false
default: false
includeonie:
description: "Include ONIE into installer"
type: boolean
required: false
default: false
buildmode:
description: "Build mode (e.g. iso, usb, manual)"
type: string
required: false
default: "iso"
vpcmode:
description: "VPC mode (e.g. l2vni, l3vni)"
type: string
required: false
default: "l2vni"
releasetest:
description: "Run Release tests"
type: boolean
required: false
default: false
release_test_regex:
description: "Regex pattern to filter release tests"
type: string
required: false
default: ""
release_test_invert_regex:
description: "Invert regex selection"
type: boolean
required: false
default: false
hybrid:
description: "Enable hybrid mode (use env with physical switches)"
type: boolean
required: false
default: false
debug:
description: "Enable tmate debugging"
type: boolean
required: false
default: false
pause_on_fail:
description: "Pause release tests on failure for debugging"
type: boolean
required: false
default: false
permissions:
contents: read
env:
# global workflow configs
slug: "${{ inputs.hybrid && 'hlab' || 'vlab' }}-${{ inputs.fabricmode == 'spine-leaf' && 'sl' || 'cc' }}-${{ inputs.mesh && 'mesh-' || '' }}${{ inputs.gateway && 'gw-' || '' }}${{ inputs.includeonie && 'onie-' || '' }}${{ inputs.buildmode }}-${{ inputs.vpcmode }}${{ inputs.releasetest && '-rt' || '' }}"
# env vars to configure hhfab
HHFAB_REG_REPO: 127.0.0.1:30000
HHFAB_VLAB_COLLECT: true
jobs:
run:
if: ${{ !inputs.skip }}
runs-on: ${{ inputs.hybrid && 'hlab' || 'vlab' }}
timeout-minutes: "${{ inputs.releasetest && (inputs.hybrid && 250 || 150) || 60 }}"
steps:
- name: Runner host
run: |
echo "$KUBE_NODE"
- name: Inputs summary
run: |
echo "Inputs:"
echo " Fabricator reference: ${{ inputs.fabricatorref }}"
echo " Pre-build script: ${{ inputs.prebuild }}"
echo " Fabric mode: ${{ inputs.fabricmode }}"
echo " Mesh: ${{ inputs.mesh }}"
echo " Gateway: ${{ inputs.gateway }}"
echo " Include ONIE: ${{ inputs.includeonie }}"
echo " Build mode: ${{ inputs.buildmode }}"
echo " VPC mode: ${{ inputs.vpcmode }}"
echo " Release test: ${{ inputs.releasetest }}"
echo " Hybrid: ${{ inputs.hybrid }}"
echo " Debug: ${{ inputs.debug }}"
echo "Calculated:"
echo " Slug: ${{ env.slug }}"
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: githedgehog/fabricator
ref: ${{ inputs.fabricatorref }}
fetch-depth: 0
- name: Checkout lab-ci repository
uses: actions/checkout@v4
if: ${{ inputs.hybrid }}
with:
repository: githedgehog/lab-ci
path: "./lab-ci"
- name: Pre-populate hhfab-cache
run: |
if [ -d "/hostcache/.hhfab-cache" ]; then
cp -r /hostcache/.hhfab-cache ~/
else
echo "Host cache not available"
fi
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
cache: false
- name: Setup local registry
run: |
just --timestamp _localreg &
- name: Pre-build script
run: |
echo "Running pre-build script"
${{ inputs.prebuild }}
- name: Build hhfab
run: |
just --timestamp oci_repo=127.0.0.1:30000 oci=http push
- name: Init hhfab for virtual mode
if: ${{ !inputs.hybrid }}
run: |
bin/hhfab init -v --dev \
--fabric-mode=${{ inputs.fabricmode }} \
--include-onie=${{ inputs.includeonie }} \
--gateway=${{ inputs.gateway }}
- name: Generate VLAB wiring
if: ${{ !inputs.hybrid }}
run: |
bin/hhfab vlab gen -v ${{ inputs.mesh && '--mesh-links-count=3' || '' }}
- name: Init hhfab for hybrid mode
if: ${{ inputs.hybrid }}
run: |
source "./lab-ci/envs/$KUBE_NODE/source.sh"
bin/hhfab init -v --dev \
--fabric-mode=${{ inputs.fabricmode }} \
--include-onie=${{ inputs.includeonie }} \
--gateway=${{ inputs.gateway }} \
-w "./lab-ci/envs/$KUBE_NODE/wiring.yaml"
- name: Print hhfab versions
run: |
bin/hhfab versions | tee versions.txt
- name: Generate VLAB diagrams
run: |
bin/hhfab diagram --format=drawio
bin/hhfab diagram --format=dot
bin/hhfab diagram --format=mermaid
# TODO: make controls restricted again when we figure out how to get NTP upstream working for isolated VMs
- name: Run and test ${{ inputs.hybrid && 'hybrid ' || '' }}VLAB
run: |
export HHFAB_JOIN_TOKEN=$(openssl rand -base64 24)
bin/hhfab vlab up -v \
--build-mode="${{ inputs.buildmode }}" \
--vpc-mode="${{ inputs.vpcmode }}" \
${{ inputs.hybrid && '--controls-restricted=false' || '' }} \
${{ inputs.hybrid && '--ready switch-reinstall' || '' }} \
--ready=inspect \
--ready=setup-vpcs \
${{ !inputs.gateway && '--ready=setup-peerings' || '' }} \
--ready=test-connectivity \
${{ inputs.releasetest && '--ready=release-test' || '' }} \
${{ inputs.release_test_regex && format('--release-test-regex="{0}"', inputs.release_test_regex) || '' }} \
${{ inputs.release_test_invert_regex && '--release-test-invert-regex' || '' }} \
${{ inputs.pause_on_fail && '--pause-on-fail' || '' }} \
--ready=exit
- name: Upload Release Test Results
uses: actions/upload-artifact@v4
if: ${{ inputs.releasetest && !cancelled()}}
with:
name: ${{ env.slug }}--test-results
path: release-test.xml
- name: Prepare debug artifacts
if: ${{ always() }}
run: |
mkdir -p _debug/serial
cp versions.txt _debug/ || true
cp result/diagram.* _debug/ || true
cp vlab.hhs _debug/ || true
cp -r show-tech-output _debug/ || true
cp .zot/log _debug/zot.log || true
find ./vlab/vms -type f -name serial.log -exec bash -c 'cp $0 _debug/serial/$(basename $(dirname $0)).log' {} \; || true
mv _debug fab-${{ github.run_id }}-${{ env.slug }}
- name: Upload debug artifacts
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: fab-${{ github.run_id }}-${{ env.slug }}
path: fab-${{ github.run_id }}-${{ env.slug }}
- name: Setup tmate session for debug
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 30
with:
limit-access-to-actor: true