Skip to content

Commit 0225f6e

Browse files
trwsgrondo
authored andcommitted
matrix: add explicit multiarch support
problem: it's too easy to accidentally break our multiarch container builds because they're only loosely tied together solution: add a method to the matrix class that ensures the containers on each arch match up
1 parent 91a870a commit 0225f6e

File tree

2 files changed

+110
-108
lines changed

2 files changed

+110
-108
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ jobs:
254254
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
255255
docker manifest create fluxrm/flux-core:bookworm fluxrm/flux-core:bookworm-amd64 fluxrm/flux-core:bookworm-386 fluxrm/flux-core:bookworm-arm64
256256
docker manifest push fluxrm/flux-core:bookworm
257-
for d in el9 noble fedora40 ; do
257+
for d in el9 noble fedora40 alpine ; do
258258
docker manifest create fluxrm/flux-core:$d fluxrm/flux-core:$d-amd64 fluxrm/flux-core:$d-arm64
259259
docker manifest push fluxrm/flux-core:$d
260260
done

src/test/generate-matrix.py

Lines changed: 109 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@
2121
DOCKER_REPO = "fluxrm/flux-core"
2222

2323

24+
def on_master_or_tag(matrix):
25+
return matrix.branch == "master" or matrix.tag
26+
27+
28+
DEFAULT_MULTIARCH_PLATFORMS = {
29+
"linux/arm64": {
30+
"when": on_master_or_tag,
31+
"suffix": " - arm64",
32+
"command_args": "--install-only ",
33+
},
34+
"linux/amd64": {"when": lambda _: True},
35+
}
36+
37+
2438
class BuildMatrix:
2539
def __init__(self):
2640
self.matrix = []
@@ -137,6 +151,27 @@ def add_build(
137151
}
138152
)
139153

