Skip to content

Conversation

@louis-bompart
Copy link
Collaborator

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a cold-start build cache optimization for the main branch using GitHub Actions cache API. When PRs are merged (via merge_group events), a new job saves the turbo build cache to a static key that can be restored by subsequent builds, improving cold-start performance when the artifact-based cache from previous runs is unavailable.

Key changes:

  • Added update-build-cold-cache job that runs on merge_group to save turbo cache to GitHub Actions cache with a static key
  • Modified setup action to restore the cold cache when load-cache != 'true', falling back to the saved cache from main

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
.github/workflows/ci.yml Adds new update-build-cold-cache job that runs on merge_group events to save turbo cache
.github/actions/setup/action.yml Adds cold cache restoration step and updates documentation for load-cache parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if: inputs.load-cache != 'true'
with:
path: .turbo
key: turbo-cache
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The cache restore action at lines 59-63 will only execute when load-cache != 'true', meaning it tries to restore the cold cache when the current run's cache shouldn't be loaded. However, this cache restoration has no fallback mechanism if the cache doesn't exist yet. Since the new job update-build-cold-cache only runs on merge_group events, the cache may not exist for PR builds, causing the restore to silently fail.

Additionally, the cache key turbo-cache is static and has no versioning or invalidation mechanism. This means if the cache becomes corrupted or outdated, there's no way to bust it without manual intervention.

Suggested change
key: turbo-cache
key: turbo-cache-v1-${{ runner.os }}-${{ inputs.cache-prefix }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
turbo-cache-v1-${{ runner.os }}-${{ inputs.cache-prefix }}-
turbo-cache-v1-${{ runner.os }}-
turbo-cache-v1-

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree

Comment on lines +943 to +960
update-build-cold-cache:
name: "Update build cold cache (main)"
if: ${{ !cancelled() && needs.is-valid.result == 'success' && github.event_name == 'merge_group' }}
needs:
- is-valid
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: ./.github/actions/setup
- name: Update build cold cache
uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5
with:
path: .turbo
key: turbo-cache
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The new job builds the entire project (via the setup action which runs pnpm run build by default) just to save the turbo cache. This is inefficient because it duplicates the work already done by other jobs like build and build-cdn. Consider adding a dependency on one of these existing build jobs and using their artifacts instead of rebuilding from scratch, or at minimum add skip-build: "true" if only the cache artifact needs to be saved.

Copilot uses AI. Check for mistakes.
default: 'false'
load-cache:
description: 'Whether to load the turbo cache. Note: pnpm is cached via setup-node.'
description: 'Whether to load the turbo cache from the current run. Note: pnpm is cached via setup-node. If not true, loading the last cache from main will be attempted'
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The description is misleading. It states "If not true, loading the last cache from main will be attempted", but the implementation attempts to restore the cache regardless of whether it's from main or not. The cache key turbo-cache is branch-agnostic and will restore whatever was last saved with that key, which could be from any branch if the cache saving logic isn't properly scoped to main branches only.

Suggested change
description: 'Whether to load the turbo cache from the current run. Note: pnpm is cached via setup-node. If not true, loading the last cache from main will be attempted'
description: 'Whether to load the turbo cache from the current run. Note: pnpm is cached via setup-node. If not true, the last available turbo cache (from any branch) will be restored, as the cache key is branch-agnostic.'

Copilot uses AI. Check for mistakes.
if: inputs.load-cache != 'true'
with:
path: .turbo
key: turbo-cache
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree

@louis-bompart louis-bompart marked this pull request as draft December 19, 2025 20:48
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.

4 participants