Skip to content

ci: cache and verify Zig tarball, harden against truncated downloads#550

Merged
srperens merged 3 commits intomainfrom
fix/ci-cache-zig
May 6, 2026
Merged

ci: cache and verify Zig tarball, harden against truncated downloads#550
srperens merged 3 commits intomainfrom
fix/ci-cache-zig

Conversation

@srperens
Copy link
Copy Markdown
Collaborator

@srperens srperens commented May 6, 2026

Summary

  • CI has been failing intermittently with tar: Unexpected EOF in archive during the "Install Zig and cargo-zigbuild" step. Both main and PR branches affected. Root cause: curl ... | tar with no retries — when ziglang.org connection is truncated, tar errors out and the step fails.
  • Cache the Zig tarball at /tmp/zig.tar.xz keyed by version+arch via actions/cache, so repeated runs don't hit ziglang.org at all.
  • On cache miss or SHA256 mismatch, download with curl --fail --retry 5 --retry-all-errors --retry-delay 3 to a temp file, verify SHA256, then extract.
  • Apply the same retry+SHA256 hardening to Dockerfile (used by docker-publish workflows) and scripts/cross-compile/setup-zig-cross.sh (developer setup).

Files changed

  • .github/workflows/ci.yml — both linux build jobs (x86_64 + aarch64)
  • .github/workflows/release.yml — linux release matrix
  • Dockerfile — root, used by docker-publish
  • scripts/cross-compile/setup-zig-cross.sh — local dev setup

Zig 0.13.0 SHA256s pinned from upstream https://ziglang.org/download/index.json:

  • linux-x86_64: d45312e61ebcc48032b77bc4cf7fd6915c11fa16e4aad116b66c9468211230ea
  • linux-aarch64: 041ac42323837eb5624068acd8b00cd5777dac4cf91179e8dad7a7e90dd0c556

Test plan

  • CI on this PR passes the "Install Zig and cargo-zigbuild" step
  • On a re-run, the cache is hit (look for "Cache hit" in the cache step) and download is skipped
  • Docker image build still works locally if anyone tests it
  • bash -n scripts/cross-compile/setup-zig-cross.sh clean (verified)

🤖 Generated with Claude Code

Per Enstedt and others added 3 commits May 6, 2026 15:11
Recent CI runs on main and PR branches have been failing intermittently
with `tar: Unexpected EOF in archive` during the "Install Zig and
cargo-zigbuild" step. The root cause is `curl | tar` with no retries —
when the connection to ziglang.org gets truncated, tar errors out and
the whole step fails.

Make the Zig install robust:
- Cache the tarball at /tmp/zig.tar.xz keyed by version+arch via
  actions/cache, so repeated runs don't hit ziglang.org at all.
- On cache miss, download with `curl --fail --retry 5 --retry-all-errors
  --retry-delay 3` to a temp file, verify SHA256, then extract.
- If a cached tarball fails the SHA256 check (extremely rare but
  possible on a bad cache hit), redownload.

Applies to both ci.yml (x86_64 and aarch64 build jobs) and release.yml
(linux build matrix).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Apply the same retry+checksum hardening to the two remaining places
that download the Zig tarball without retries or verification:

- Dockerfile (used by docker-publish workflow): add curl --fail
  --retry 5 --retry-all-errors --retry-delay 3 plus SHA256 verify
- scripts/cross-compile/setup-zig-cross.sh (developer setup):
  same hardening so local cross-compile setup is robust

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…inary

Two changes that together cut the install step from ~25 min to ~10 sec
(plus the cargo-zigbuild compile, which can take ~10 min from source):

1. Zig tarball: switch primary URL to the community mirror
   `zigmirror.hryx.net` (verified 200 OK, full content-length, no
   throttling), fall back to ziglang.org on failure. The upstream URL
   was throttling GitHub Actions runners to single-digit kbps,
   causing 25 min downloads.

2. cargo-zigbuild: replace `cargo install --locked cargo-zigbuild`
   (compiles from source on every run) with download of the prebuilt
   binary from cargo-zigbuild's own GitHub Releases (~1.2 MB, version
   0.22.3 pinned). SHA256 verified.

Both downloads are cached and SHA256-verified; cache miss or checksum
mismatch triggers redownload.

Apply to ci.yml (x86_64 + aarch64), release.yml (linux matrix),
Dockerfile (used by docker-publish), and the cross-compile dev setup
script.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@srperens srperens merged commit 2ed92b6 into main May 6, 2026
7 checks passed
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