-
Notifications
You must be signed in to change notification settings - Fork 52
297 lines (274 loc) · 9.87 KB
/
ci.yml
File metadata and controls
297 lines (274 loc) · 9.87 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
name: ci
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches:
- main
- release/**
paths-ignore:
- 'website/**'
- 'docs/**'
- '*.md'
- 'CODEOWNERS'
- 'LICENSE'
- '.github/copilot-instructions.md'
- '.github/workflows/retag.yml'
- '.github/workflows/retag/**'
- 'cmd/retagger/**'
- 'cmd/worker-image-matrix/**'
- '.github/workflows/worker-images/**'
- '.github/workflows/worker-images.yml'
- '.github/workflows/dependabot.yml'
- '.github/workflows/release.yml'
- '.github/workflows/deploy-docs.yml'
push:
branches:
- main
- release/**
paths-ignore:
- 'website/**'
- 'docs/**'
- '*.md'
- 'CODEOWNERS'
- 'LICENSE'
- '.github/copilot-instructions.md'
- '.github/workflows/retag.yml'
- '.github/workflows/retag/**'
- 'cmd/retagger/**'
- 'cmd/worker-image-matrix/**'
- '.github/workflows/worker-images/**'
- '.github/workflows/worker-images.yml'
permissions:
contents: read
packages: read
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
- name: checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: '1.24'
cache: false
# Use the golang-ci lint action which automattically sets up GHA caching and other things
# Note: There is also a "lint" target in docker-bake.hcl for local linting
# If you make changes to this, please make sure to also update the local linting target
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.1.6
args: --timeout=30m
- name: custom linters
run: go run ./cmd/lint ./...
- name: validate generated files
run: |
go generate ./... || exit $?
if ! git diff --exit-code; then
echo "::error::Missing updates to generated files. Please run 'go generate ./...' and commit the changes"
exit 1
fi
integration:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
suite:
- Mariner2
- Azlinux3
- Bookworm
- Bullseye
- Bionic
- Focal
- Jammy
- Noble
- Windows
- Almalinux8
- Almalinux9
- Rockylinux8
- Rockylinux9
- Trixie
- other
include:
- suite: other
skip: Mariner2|Azlinux3|Bookworm|Bullseye|Bionic|Focal|Jammy|Noble|Windows|Almalinux8|Almalinux9|Rockylinux8|Rockylinux9|Trixie
# TODO: support diff/merge
# Right now this is handled by the e2e suite, but we can migrate that here.
steps:
- name: Harden Runner
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: '1.24'
cache: false
- name: Cleanup runner
run: docker system prune -f --volumes --all
- name: checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: ./.github/actions/enable-containerd
- uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
name: Login to GHCR
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup tracing
id: setup-tracing
uses: ./.github/actions/setup-tracing
- name: download deps
run: go mod download
- name: Setup QEMU
run: docker run --rm --privileged tonistiigi/binfmt:latest --install all
- name: Setup source policy
uses: ./.github/actions/setup-source-policy
- name: Get docker info
run: |
docker info
docker version
docker buildx version
containerd --version
- name: Run integration tests
run: |
set -ex
if [ -n "${TEST_SUITE}" ] && [ ! "${TEST_SUITE}" = "other" ]; then
run="-run=${TEST_SUITE}"
fi
if [ -n "${TEST_SKIP}" ]; then
skip="-skip=${TEST_SKIP}"
fi
go test -timeout=59m -v -json ${run} ${skip} ./test | go run ./cmd/test2json2gha --slow 120s --logdir /tmp/testlogs
env:
TEST_SUITE: ${{ matrix.suite }}
TEST_SKIP: ${{ matrix.skip }}
- name: Finalize traces
if: always()
uses: ./.github/actions/teardown-tracing
with:
artifact-name: integration-test-traces-${{matrix.suite}}
tracing-id: ${{ steps.setup-tracing.outputs.tracing-id }}
traces-path: ${{ steps.setup-tracing.outputs.traces-path }}
- name: Upload reports
if: always()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: integration-test-logs-${{matrix.suite}}
path: /tmp/testlogs/*
retention-days: 1
- name: dump logs
if: failure()
id: dump-logs
run: |
set -e
dir="$(mktemp -d)"
f="${dir}/dockerd.log"
echo "DOCKERD_LOG_PATH=${f}" >> $GITHUB_OUTPUT
sudo journalctl -u docker > "${f}"
- name: Upload buildkit logs
if: failure()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: e2e-dockerd-logs-${{ matrix.suite }}
path: ${{ steps.dump-logs.outputs.DOCKERD_LOG_PATH }}
retention-days: 1
unit:
runs-on: ubuntu-22.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
- name: checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: '1.24'
cache: false
- name: download deps
run: go mod download
- name: Run unit tests
run: go test -v --test.short --json ./... | go run ./cmd/test2json2gha
e2e:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
disable_diff_merge: ["1", "0"]
name: "Test E2E (disable diff/merge: ${{ matrix.disable_diff_merge }})"
env:
DALEC_DISABLE_DIFF_MERGE: ${{ matrix.disable_diff_merge }}
FRONTEND_REF: localhost:5000/dalec/frontend
steps:
- name: Harden Runner
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
- name: checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
# We need to fetch all commits so that we can diff against the base branch
fetch-depth: 0
- name: Expose GitHub tokens for caching
uses: crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0
- name: Setup source policy
uses: ./.github/actions/setup-source-policy
- uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
name: Login to GHCR
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/format-repo
id: format-repo
- name: Setup builder
run: |
# Sometimes the builder runs out of space... so cleanup anything we can first.
docker image prune -a -f
docker run -d --net=host ghcr.io/${{ steps.format-repo.outputs.result }}/mirror/dockerhub/library/registry:latest
# If diff/merge are enabled we need to use a buildx builder to make sure the feature is supported.
# Otherwise we can just use the default docker builder.
if [ "${DALEC_DISABLE_DIFF_MERGE}" = "0" ]; then
docker buildx create --use --driver-opt network=host
echo FRONTEND_BAKE_TARGET="frontend-ci-full" >> $GITHUB_ENV
echo USE_BUILDX=1 >> $GITHUB_ENV
else
echo DALEC_NO_CACHE_EXPORT="1" >> $GITHUB_ENV
echo FRONTEND_BAKE_TARGET="frontend-ci" >> $GITHUB_ENV
fi
- name: Build frontend image
run: docker buildx bake ${FRONTEND_BAKE_TARGET}
- name: test
run: |
docker buildx bake test
- name: Build go-md2man example in docs
run: |
version=$(cat docs/examples/go-md2man.yml | yq .version)
docker build -t go-md2man:$version -f docs/examples/go-md2man.yml --target=mariner2/rpm --output=_output .
docker build -t go-md2man:$version -f docs/examples/go-md2man.yml --target=mariner2 .
- name: dump logs
if: failure()
id: dump-logs
run: |
set -e
dir="$(mktemp -d)"
f="${dir}/dockerd.log"
echo "DOCKERD_LOG_PATH=${f}" >> $GITHUB_OUTPUT
if [ "${USE_BUILDX}" = "1" ]; then
docker logs $(docker ps -lq) > "${f}"
else
sudo journalctl -u docker > "${f}"
fi
- name: Upload buildkit logs
if: failure()
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: e2e-dockerd-logs-diffmerge=${{ matrix.disable_diff_merge }}
path: ${{ steps.dump-logs.outputs.DOCKERD_LOG_PATH }}
retention-days: 1