-
Notifications
You must be signed in to change notification settings - Fork 259
421 lines (405 loc) · 17.7 KB
/
build-test.yaml
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
name: Build and test FreeIPA containers
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '15 4 * * 1,3,5'
jobs:
build:
name: Build image
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
os: [ fedora-rawhide, fedora-41, fedora-40, centos-9-stream, rocky-9, rocky-8, almalinux-9, almalinux-8 ]
docker: [ docker ]
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Separate git work tree with just the files needed for build
run: git worktree add --no-checkout ../minimize-for-build
- name: Populate with the Dockerfile
run: cd ../minimize-for-build && git checkout HEAD Dockerfile.${{ matrix.os }}
- name: Populate with files referenced from the Dockerfile
run: cd ../minimize-for-build && awk '/^(ADD|COPY)/ { for (i = 2; i < NF; i++) print $i }' Dockerfile.${{ matrix.os }} | while read f ; do git checkout HEAD $f ; done
- name: Ensure docker images sees the named parent image
run: awk '$1 == "FROM" { print $2 ; exit }' ../minimize-for-build/Dockerfile.${{ matrix.os }} | xargs ${{ matrix.docker }} pull
- name: Build image
run: ${{ matrix.docker }} build -t localhost/freeipa-server:${{ matrix.os }} -f Dockerfile.${{ matrix.os }} ../minimize-for-build
- name: Label the built image
run: docker="${{ matrix.docker }}" ./ci/label-image.sh Dockerfile.${{ matrix.os }} localhost/freeipa-server:${{ matrix.os }} $( cd ../minimize-for-build && git write-tree ) "${{ github.server_url }}/${{ github.repository }}" "actions/runs/${{ github.run_id }}"
- name: File issue if building image failed
if: ${{ failure() && github.event_name == 'schedule' }}
run: |
curl -s '${{ github.api_url }}/repos/${{ github.repository }}/issues?labels=image-build-fail' | jq -r '.[0].state' | grep open \
|| curl -s -X POST \
--url ${{ github.api_url }}/repos/${{ github.repository }}/issues \
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
-H 'Accept: application/vnd.github.v3+json' \
-d '{
"title": "Image build for ${{ matrix.os }} failed on '$( date -I )'",
"body": "This issue was automatically created by GitHub Action\n\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.\n",
"labels": ["image-build-fail" ]
}'
- name: Create directory for artifacts
run: mkdir freeipa-server-${{ matrix.os }}
- name: Save image
run: ${{ matrix.docker }} save localhost/freeipa-server:${{ matrix.os }} | gzip > freeipa-server-${{ matrix.os }}/freeipa-server-${{ matrix.os }}.tar.gz
- uses: actions/upload-artifact@v4
with:
name: freeipa-server-${{ matrix.os }}
path: freeipa-server-${{ matrix.os }}
retention-days: 1
- name: Check resulting labels
run: |
skopeo inspect docker-archive:freeipa-server-${{ matrix.os }}/freeipa-server-${{ matrix.os }}.tar.gz | jq '.Labels'
diff -u <( skopeo inspect docker://quay.io/freeipa/freeipa-server:${{ matrix.os }} | jq '.Labels' ) <( skopeo inspect docker-archive:freeipa-server-${{ matrix.os }}/freeipa-server-${{ matrix.os }}.tar.gz | jq '.Labels' ) || true
shell: bash
test-docker:
name: Run with docker
runs-on: ubuntu-22.04
needs: [ build ]
strategy:
fail-fast: false
matrix:
include:
- os: fedora-41
- os: fedora-41
readonly: --read-only
volume: freeipa-data
- os: fedora-41
readonly: --read-only
- os: fedora-rawhide
- os: fedora-rawhide
readonly: --read-only
ca: --external-ca
volume: freeipa-data
- os: centos-9-stream
- os: centos-9-stream
readonly: --read-only
volume: freeipa-data
- os: centos-9-stream
readonly: --read-only
ca: --external-ca
os: [ fedora-40, almalinux-9, rocky-8 ]
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/docker-cgroups-ubuntu-22
- uses: actions/download-artifact@v4
with:
name: freeipa-server-${{ matrix.os }}
- name: Load image
run: gunzip < freeipa-server-${{ matrix.os }}.tar.gz | docker load
- run: docker volume create ${{ matrix.volume }}
if: ${{ matrix.volume }} == freeipa-data
- name: Run master and replica
run: readonly=${{ matrix.readonly }} ca=${{ matrix.ca }} VOLUME=${{ matrix.volume }} seccomp=${{ matrix.seccomp }} replica=${{ matrix.replica }} tests/run-master-and-replica.sh localhost/freeipa-server:${{ matrix.os }}
- name: Run partial tests
if: ${{ failure() }}
run: tests/run-partial-tests.sh Dockerfile.${{ matrix.os }}
test-rootless-docker:
name: Run with rootless docker
runs-on: ubuntu-22.04
needs: [ build ]
strategy:
fail-fast: false
matrix:
include:
- os: fedora-rawhide
readonly: --read-only
- os: fedora-41
readonly: --read-only
volume: freeipa-data
- os: rocky-9
readonly: --read-only
- os: almalinux-8
readonly: --read-only
volume: freeipa-data
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- run: sudo systemctl disable --now docker.service docker.socket
- run: curl -fsSL https://get.docker.com/rootless | FORCE_ROOTLESS_INSTALL=1 sh
- uses: actions/download-artifact@v4
with:
name: freeipa-server-${{ matrix.os }}
- name: Load image
run: gunzip < freeipa-server-${{ matrix.os }}.tar.gz | docker load
- run: docker volume create ${{ matrix.volume }}
if: ${{ matrix.volume }} == freeipa-data
- name: Run master and replica
run: readonly=${{ matrix.readonly }} ca=${{ matrix.ca }} VOLUME=${{ matrix.volume }} seccomp=${{ matrix.seccomp }} replica=${{ matrix.replica }} tests/run-master-and-replica.sh localhost/freeipa-server:${{ matrix.os }}
- name: Run partial tests
if: ${{ failure() }}
run: tests/run-partial-tests.sh Dockerfile.${{ matrix.os }}
test-docker-20-04:
name: Run with docker on Ubuntu 20.04 with hybrid cgroups
runs-on: ubuntu-20.04
needs: [ build ]
strategy:
fail-fast: false
matrix:
include:
- os: fedora-41
readonly: --read-only
- os: centos-9-stream
readonly: --read-only
timeout-minutes: 30
steps:
- run: ls -la /sys/fs/cgroup/unified
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: freeipa-server-${{ matrix.os }}
- name: Load image
run: gunzip < freeipa-server-${{ matrix.os }}.tar.gz | docker load
- name: Run master and replica
run: readonly=${{ matrix.readonly }} ca=${{ matrix.ca }} seccomp=${{ matrix.seccomp }} replica=${{ matrix.replica }} tests/run-master-and-replica.sh localhost/freeipa-server:${{ matrix.os }}
- name: Run partial tests
if: ${{ failure() }}
run: tests/run-partial-tests.sh Dockerfile.${{ matrix.os }}
test-podman:
name: Run with sudo podman 4
runs-on: ubuntu-22.04
needs: [ build ]
strategy:
fail-fast: false
matrix:
os: [ fedora-41, centos-9-stream ]
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install podman 4.*
uses: ./.github/actions/install-podman-4
- uses: actions/download-artifact@v4
with:
name: freeipa-server-${{ matrix.os }}
- name: Load image
run: gunzip < freeipa-server-${{ matrix.os }}.tar.gz | sudo podman load
- name: Run master and replica
run: docker='sudo podman' tests/run-master-and-replica.sh localhost/freeipa-server:${{ matrix.os }}
- name: Run partial tests
if: ${{ failure() }}
run: docker='sudo podman' tests/run-partial-tests.sh Dockerfile.${{ matrix.os }}
test-rootless-podman:
name: Run with rootless podman 4
runs-on: ubuntu-22.04
needs: [ build ]
strategy:
fail-fast: false
matrix:
include:
- os: fedora-41
readonly: --read-only
volume: freeipa-data
- os: almalinux-9
readonly: --read-only
volume: freeipa-data
- os: rocky-8
readonly: --read-only
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install podman 4.*
uses: ./.github/actions/install-podman-4
- uses: actions/download-artifact@v4
with:
name: freeipa-server-${{ matrix.os }}
- name: Load image
run: gunzip < freeipa-server-${{ matrix.os }}.tar.gz | podman load
- run: podman volume create ${{ matrix.volume }}
if: ${{ matrix.volume }} == freeipa-data
- name: Run master and replica
run: docker=podman VOLUME=${{ matrix.volume }} tests/run-master-and-replica.sh localhost/freeipa-server:${{ matrix.os }} && podman pod ls -q | xargs podman pod rm -f
- name: Run partial tests
if: ${{ failure() }}
run: docker=podman tests/run-partial-tests.sh Dockerfile.${{ matrix.os }}
test-upgrade:
name: Upgrade from older version or build
runs-on: ubuntu-22.04
needs: [ build ]
strategy:
fail-fast: false
matrix:
include:
- os: fedora-rawhide
data-from: fedora-41
- os: fedora-41
data-from: fedora-41
- os: fedora-41
data-from: fedora-40
- os: fedora-40
data-from: fedora-39
- os: rocky-8
data-from: centos-8-certs-updated-data
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/docker-cgroups-ubuntu-22
- uses: actions/download-artifact@v4
with:
name: freeipa-server-${{ matrix.os }}
- name: Load image
run: gunzip < freeipa-server-${{ matrix.os }}.tar.gz | docker load
- name: Populate volume with data
run: docker volume create loaded-data && docker create --name loaded-data -v loaded-data:/data:z quay.io/freeipa/freeipa-server:data-${{ matrix.data-from }} noop && mkdir /tmp/freeipa-data && docker run --security-opt label=disable --volumes-from loaded-data -v /tmp/freeipa-data:/data-out:z --rm docker.io/library/busybox sh -c 'cd /data && cp -a . /data-out'
- name: Run master and replica
run: VOLUME=/tmp/freeipa-data replica=none tests/run-master-and-replica.sh localhost/freeipa-server:${{ matrix.os }}
test-upgrade-podman:
name: Upgrade from older version with podman 4
runs-on: ubuntu-22.04
needs: [ build ]
strategy:
fail-fast: false
matrix:
include:
- os: fedora-41
data-from: fedora-40
- os: almalinux-8
data-from: centos-8-certs-updated-data
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Install podman 4.*
uses: ./.github/actions/install-podman-4
- uses: actions/download-artifact@v4
with:
name: freeipa-server-${{ matrix.os }}
- name: Load image
run: gunzip < freeipa-server-${{ matrix.os }}.tar.gz | podman load
- name: Populate volume with data
run: podman volume create loaded-data && podman run --name loaded-data -v loaded-data:/data:z quay.io/freeipa/freeipa-server:data-${{ matrix.data-from }} noop || true
- name: Copy the content of the volume to directory
run: mkdir /tmp/freeipa-data && podman run --volumes-from loaded-data -v /tmp/freeipa-data:/data-out:z --rm docker.io/library/busybox sh -c 'cd /data && cp -a . /data-out'
- name: Run master and replica
run: docker=podman VOLUME=/tmp/freeipa-data replica=none tests/run-master-and-replica.sh localhost/freeipa-server:${{ matrix.os }}
test-upgrade-20-04:
name: Upgrade from older version or build on Ubuntu 20.04
runs-on: ubuntu-20.04
needs: [ build ]
strategy:
fail-fast: false
matrix:
include:
- os: fedora-41
data-from: fedora-41
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: freeipa-server-${{ matrix.os }}
- name: Load image
run: gunzip < freeipa-server-${{ matrix.os }}.tar.gz | docker load
- name: Populate volume with data
run: docker volume create loaded-data && docker create --name loaded-data -v loaded-data:/data:z quay.io/freeipa/freeipa-server:data-${{ matrix.data-from }} noop && mkdir /tmp/freeipa-data && docker run --security-opt label=disable --volumes-from loaded-data -v /tmp/freeipa-data:/data-out:z --rm docker.io/library/busybox sh -c 'cd /data && cp -a . /data-out'
- name: Run master and replica
run: VOLUME=/tmp/freeipa-data replica=none tests/run-master-and-replica.sh localhost/freeipa-server:${{ matrix.os }}
test-k3s:
name: Run with K3s with docker
runs-on: ubuntu-22.04
needs: [ build ]
strategy:
fail-fast: false
matrix:
os: [ fedora-41, rocky-9, almalinux-8, centos-9-stream ]
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/docker-cgroups-ubuntu-22
- uses: actions/download-artifact@v4
with:
name: freeipa-server-${{ matrix.os }}
- name: Download latest cri-dockerd
run: curl -s ${{ github.api_url }}/repos/Mirantis/cri-dockerd/releases/latest | jq -r '.assets[].browser_download_url' | grep jammy_amd64.deb | tee /dev/stderr | xargs curl -LO
- name: Install cri-dockerd
run: sudo apt install -y ./cri-dockerd_*.deb
- name: Unset network-plugin
run: |
sudo mkdir /etc/systemd/system/cri-docker.service.d
( echo '[Service]' ; echo 'ExecStart=' ; sed 's/ExecStart=.*/& --network-plugin=/;t;d' /lib/systemd/system/cri-docker.service ) | sudo tee /etc/systemd/system/cri-docker.service.d/network-plugin.conf
sudo systemctl daemon-reload
sudo systemctl restart cri-docker
- name: Load image
run: gunzip < freeipa-server-${{ matrix.os }}.tar.gz | docker load
- name: Run K3s and master in it
run: tests/run-master-in-k3s.sh localhost/freeipa-server:${{ matrix.os }}
push-after-success:
name: Push images to registries
runs-on: ubuntu-22.04
needs: [ test-docker, test-rootless-docker, test-docker-20-04, test-podman, test-rootless-podman, test-upgrade, test-upgrade-20-04, test-k3s ]
if: github.event_name != 'pull_request' && github.repository == 'freeipa/freeipa-container' && github.ref == 'refs/heads/master'
strategy:
fail-fast: false
matrix:
os: [ fedora-41, fedora-40, centos-9-stream, rocky-9, rocky-8, almalinux-9, almalinux-8 ]
timeout-minutes: 30
steps:
- uses: actions/download-artifact@v4
with:
name: freeipa-server-${{ matrix.os }}
- name: Prepare authentication file
run: |
cat > auth.json << 'EOF'
${{ secrets.REGISTRY_CREDENTIALS_FILE }}
EOF
- name: Copy ${{ matrix.os }} to registries
run: |
set -e
f=docker-archive:freeipa-server-${{ matrix.os }}.tar.gz
while read r ; do
if cmp \
<( skopeo inspect $r:${{ matrix.os }} \
| jq -r '.Labels."org.opencontainers.image.base.digest", .Labels."org.opencontainers.image.version"' ) \
<( skopeo inspect $f \
| jq -r '.Labels."org.opencontainers.image.base.digest", .Labels."org.opencontainers.image.version"' ) ; then
echo Built freeipa-server:${{ matrix.os }} is the same as image at ${r#docker://}, not pushing
continue
fi
echo Copying freeipa-server:${{ matrix.os }} to ${r#docker://}
skopeo copy --authfile=auth.json $f $r:${{ matrix.os }}
VERSION=$( skopeo inspect --format='{{index .Labels "org.opencontainers.image.version"}}' $f | sed 's/-.*//' )
test -n "$VERSION"
skopeo copy --authfile=auth.json $r:${{ matrix.os }} $r:${{ matrix.os }}-$VERSION
echo Tagged as ${{ matrix.os }}-$VERSION as well
done << 'EOF'
${{ secrets.REGISTRY_TARGET_LIST }}
EOF
test-subscription:
# Workaround https://github.com/actions/runner/issues/1138
name: Prerequisite for RHEL builds
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
has_rhel_subscriptions: ${{ steps.check.outputs.has_rhel_subscriptions }}
steps:
- id: check
run: |
if [ -n "${{ secrets.REDHAT_ORG }}" -a -n "${{ secrets.REDHAT_ACTIVATIONKEY }}" ] ; then
echo "has_rhel_subscriptions=1" >> $GITHUB_OUTPUT
fi
build-test-rhel-podman:
name: Build and test RHEL image
runs-on: ubuntu-22.04
needs: [ test-subscription ]
if: needs.test-subscription.outputs.has_rhel_subscriptions == 1
strategy:
fail-fast: false
matrix:
os: [ rhel-9, rhel-8 ]
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install podman 4.*
uses: ./.github/actions/install-podman-4
- name: For RHEL builds, use entitlements
uses: ./.github/actions/podman-entitlement
with:
org: ${{ secrets.REDHAT_ORG }}
activationkey: ${{ secrets.REDHAT_ACTIVATIONKEY }}
- name: Build image
run: podman build -t localhost/freeipa-server:${{ matrix.os }} -f Dockerfile.${{ matrix.os }} .
- name: Run master
run: docker=podman tests/run-master-and-replica.sh localhost/freeipa-server:${{ matrix.os }} && podman pod ls -q | xargs podman pod rm -f