Skip to content

ci(image): stop exporting build cache from PR builds#540

Merged
joryirving merged 1 commit into
mainfrom
ci/no-cache-export-on-prs
Jul 2, 2026
Merged

ci(image): stop exporting build cache from PR builds#540
joryirving merged 1 commit into
mainfrom
ci/no-cache-export-on-prs

Conversation

@joryirving

Copy link
Copy Markdown
Contributor

Summary

  • PR builds no longer write the buildx cache (cache-to is now main/tag-only); they still read it.

Profiled the 405s v0.5.16 bump build: the mode=max cache export was 272s (72%) — it re-uploads every stage's layers (~1GB of node_modules) whenever package.json changes, i.e. every release-bump and Renovate PR. Actual work (npm ci ×2 + next build + prisma generate) is ~65s.

Verification

  • Not run — validated by this PR's own image build duration (expect ~100-130s instead of 5+ min on lockfile-touching PRs).

The mode=max cache export re-uploads every stage's layers (~1GB of
node_modules trees) to the GHA cache backend whenever package.json
changes — ~270s of every release-bump and Renovate PR build (72% of
the 405s worst case). PRs now only consume the cache; main and tag
builds keep it warm.

@its-saffron its-saffron Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Automated Review

Full PR review.

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic) — escalated (fast_low_confidence)

Recommendation: Approve

This PR reduces PR build times by stopping unnecessary cache exports. The change is correct, minimal, and consistent with existing workflow patterns.

Change Summary

Aspect Detail
File .github/workflows/image.yaml
Change Replace unconditional cache-to: type=gha,mode=max with a conditional that exports cache only on non-PR events
Logic `cache-to: ${{ github.event_name != 'pull_request' && 'type=gha,mode=max'

Verification

Logic correctness

  • PR events: github.event_name != 'pull_request'false, short-circuits to '' (no export) ✓
  • Push/tag events: github.event_name != 'pull_request'true, evaluates to 'type=gha,mode=max'

Behavior verified

  • cache-from: type=gha (line 69) is unchanged — PR builds still read the cache ✓
  • Only the write path is disabled for PRs ✓
  • Main/tag builds continue to read and write cache normally ✓

Consistency with existing patterns

The workflow already uses identical conditionals for push/load:

push: ${{ github.event_name != 'pull_request' }}
load: ${{ github.event_name == 'pull_request' }}

The cache-to change follows the same established pattern. ✓

Standards Compliance

Check Status
No secrets or credentials introduced
No database schema changes
Follows existing workflow conventions
CI checks pass (Lint, Typecheck, Build, Tests, Docker Build)
Comment explains the rationale clearly

CI Check Results

All checks completed successfully for commit e367961:

  • Lint: success
  • Typecheck: success
  • Build: success
  • Tests: success
  • Docker Build: success

Linked Issue Fit

No linked issues found in the PR body.

Performance Rationale (from PR body, verified against workflow)

The PR documents:

  • mode=max export was ~272s out of 405s total (72%) — verified: mode=max enables full layer export
  • Re-uploads ~1GB of node_modules on every package.json change — plausible for the node_modules layer
  • Expected improvement: ~100-130s instead of 5+ minutes

Findings

No issues identified. The change is a targeted CI optimization with low risk and clear benefit.

@joryirving joryirving merged commit 639aa56 into main Jul 2, 2026
6 checks passed
@joryirving joryirving deleted the ci/no-cache-export-on-prs branch July 2, 2026 03:17
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