-
Notifications
You must be signed in to change notification settings - Fork 26
393 lines (341 loc) · 10.7 KB
/
build.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
name: build
on:
push:
branches: ["main"]
paths-ignore:
- '**/*.md'
- '**/*.png'
- '**/*.gitignore'
- '.vscode/**'
- '.github/mergify.yml'
- '.excalidraw-ignore'
pull_request:
branches: ["main"]
# Must stay in sync with the paths in .github/workflows/docs.yml and .github/mergify.yml
paths-ignore:
- '**/*.md'
- '**/*.png'
- '**/*.gitignore'
- '.vscode/**'
- '.github/mergify.yml'
- '.excalidraw-ignore'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: ./.github/actions/setup-go-env
- name: Generate Source Code
run: |
make generate
- name: Check for uncommitted changes
id: check-changes
run: |
if [ "$(git diff --ignore-space-at-eol | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
echo "========================================================"
echo " run 'make generate' and commit the changes"
echo "========================================================"
exit 1
fi
go-lint-linux:
runs-on: ubuntu-latest
strategy:
matrix:
os: ["linux"]
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: ./.github/actions/setup-go-env
- name: Lint ${{ matrix.os }}
run: make dist/.go-lint-${{ matrix.os }}
# these are a little slower to lint...
go-lint-rest:
runs-on: ubuntu-latest
strategy:
matrix:
os: ["darwin", "windows"]
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: ./.github/actions/setup-go-env
- name: Lint ${{ matrix.os }}
run: make dist/.go-lint-${{ matrix.os }}
ui-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: UI Lint
run: make ui-lint
k8s-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: ./.github/actions/setup-go-env
- name: Login to GHCR
run: echo "${{ github.token }}" | docker login https://ghcr.io -u "${GITHUB_ACTOR}" --password-stdin
- name: Check Kube Manifests
run: |
make -j yaml-lint k8s-lint
opa-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup OPA
uses: open-policy-agent/setup-opa@v2
with:
version: latest
- name: OPA Lint and Tests
run: make opa-lint
build-images:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: apiserver
tags: quay.io/nexodus/apiserver:latest
- name: frontend
tags: quay.io/nexodus/frontend:latest
- name: ipam
tags: quay.io/nexodus/go-ipam:latest
- name: nexd
tags: quay.io/nexodus/nexd:latest
- name: envsubst
tags: quay.io/nexodus/envsubst:latest
- name: playwright
tags: quay.io/nexodus/playwright:latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build and export ${{ matrix.name }}
uses: docker/build-push-action@v5
with:
file: ./Containerfile.${{ matrix.name }}
tags: ${{ matrix.tags }}
outputs: type=docker,dest=/tmp/${{ matrix.name }}.tar
cache-from: type=gha,scope=${{ matrix.name }}
cache-to: type=gha,scope=${{ matrix.name }},mode=max
- name: Upload ${{ matrix.name }} artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: /tmp/${{ matrix.name }}.tar
go-unit:
needs: [ go-lint-linux, go-lint-rest, generate ]
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
arch: ["amd64", "arm64", "arm"]
exclude:
- os: macos-latest
arch: arm
- os: windows-latest
arch: arm
- os: windows-latest
arch: arm64
# Tests are failing with "bad CPU type in executable" or "exec format error"
- os: ubuntu-latest
arch: arm
- os: ubuntu-latest
arch: arm64
- os: macos-latest
arch: arm64
runs-on: ${{ matrix.os }}
env:
GOARCH: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: ./.github/actions/setup-go-env
- name: Unit tests
run: |
gotestsum --format standard-quiet -- -v ./...
build-packages:
needs: [ go-lint-linux, generate ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: ./.github/actions/setup-go-env
- name: Build nexodus packages
id: build
shell: bash
run: |
NEXODUS_BUILD_PROFILE=prod make -j dist/packages
- name: Upload nexodus zip packages
uses: actions/upload-artifact@v4
with:
name: nexodus-packages-zip
if-no-files-found: error
path: |
dist/packages/*.zip
- name: Upload nexodus tar.gz packages
uses: actions/upload-artifact@v4
with:
name: nexodus-packages-tar
if-no-files-found: error
path: |
dist/packages/*.tar.gz
upload-s3-packages:
needs: ["build-packages", "build-rpm", "go-unit", "e2e"]
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
environment: image-repositories
if: github.ref == 'refs/heads/main'
steps:
- name: download zip binary artifacts
uses: actions/download-artifact@v4
with:
name: nexodus-packages-zip
path: dist/packages
- name: download tar.gz binary artifacts
uses: actions/download-artifact@v4
with:
name: nexodus-packages-tar
path: dist/packages
- name: Display structure of downloaded files
run: ls -lah -R
working-directory: dist/packages
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE }}
role-session-name: nexodus-ci-deploy
aws-region: us-east-1
- name: copy binaries to s3
run: |
aws s3 sync dist/packages s3://nexodus-io/qa
e2e:
needs: [build-images]
name: e2e-integration
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
# todo: work on getting the cockroach overlay working ["dev", "cockroach"]
overlay: ["dev"]
steps:
- name: Remove unnecessary files on the runner for additional space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo apt-get clean
sudo apt-get autoremove
docker system prune -a -f
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Setup Go
uses: ./.github/actions/setup-go-env
- name: Install deps
run: |
sudo apt update
sudo apt-get -qy install libnss3-tools
- name: Download apiserver image
uses: actions/download-artifact@v4
with:
name: apiserver
path: /tmp
- name: Download frontend image
uses: actions/download-artifact@v4
with:
name: frontend
path: /tmp
- name: Download ipam image
uses: actions/download-artifact@v4
with:
name: ipam
path: /tmp
- name: Download nexd image
uses: actions/download-artifact@v4
with:
name: nexd
path: /tmp
- name: Download envsubst image
uses: actions/download-artifact@v4
with:
name: envsubst
path: /tmp
- name: Download playwright image
uses: actions/download-artifact@v4
with:
name: playwright
path: /tmp
- name: Load Docker images
run: |
docker load --input /tmp/apiserver.tar
docker load --input /tmp/frontend.tar
docker load --input /tmp/ipam.tar
docker load --input /tmp/nexd.tar
docker load --input /tmp/envsubst.tar
docker load --input /tmp/playwright.tar
- name: Setup KIND
run: |
OVERLAY=${{ matrix.overlay }} make setup-kind install-olm deploy-operators load-images deploy cacerts derpcerts
- name: Build dist
run: |
make dist/nexd dist/nexctl
- name: Run e2e Tests
run: |
gotestsum --format standard-quiet -- -v --tags=integration ./integration-tests/...
- name: Get Logs
if: always()
run: |
kubectl logs -n nexodus -l app.kubernetes.io/part-of=nexodus --all-containers=true > logs.txt
- name: Upload Logs and Test Reports
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-${{ matrix.overlay }}-logs
path: |
logs.txt
./ui/playwright-report/
- name: Check Disk Space
if: always()
run: df -h
build-rpm:
needs: [ go-lint-linux, generate ]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- mock_root: fedora-38-x86_64
srpm_mock_root: fedora-38-x86_64
srpm_distro: fc38
- mock_root: fedora-39-x86_64
srpm_mock_root: fedora-39-x86_64
srpm_distro: fc39
- mock_root: centos-stream-9-x86_64
srpm_mock_root: centos-stream-9-x86_64
srpm_distro: el9
steps:
- uses: actions/checkout@v4
# Needed for building binaries to generate manpages
- name: Setup Go
uses: ./.github/actions/setup-go-env
- name: Build rpm
id: build-rpm
run: |
MOCK_ROOT="${{ matrix.mock_root }}" SRPM_MOCK_ROOT="${{ matrix.srpm_mock_root }}" SRPM_DISTRO="${{ matrix.srpm_distro }}" make rpm
echo "artifact-name=$(pwd)/dist/rpm/mock/nexodus-${{ matrix.mock_root }}-*.x86_64.rpm" >> "$GITHUB_OUTPUT"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: nexodus-rpms-${{ matrix.mock_root }}
path: |
${{ steps.build-rpm.outputs.artifact-name }}
build-workflow-complete:
needs: ["build-packages", "build-rpm", "go-unit", "e2e", "k8s-lint", "opa-lint", "ui-lint"]
runs-on: ubuntu-latest
steps:
- name: Build Complete
run: echo "Build Complete"