Skip to content

Make GHCR cache exports and consumer pushes conditional for external PRs#3423

Merged
joshlf merged 1 commit into
mainfrom
codex/investigate-build-failures-on-pull-request
May 31, 2026
Merged

Make GHCR cache exports and consumer pushes conditional for external PRs#3423
joshlf merged 1 commit into
mainfrom
codex/investigate-build-failures-on-pull-request

Conversation

@joshlf
Copy link
Copy Markdown
Member

@joshlf joshlf commented May 31, 2026

Motivation

  • External pull requests run with read-only package permissions on GitHub, which causes GHCR cache exports and image pushes to fail when workflows attempt to write to the registry.
  • The change avoids noisy or failing runs for untrusted external PRs by skipping steps that require GHCR write access while preserving behavior for trusted runs.

Description

  • Replace unconditional cache-to arguments in Docker build steps with conditional expressions so cache-to is omitted for external pull requests in .github/workflows/anneal.yml and .github/workflows/ci.yml.
  • Add if: guards to the Docker push step and to consumer jobs (anneal_tests and verify_examples) in anneal.yml so those steps are skipped for external pull requests that cannot push or pull GHCR writes.
  • Add explanatory comments around the new conditionals and keep other build settings unchanged to preserve caching behavior for trusted runs.

Testing

  • No automated tests were executed as part of this rollout because the changes are GitHub Actions workflow configuration only and will be validated by subsequent GitHub Actions runs.

Codex Task

### Motivation
- External fork PRs were failing CI at Docker build/cache steps because the runner `GITHUB_TOKEN` for forks does not have permission to write GHCR packages or cache entries.

### Description
- In `.github/workflows/ci.yml` conditionally disable `cache-to` exports to GHCR for external pull requests while preserving cache exports for same-repo runs, pushes, merge groups, and workflow dispatches.
- In `.github/workflows/anneal.yml` conditionally disable `cache-to` and guard the `Build and push Docker image` step so image push/cache writes are only attempted when the run is allowed to write to GHCR.
- In `.github/workflows/anneal.yml` add `if:` guards on Anneal consumer jobs (`anneal_tests` and `verify_examples`) so those consumer jobs are skipped for external fork PRs that cannot publish the GHCR image they would consume.

### Testing
- Ran `./ci/check_actions.sh` and it completed successfully.
- Ran `git diff --check` and it produced no issues.
- Ran `CARGO_ZEROCOPY_AUTO_INSTALL_TOOLCHAIN=1 ./githooks/pre-push` to exercise the repo hooks in a non-interactive way and it completed successfully (the initial pre-push without auto-install hit local tooling prompts).
@joshlf joshlf requested a review from jswrenn May 31, 2026 17:40
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.85%. Comparing base (f70e422) to head (76e1c7e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3423   +/-   ##
=======================================
  Coverage   91.85%   91.85%           
=======================================
  Files          20       20           
  Lines        6093     6093           
=======================================
  Hits         5597     5597           
  Misses        496      496           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joshlf joshlf added this pull request to the merge queue May 31, 2026
Merged via the queue into main with commit cf7cf61 May 31, 2026
139 checks passed
@joshlf joshlf deleted the codex/investigate-build-failures-on-pull-request branch May 31, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants