fix: refactor cache-checkout to use actions/cache@v4 with fallback (#26702)
This fixes cache propagation delay issues with Blacksmith's distributed cache. The previous implementation used separate save/restore actions with fail-on-cache-miss: true, which failed when the cache wasn't immediately available after being saved by the Prepare job. The new implementation uses actions/cache@v4 (combined save/restore) with a fallback to do the checkout if cache miss, matching the pattern used by cache-build and cache-db which don't have this issue. Changes: - Refactored cache-checkout action to use actions/cache@v4 - Added fallback checkout step when cache miss occurs - Removed mode input (no longer needed) - Updated all workflows to use the simplified cache-checkout action Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin AI
parent
eecf9e1ab9
commit
bf4cdf6245
@@ -1,17 +1,11 @@
|
||||
name: Cache Git Checkout
|
||||
description: "Save or restore git checkout from cache to speed up CI workflows"
|
||||
inputs:
|
||||
mode:
|
||||
description: "Mode of operation: 'save' to cache the checkout, 'restore' to restore from cache"
|
||||
required: true
|
||||
|
||||
description: "Cache or restore git checkout to speed up CI workflows"
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Restore git checkout from cache
|
||||
if: ${{ inputs.mode == 'restore' }}
|
||||
uses: actions/cache/restore@v4
|
||||
id: cache-restore
|
||||
- name: Cache git checkout
|
||||
uses: actions/cache@v4
|
||||
id: cache-checkout
|
||||
with:
|
||||
path: |
|
||||
.
|
||||
@@ -19,15 +13,14 @@ runs:
|
||||
!node_modules
|
||||
!**/node_modules
|
||||
key: git-checkout-${{ github.head_ref || github.ref_name }}-${{ github.event.pull_request.head.sha || github.sha }}
|
||||
fail-on-cache-miss: true
|
||||
|
||||
- name: Save git checkout to cache
|
||||
if: ${{ inputs.mode == 'save' }}
|
||||
uses: actions/cache/save@v4
|
||||
- name: Checkout PR code (on cache miss)
|
||||
if: steps.cache-checkout.outputs.cache-hit != 'true'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: |
|
||||
.
|
||||
!.git
|
||||
!node_modules
|
||||
!**/node_modules
|
||||
key: git-checkout-${{ github.head_ref || github.ref_name }}-${{ github.event.pull_request.head.sha || github.sha }}
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 2
|
||||
sparse-checkout-cone-mode: false
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/example-apps/
|
||||
!**/*.mp4
|
||||
|
||||
@@ -68,8 +68,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- uses: ./.github/actions/cache-db
|
||||
- name: Cache API v1 production build
|
||||
|
||||
@@ -38,8 +38,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- name: Generate Prisma schemas
|
||||
working-directory: apps/api/v2
|
||||
|
||||
@@ -15,8 +15,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- run: yarn prisma generate
|
||||
- name: Run API v2 unit tests
|
||||
|
||||
@@ -15,8 +15,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- name: Cache atoms production build
|
||||
uses: actions/cache@v4
|
||||
|
||||
@@ -37,8 +37,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
|
||||
- name: Generate Swagger
|
||||
|
||||
@@ -15,8 +15,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- name: Show info
|
||||
run: node -e "console.log(require('v8').getHeapStatistics())"
|
||||
|
||||
@@ -20,8 +20,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
|
||||
@@ -15,8 +15,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- name: Cache Docs build
|
||||
uses: actions/cache@v4
|
||||
id: cache-docs-build
|
||||
|
||||
@@ -77,8 +77,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- uses: ./.github/actions/cache-db
|
||||
- name: Build platform packages with Turbo
|
||||
|
||||
@@ -84,8 +84,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- uses: ./.github/actions/yarn-playwright-install
|
||||
- run: yarn prisma generate
|
||||
|
||||
@@ -76,8 +76,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- uses: ./.github/actions/yarn-playwright-install
|
||||
- run: yarn prisma generate
|
||||
|
||||
@@ -84,8 +84,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- uses: ./.github/actions/yarn-playwright-install
|
||||
- run: yarn prisma generate
|
||||
|
||||
@@ -85,8 +85,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- uses: ./.github/actions/yarn-playwright-install
|
||||
- run: yarn prisma generate
|
||||
|
||||
@@ -82,8 +82,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- run: yarn prisma generate
|
||||
- uses: ./.github/actions/cache-db
|
||||
|
||||
@@ -13,8 +13,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- name: Run Lint
|
||||
run: yarn lint
|
||||
|
||||
@@ -174,11 +174,7 @@ jobs:
|
||||
db-cache-hit: ${{ steps.cache-db-check.outputs.cache-hit }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/dangerous-git-checkout
|
||||
- name: Cache git checkout
|
||||
uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: save
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
- name: Generate DB cache key
|
||||
id: cache-db-key
|
||||
uses: ./.github/actions/cache-db-key
|
||||
|
||||
@@ -46,8 +46,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- run: yarn prisma generate
|
||||
- name: Generate cache key
|
||||
|
||||
@@ -50,8 +50,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
if: inputs.DB_CACHE_HIT != 'true'
|
||||
- run: yarn prisma generate
|
||||
|
||||
@@ -15,8 +15,6 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: .github
|
||||
- uses: ./.github/actions/cache-checkout
|
||||
with:
|
||||
mode: restore
|
||||
- uses: ./.github/actions/yarn-install
|
||||
- run: yarn prisma generate
|
||||
- run: yarn test -- --no-isolate
|
||||
|
||||
Reference in New Issue
Block a user