-
Notifications
You must be signed in to change notification settings - Fork 2
398 lines (383 loc) · 15.6 KB
/
Copy pathci.yml
File metadata and controls
398 lines (383 loc) · 15.6 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
schedule:
# Nightly K8s-version-matrix smoke at 04:17 UTC. Off-peak slot avoids
# contention with US/EU working-hours PR traffic and the lint cache.
- cron: '17 4 * * *'
permissions:
contents: read
jobs:
validate-yaml-json:
name: Validate YAML/JSON
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up promtool
env:
PROMETHEUS_VERSION: 2.55.1
run: |
set -euo pipefail
mkdir -p /tmp/prometheus
asset="prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz"
base_url="https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}"
curl -sSLO "${base_url}/${asset}"
curl -sSLO "${base_url}/sha256sums.txt"
grep " ${asset}$" sha256sums.txt | sha256sum -c -
tar -xzf "${asset}" --strip-components=1 -C /tmp/prometheus "prometheus-${PROMETHEUS_VERSION}.linux-amd64/promtool"
echo "/tmp/prometheus" >> "${GITHUB_PATH}"
- name: Validate YAML and Grafana JSON
run: make validate-yaml-json
markdown-links:
name: Markdown links
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Check local Markdown links
run: make check-markdown-links
examples:
name: Examples
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up Go
run: scripts/ci-setup-go.sh
- name: Execute example scripts
run: make check-examples
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up Go
run: scripts/ci-setup-go.sh
- name: golangci-lint
run: make lint
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up Go
run: scripts/ci-setup-go.sh
- name: Generate
run: make generate
- name: Build
run: make build
- name: Verify no diff after generate
run: |
git diff --exit-code || (echo "Generated files are out of date. Run 'make generate'." && exit 1)
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up Go
run: scripts/ci-setup-go.sh
- name: Run tests
run: make test
conformance:
name: Conformance
runs-on: ubuntu-latest
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up Go
run: scripts/ci-setup-go.sh
- name: Run reference conformance suites
run: make conformance
- name: Verify hello-world custom-substrate proof
run: make conformance-hello-world
cli-smoke:
name: CLI Smoke and Stress
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up Go
run: scripts/ci-setup-go.sh
- name: Run CLI smoke and stress tests
run: make cli-smoke cli-stress
install-render:
name: Install Render
runs-on: ubuntu-latest
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up Helm and kubectl
run: scripts/ci-setup-tools.sh
- name: Verify install render
run: scripts/verify-install.sh render
kind-smoke:
name: Kind Install Smoke
runs-on: ubuntu-latest
timeout-minutes: 20
if: github.event_name == 'pull_request'
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up Helm, kubectl, and kind
env:
CI_SETUP_KIND: "true"
run: scripts/ci-setup-tools.sh
- name: Install chart and run quickstart smoke
env:
KAPRO_CI_KEEP_CLUSTER_ON_FAILURE: "true"
KAPRO_CI_QUICKSTARTS: direct,flux,argo,oci
run: scripts/ci-kind-smoke.sh
- name: Collect Kind smoke diagnostics
if: failure()
run: |
mkdir -p kind-smoke-diagnostics
kind export logs --name kapro-ci-smoke kind-smoke-diagnostics/kind || true
kubectl --context kind-kapro-ci-smoke get events -A --sort-by=.lastTimestamp > kind-smoke-diagnostics/events.txt || true
kubectl --context kind-kapro-ci-smoke get all -A -o wide > kind-smoke-diagnostics/all.txt || true
kubectl --context kind-kapro-ci-smoke get substrates.kapro.io,fleets.kapro.io,clusters.kapro.io,plans.kapro.io,promotions.kapro.io,promotionruns.runtime.kapro.io,targets.runtime.kapro.io -A -o yaml > kind-smoke-diagnostics/kapro-resources.yaml || true
kubectl --context kind-kapro-ci-smoke -n kapro-system logs deploy/kapro-kapro-operator --tail=-1 > kind-smoke-diagnostics/operator.log || true
release-smoke:
name: Release Smoke
runs-on: ubuntu-latest
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up Helm
run: scripts/ci-setup-tools.sh
- name: Verify release packaging
run: VERSION=v0.6.2 make release-smoke
docker:
name: Docker Build (dry-run)
runs-on: ubuntu-latest
timeout-minutes: 15
if: github.event_name == 'pull_request'
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Build operator image (no push)
run: docker build -f build/package/Dockerfile.operator -t ghcr.io/kapro-dev/kapro-operator:pr-${{ github.event.number }} .
- name: Build cluster-controller image (no push)
run: docker build -f build/package/Dockerfile.cluster-controller -t ghcr.io/kapro-dev/kapro-cluster-controller:pr-${{ github.event.number }} .
kind-smoke-matrix:
# K8s version matrix for the Kind install smoke. Runs nightly on
# schedule and on-demand via workflow_dispatch. The single-version
# Kind Install Smoke job above runs on pull requests.
name: Kind Smoke (K8s ${{ matrix.k8s }})
runs-on: ubuntu-latest
timeout-minutes: 25
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
strategy:
fail-fast: false
matrix:
k8s:
- v1.28.13
- v1.29.8
- v1.30.4
- v1.31.0
steps:
- name: Checkout public source
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
git init .
git remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
ref="refs/pull/${PR_NUMBER}/merge"
else
ref="${GITHUB_REF}"
fi
git -c protocol.version=2 fetch --no-tags --depth=1 origin "+${ref}:refs/remotes/origin/checkout"
git checkout --force --detach refs/remotes/origin/checkout
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Set up Helm, kubectl, and kind
env:
CI_SETUP_KIND: "true"
run: scripts/ci-setup-tools.sh
- name: Install chart and run quickstart smoke
env:
KAPRO_CI_KIND_IMAGE: kindest/node:${{ matrix.k8s }}
KAPRO_CI_KIND_CLUSTER: kapro-ci-${{ matrix.k8s }}
KAPRO_CI_KEEP_CLUSTER_ON_FAILURE: "true"
KAPRO_CI_QUICKSTARTS: direct,flux,argo,oci
run: scripts/ci-kind-smoke.sh
- name: Collect Kind smoke diagnostics
if: failure()
env:
KAPRO_CI_KIND_CLUSTER: kapro-ci-${{ matrix.k8s }}
run: |
mkdir -p kind-smoke-diagnostics
kind export logs --name "${KAPRO_CI_KIND_CLUSTER}" kind-smoke-diagnostics/kind || true
kubectl --context "kind-${KAPRO_CI_KIND_CLUSTER}" get events -A --sort-by=.lastTimestamp > kind-smoke-diagnostics/events.txt || true
kubectl --context "kind-${KAPRO_CI_KIND_CLUSTER}" get all -A -o wide > kind-smoke-diagnostics/all.txt || true
kubectl --context "kind-${KAPRO_CI_KIND_CLUSTER}" get substrates.kapro.io,fleets.kapro.io,clusters.kapro.io,plans.kapro.io,promotions.kapro.io,promotionruns.runtime.kapro.io,targets.runtime.kapro.io -A -o yaml > kind-smoke-diagnostics/kapro-resources.yaml || true
kubectl --context "kind-${KAPRO_CI_KIND_CLUSTER}" -n kapro-system logs deploy/kapro-kapro-operator --tail=-1 > kind-smoke-diagnostics/operator.log || true