154+
def add_multiarch_build(
155+
self,
156+
name: str,
157+
platforms=DEFAULT_MULTIARCH_PLATFORMS,
158+
default_suffix="",
159+
image=None,
160+
docker_tag=True,
161+
**kwargs,
162+
):
163+
for p, args in platforms.items():
164+
if args["when"](self):
165+
suffix = args.get("suffix", default_suffix)
166+
self.add_build(
167+
name + suffix,
168+
platform=p,
169+
docker_tag=docker_tag,
170+
image=image if image is not None else name,
171+
command_args=args.get("command_args", ""),
172+
**kwargs,
173+
)
174+
140175
def __str__(self):
141176
"""Return compact JSON representation of matrix"""
142177
return json.dumps(
@@ -146,33 +181,85 @@ def __str__(self):
146181

147182
matrix = BuildMatrix()
148183

149-
# Debian: 32b
184+
# Multi-arch builds, arm only builds on
185+
bookworm_platforms = dict(DEFAULT_MULTIARCH_PLATFORMS)
186+
bookworm_platforms["linux/386"] = {"when": lambda _: True, "suffix": " - 32 bit"}
187+
common_args = (
188+
"--prefix=/usr"
189+
" --sysconfdir=/etc"
190+
" --with-systemdsystemunitdir=/etc/systemd/system"
191+
" --localstatedir=/var"
192+
" --with-flux-security"
193+
" --enable-caliper"
194+
)
195+
matrix.add_multiarch_build(
196+
name="bookworm",
197+
default_suffix=" - test-install",
198+
platforms=bookworm_platforms,
199+
args=common_args,
200+
env=dict(
201+
TEST_INSTALL="t",
202+
),
203+
)
204+
matrix.add_multiarch_build(
205+
name="noble",
206+
default_suffix=" - test-install",
207+
args=common_args,
208+
env=dict(
209+
TEST_INSTALL="t",
210+
),
211+
)
212+
matrix.add_multiarch_build(
213+
name="el9",
214+
default_suffix=" - test-install",
215+
args=common_args,
216+
env=dict(
217+
TEST_INSTALL="t",
218+
),
219+
)
220+
matrix.add_multiarch_build(
221+
name="fedora40",
222+
default_suffix=" - test-install",
223+
args=common_args,
224+
env=dict(
225+
TEST_INSTALL="t",
226+
),
227+
)
228+
matrix.add_multiarch_build(
229+
name="alpine",
230+
default_suffix=" - test-install",
231+
args=(
232+
"--prefix=/usr"
233+
" --sysconfdir=/etc"
234+
" --with-systemdsystemunitdir=/etc/systemd/system"
235+
" --localstatedir=/var"
236+
" --with-flux-security"
237+
),
238+
env=dict(
239+
TEST_INSTALL="t",
240+
),
241+
)
242+
243+
# single arch builds that still produce a container
244+
# Ubuntu: TEST_INSTALL
150245
matrix.add_build(
151-
name="bookworm - 32 bit",
152-
image="bookworm",
153-
platform="linux/386",
246+
name="jammy - test-install",
247+
image="jammy",
248+
env=dict(
249+
TEST_INSTALL="t",
250+
),
251+
args="--with-flux-security --enable-caliper",
154252
docker_tag=True,
155253
)
156254

157-
# debian/Fedora40: arm64, expensive, only on master and tags, only install
158-
if matrix.branch == "master" or matrix.tag:
159-
for d in ("bookworm", "noble", "fedora40", "el9"):
160-
matrix.add_build(
161-
name=f"{d} - arm64",
162-
image=f"{d}",
163-
platform="linux/arm64",
164-
docker_tag=True,
165-
command_args="--install-only ",
166-
args=(
167-
"--prefix=/usr"
168-
" --sysconfdir=/etc"
169-
" --with-systemdsystemunitdir=/etc/systemd/system"
170-
" --localstatedir=/var"
171-
" --with-flux-security"
172-
),
173-
)
255+
# Ubuntu 20.04: py3.8, deprecated
256+
matrix.add_build(
257+
name="focal - py3.8",
258+
image="focal",
259+
env=dict(PYTHON_VERSION="3.8"),
260+
docker_tag=True,
261+
)
174262

175-
# builds to match arm64 images must have linux/amd64 platform explicitly
176263

177264
# Debian: gcc-12, content-s3, distcheck
178265
matrix.add_build(
@@ -210,62 +297,6 @@ def __str__(self):
210297
args="--with-flux-security --enable-caliper",
211298
)
212299

213-
214-
# Ubuntu: TEST_INSTALL
215-
matrix.add_build(
216-
name="noble - test-install",
217-
image="noble",
218-
env=dict(
219-
TEST_INSTALL="t",
220-
),
221-
platform="linux/amd64",
222-
args="--with-flux-security --enable-caliper",
223-
docker_tag=True,
224-
)
225-
226-
# Ubuntu: TEST_INSTALL
227-
matrix.add_build(
228-
name="jammy - test-install",
229-
image="jammy",
230-
env=dict(
231-
TEST_INSTALL="t",
232-
),
233-
args="--with-flux-security --enable-caliper",
234-
docker_tag=True,
235-
)
236-
237-
# Debian: TEST_INSTALL
238-
matrix.add_build(
239-
name="bookworm - test-install",
240-
image="bookworm",
241-
env=dict(
242-
TEST_INSTALL="t",
243-
),
244-
platform="linux/amd64",
245-
args="--with-flux-security --enable-caliper",
246-
docker_tag=True,
247-
)
248-
249-
# el9: TEST_INSTALL
250-
matrix.add_build(
251-
name="el9 - test-install",
252-
image="el9",
253-
env=dict(
254-
TEST_INSTALL="t",
255-
),
256-
platform="linux/amd64",
257-
args="--with-flux-security --enable-caliper",
258-
docker_tag=True,
259-
)
260-
261-
# Ubuntu 20.04: py3.8
262-
matrix.add_build(
263-
name="focal - py3.8",
264-
image="focal",
265-
env=dict(PYTHON_VERSION="3.8"),
266-
docker_tag=True,
267-
)
268-
269300
# RHEL8 clone
270301
matrix.add_build(
271302
name="el8 - ascii",
@@ -285,35 +316,6 @@ def __str__(self):
285316
args="--with-flux-security --enable-caliper",
286317
)
287318

288-
# Fedora 40
289-
matrix.add_build(
290-
name="fedora40 - gcc-14",
291-
image="fedora40",
292-
args=(
293-
"--prefix=/usr"
294-
" --sysconfdir=/etc"
295-
" --with-systemdsystemunitdir=/etc/systemd/system"
296-
" --localstatedir=/var"
297-
" --with-flux-security"
298-
" --enable-caliper"
299-
),
300-
platform="linux/amd64",
301-
docker_tag=True,
302-
)
303-
304-
matrix.add_build(
305-
name="alpine",
306-
image="alpine",
307-
args=(
308-
"--prefix=/usr"
309-
" --sysconfdir=/etc"
310-
" --with-systemdsystemunitdir=/etc/systemd/system"
311-
" --localstatedir=/var"
312-
" --with-flux-security"
313-
),
314-
docker_tag=True,
315-
)
316-
317319
# inception
318320
matrix.add_build(
319321
name="inception",

0 commit comments

Comments
 (0)