Skip to content

Commit 2b3ef76

Browse files
Rolv-Apnesethcgwalters
authored andcommitted
justfile: forward build settings to nested recipes
`just` cmdline overrides apply to a single invocation, with only environment variables propagating to nested invocations. test-tmt, for example, calls nested recipes for _build-upgrade-image and test-tmt-nobuild, so both ran with the default settings. `just test-composefs systemd ext4 uki sealed` then built the main image as a sealed UKI but the upgrade image as bls and unsealed (default). The upgrade image kept a stale UKI whose embedded composefs digest no longer matched its rootfs, and upgrades to it failed. CI never hit this because it exports the BOOTC_* env vars, which are propagated. Let's just forward settings explicitly when we have nested recipes to avoid this issue. Achieved with a new variable holding the current build settings as cmdline overrides, which is then passed to every recipe which invokes another. Recipes which need to override a setting (e.g. variant=composefs) just pass it after this variable and the last override wins. Assited-by: llm Signed-off-by: Rolv Apneseth <rolv.apneseth@gmail.com>
1 parent bb6c8a4 commit 2b3ef76

1 file changed

Lines changed: 29 additions & 10 deletions

File tree

‎Justfile‎

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ no_auto_local_deps := env("BOOTC_no_auto_local_deps", "")
6262
nocache := env("BOOTC_nocache", "")
6363
_nocache_arg := if nocache != "" { "--no-cache" } else { "" }
6464
_baseconfigs_env := if baseconfigs != "" { "--env=BOOTC_baseconfigs=" + baseconfigs } else { "" }
65+
# Build settings as `just` command line overrides, for forwarding to nested
66+
# `just` invocations. Command line overrides only apply to a single
67+
# invocation, so recipes which nest other recipes must pass
68+
# the current settings along themselves. Exported BOOTC_* environment
69+
# variables reach nested invocations on their own, so CI does not depend on
70+
# this. Recipes which force a setting (e.g. variant=composefs) pass it after
71+
# these, and the last override wins.
72+
# https://just.systems/man/en/dependencies.html#running-recipes-in-the-middle-of-a-recipe
73+
_forward_settings := "base_img=" + base_img + \
74+
" base=" + base + \
75+
" variant=" + variant + \
76+
" bootloader=" + bootloader + \
77+
" filesystem=" + filesystem + \
78+
" boot_type=" + boot_type + \
79+
" seal_state=" + seal_state + \
80+
' baseconfigs="' + baseconfigs + '"' + \
81+
" erofs_version=" + erofs_version
6582
testimage_label := "bootc.testimage=1"
6683
# Pinned to ubi9/podman 9.8-1793032728: the 9.8-1793203936 build that
6784
# replaced it has no sigstore signature for the registry.access.redhat.com
@@ -189,13 +206,15 @@ list-variants:
189206
# Build a sealed composefs image (alias for variant=composefs-sealeduki-sdboot)
190207
[group('core')]
191208
build-sealed:
192-
@just --justfile {{justfile()}} variant=composefs bootloader=systemd boot_type=uki seal_state=sealed build
209+
@just --justfile {{justfile()}} {{_forward_settings}} variant=composefs bootloader=systemd boot_type=uki seal_state=sealed build
193210

194211
# Run tmt integration tests in VMs (e.g. `just test-tmt readonly`)
195212
[group('core')]
196213
test-tmt *ARGS: build
197-
@just _build-upgrade-image
198-
@just test-tmt-nobuild {{ARGS}}
214+
# Nested invocations do not inherit command line overrides, so the
215+
# current settings are passed along explicitly (see _forward_settings).
216+
@just {{_forward_settings}} _build-upgrade-image
217+
@just {{_forward_settings}} test-tmt-nobuild {{ARGS}}
199218

200219
[group('testing')]
201220
build-ukiboot-test-image: build
@@ -240,7 +259,7 @@ test-composefs bootloader filesystem boot_type seal_state *ARGS:
240259
exit 1; \
241260
fi
242261

243-
just variant=composefs \
262+
just {{_forward_settings}} variant=composefs \
244263
bootloader={{bootloader}} \
245264
filesystem={{filesystem}} \
246265
boot_type={{boot_type}} \
@@ -316,11 +335,11 @@ test-tmt-nobuild *ARGS:
316335
cargo xtask run-tmt --env=BOOTC_variant={{variant}} --env=BOOTC_erofs_version={{erofs_version}} {{_baseconfigs_env}} --upgrade-image={{upgrade_img}} {{base_img}} {{ARGS}}
317336

318337
# Run readonly tests with a baseconfig baked into the image at build time.
319-
# Requires composefs variant. Example: just variant=composefs test-tmt-baseconfig root-transient
338+
# Requires composefs variant. Example: just test-tmt-baseconfig root-transient
320339
[group('testing')]
321340
test-tmt-baseconfig baseconfig *ARGS:
322-
just variant=composefs baseconfigs={{baseconfig}} build
323-
just variant=composefs baseconfigs={{baseconfig}} _build-upgrade-image
341+
just {{_forward_settings}} variant=composefs baseconfigs={{baseconfig}} build
342+
just {{_forward_settings}} variant=composefs baseconfigs={{baseconfig}} _build-upgrade-image
324343
cargo xtask run-tmt \
325344
--env=BOOTC_variant=composefs \
326345
--env=BOOTC_erofs_version={{erofs_version}} \
@@ -334,9 +353,9 @@ test-tmt-baseconfig baseconfig *ARGS:
334353
# Run readonly tests for all standard baseconfigs
335354
[group('testing')]
336355
test-baseconfigs *ARGS:
337-
just test-tmt-baseconfig etc-transient {{ARGS}}
338-
just test-tmt-baseconfig root-transient {{ARGS}}
339-
just test-tmt-baseconfig var-volatile {{ARGS}}
356+
just {{_forward_settings}} test-tmt-baseconfig etc-transient {{ARGS}}
357+
just {{_forward_settings}} test-tmt-baseconfig root-transient {{ARGS}}
358+
just {{_forward_settings}} test-tmt-baseconfig var-volatile {{ARGS}}
340359

341360
# Run tmt tests on Fedora CoreOS
342361
[group('testing')]

0 commit comments

Comments
 (0)