Skip to content

CI: Build output caching + cross-workflow restore-cache action #19677

@chargome

Description

@chargome

Linear ticket: https://linear.app/getsentry/issue/JS-1880

Prerequisite for #19673, #19674, #19675, #19676.

Context

When test workflows are split into independent workflow files, they can no longer use actions/download-artifact to get build output (artifacts are scoped to the workflow run). This issue covers the caching infrastructure needed to share build output across workflows.

Tasks

1. Add actions/cache/save to job_build

After the existing actions/upload-artifact step in job_build, add:

- uses: actions/cache/save@v5
  with:
    key: build-output-${{ github.sha }}
    path: |
      dev-packages/*/build
      packages/*/build
      packages/*/lib
      packages/ember/*.d.ts
      packages/gatsby/*.d.ts

This runs alongside existing behavior. No jobs consume it yet. Validates that cache save works and fits within the 10GB repo cache budget.

2. Create cross-workflow restore-cache variant

The existing .github/actions/restore-cache/action.yml uses actions/download-artifact which only works within the same workflow run. Create a new composite action (e.g., .github/actions/restore-build/action.yml) that:

  1. Restores dependency cache via actions/cache/restore (same as today)
  2. Restores build output via actions/cache/restore with key build-output-{SHA}
  3. On cache miss: runs yarn build with Nx cache (warm from develop, ~2 min)
  4. Uploads build output via actions/upload-artifact for downstream jobs within the same workflow

3. Validate cache size budget

actions/cache has a 10GB per-repo limit. Current usage includes Nx cache, dependency cache, Playwright browsers, and E2E tarballs. Build output adds ~200-400MB per SHA. Verify this fits, monitor after rollout. GitHub evicts entries not accessed in 7 days, and cleanup-pr-caches.yml already handles PR cache cleanup.

Notes

  • GitHub cache is branch-scoped: feature branches can only read from their own branch + the base branch (develop). No cross-contamination between PRs.
  • The Nx-cached fallback build handles the race condition where a test workflow starts before the build workflow finishes saving the cache.
  • E2E tarballs already use this exact actions/cache pattern with key tarball-{SHA}, so this is a proven approach in this repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions