Skip to content

Conversation

@ghostwriternr
Copy link
Member

Fixes cache incompatibility between single-arch PR builds and multi-arch release builds.

Changes:

  • PR workflow: Explicit amd64 platform with updated cache scopes
  • Release workflow: Two-step build (single-arch cache + multi-arch publish)
  • Pkg-pr-new workflow: Added single-arch cache fallbacks

Add explicit single-arch platform declaration and update cache scopes
to use -amd64 suffix. This ensures PR builds can reuse cache from
release workflow's single-arch build step.

Changes:
- Add platforms: linux/amd64 to build-push-action
- Update cache-from scopes: pr-{number}-amd64, release-amd64
- Update cache-to scope: pr-{number}-amd64

This resolves the 0 CACHED steps issue where single-arch PR builds
could not reuse multi-arch release cache layers.
Add dedicated single-arch (amd64) cache build step before multi-arch
builds to enable PR workflows to reuse release cache. Both beta and
stable release jobs now use two-step pattern:
1. Build single-arch for cache (push: false)
2. Build multi-arch for publishing (push: true)

Changes:
- Add single-arch cache step to publish-prerelease job
- Add single-arch cache step to publish-release job
- Update both multi-arch steps to import from release-amd64 cache

This enables cache cross-pollination: release builds populate
release-amd64 cache, which PR builds can then reuse.
Add single-arch cache fallbacks to preview builds to enable reuse
of PR and release single-arch caches. Multi-arch preview builds can
now import layers from:
1. Own preview cache (warm subsequent builds)
2. PR single-arch cache (reuse from pullrequest.yml)
3. Release single-arch cache (reuse from release.yml)
4. Release multi-arch cache (fallback)

This reduces cold cache build times for preview packages from 10+ min
to 2-3 min after first PR build completes.
@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2025

⚠️ No Changeset found

Latest commit: ec3df02

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@claude
Copy link
Contributor

claude bot commented Oct 30, 2025

Claude Code Review

Status: Looks good

This PR fixes Docker cache layer incompatibility between single-arch PR builds and multi-arch release builds. The approach is sound:

What's Good

  • Two-step build pattern in release workflow: single-arch cache build (amd64) followed by multi-arch publish enables PR builds to reuse layers
  • Consistent cache scoping: -amd64 suffix on cache scopes clearly indicates architecture
  • Cascading fallbacks in pkg-pr-new workflow provide good cache reuse strategy
  • Commit messages follow project conventions (imperative mood, explain what/why)

Minor Observations

  1. Duplication: The single-arch cache build step is identical in both publish-prerelease and publish-release jobs. Consider extracting to a reusable workflow step if GitHub Actions supports it, though this duplication is acceptable for workflow clarity.

  2. Cache pollution: Multiple workflows writing to release-amd64 scope (both beta and stable releases). This should work fine as they use the same Dockerfile/version, but worth monitoring if stale layers accumulate.

  3. Documentation: The inline comments are helpful, but consider updating CLAUDE.md's Docker section to mention the single-arch cache strategy for future maintainers.

These are minor points - the PR is ready to merge as-is.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 30, 2025

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/sandbox-sdk/@cloudflare/sandbox@178

commit: ec3df02

@github-actions
Copy link
Contributor

🐳 Docker Image Published

FROM cloudflare/sandbox:0.0.0-pr-178-d72d351

Version: 0.0.0-pr-178-d72d351

You can use this Docker image with the preview package from this PR.

@ghostwriternr ghostwriternr merged commit 87a8d20 into main Oct 30, 2025
8 of 9 checks passed
@ghostwriternr ghostwriternr deleted the fix/docker-cache-architecture-mismatch branch October 30, 2025 15:44
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