Skip to content

fix: remove ARG TARGETARCH default in Dockerfile.test-tools#126

Merged
ycpss91255 merged 1 commit into
mainfrom
fix/test-tools-targetarch-default
Apr 24, 2026
Merged

fix: remove ARG TARGETARCH default in Dockerfile.test-tools#126
ycpss91255 merged 1 commit into
mainfrom
fix/test-tools-targetarch-default

Conversation

@ycpss91255
Copy link
Copy Markdown
Contributor

Summary

Critical latent bug shipped since multi-arch matrix landed (v0.9.10+). The arm64 variant of every GHCR test-tools:* image contains x86_64 shellcheck / hadolint binaries, silently breaking downstream arm64 CI at first consumption.

Root cause

Dockerfile.test-tools declares ARG TARGETARCH=amd64 with a default. Per moby/buildkit#3403, a default value shadows BuildKit's per-platform auto-inject. Result: multi-arch builds of this file run the case "${TARGETARCH}" in ... branch with TARGETARCH=amd64 regardless of the actual build platform → x86_64 binary URL used for both amd64 and arm64 manifests.

Confirmation

Anonymous pull of ghcr.io/ycpss91255-docker/test-tools:v0.9.13 arm64 variant:

$ docker create --platform linux/arm64 ghcr.io/.../test-tools:v0.9.13
$ docker cp ...:/usr/local/bin/shellcheck /tmp/sc-arm64
$ file /tmp/sc-arm64
/tmp/sc-arm64: ELF 64-bit LSB executable, x86-64, ...

ros1_bridge PR #27 enabled arm64 matrix and hit:

shellcheck: Exec format error

Fix

-ARG TARGETARCH=amd64
+ARG TARGETARCH

Regression test in template_spec.bats asserts the ARG has no default (^ARG TARGETARCH= must not match) while the bare declaration (^ARG TARGETARCH$) still does. 674 → 675.

Release plan (post-merge)

  1. Tag v0.10.0-rc2 from main after this PR merges.
  2. release-test-tools.yaml auto-reissues ghcr.io/.../test-tools:v0.10.0-rc2 + :latest with per-arch-correct binaries.
  3. Downstream ros1_bridge PR docs: remove i18n for TEST.md and CHANGELOG.md #27 bumps main.yaml @v0.9.13@v0.10.0-rc2, arm64 matrix goes green.
  4. If validation passes, promote rc2 → v0.10.0.

Impact on existing tags

v0.9.13, v0.10.0-rc1 GHCR images stay broken on arm64. Repos currently pinned to those tags that only build amd64 are unaffected. Repos with arm64 matrix enabled must move to @v0.10.0-rc2+ — or the template bumps its minimum supported tag if we want to deprecate the broken ones.

Test plan

  • make -f Makefile.ci test local — 675/675 pass
  • Self-test CI green on this PR
  • Post-tag: inspect arm64 variant of :v0.10.0-rc2, confirm shellcheck is aarch64:
    docker create --platform linux/arm64 ghcr.io/.../test-tools:v0.10.0-rc2
    docker cp ...:/usr/local/bin/shellcheck /tmp/sc-arm64
    file /tmp/sc-arm64   # expect: aarch64
    
  • Post-tag: ros1_bridge PR docs: remove i18n for TEST.md and CHANGELOG.md #27 @v0.10.0-rc2, arm64 CI shard green.

`ARG TARGETARCH=amd64` (with a default) silently shadows BuildKit's
per-platform auto-inject (moby/buildkit#3403). Consequence: every
multi-arch build of this Dockerfile — including every `:vX.Y.Z` and
`:latest` pushed to GHCR by release-test-tools.yaml since v0.9.10 —
ran its `case` branch with TARGETARCH=amd64 *regardless of target
platform*. The arm64 variant therefore shipped x86_64 shellcheck
and hadolint binaries; downstream CI on arm64 runners fails at
`shellcheck: Exec format error` the first time it consumes
test-tools on arm64 (caught by ros1_bridge PR #27 enabling the arm64
matrix).

Fix: drop the default. `ARG TARGETARCH` (bare declaration) lets
BuildKit auto-inject take effect. Outside BuildKit, pass
`--build-arg TARGETARCH=<arch>` explicitly — the `case` default
branch already fails loud on empty TARGETARCH so nobody silently
ships the wrong binaries.

Regression test in template_spec.bats asserts the ARG has no
default, plus the existing bare-declaration test continues to
guarantee consumption is still wired. 674 → 675.

Re-release plan: tag v0.10.0-rc2 after merge. release-test-tools.yaml
re-runs on tag push and reissues ghcr.io/.../test-tools:v0.10.0-rc2
+ :latest with correct per-arch binaries. Downstream repos on the
broken v0.9.13 / v0.10.0-rc1 tags stay broken on arm64 until they
bump @tag.
@ycpss91255 ycpss91255 merged commit ef0883a into main Apr 24, 2026
3 checks passed
@ycpss91255 ycpss91255 deleted the fix/test-tools-targetarch-default branch April 24, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant