Skip to content

Commit df0a75d

Browse files
authored
ci: cache propagation workaround (#15469)
# Overview Addresses intermittent CI failures caused by [GitHub Actions cache propagation delays](actions/cache#1710). Jobs were failing with "command not found" errors because the build cache wasn't available yet when downstream jobs started. ## Key Changes - **Added `fail-on-cache-miss: true` to all build cache restores** - Makes cache failures explicit rather than silently continuing without `node_modules` - **Added `cache-propagation-delay` option to setup action** - New input with default of `0` seconds - Set to `120` seconds in all jobs that restore the build cache - **Standardized GitHub Action versions in matrix jobs** - `actions/checkout@v4` → `@v5` - `actions/setup-node@v4` → `@v6` ## References / Links - [GitHub Actions Cache Issue #1710: Cache indexing lag / API propagation delay](actions/cache#1710)
1 parent 9bd5123 commit df0a75d

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

.github/actions/setup/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ inputs:
1515
default: 'true'
1616
pnpm-install-cache-key:
1717
description: The cache key override for the pnpm install cache
18+
cache-propagation-delay:
19+
description: Seconds to wait after setup for cache propagation (workaround for https://github.com/actions/cache/issues/1710)
20+
default: '0'
1821

1922
outputs:
2023
pnpm-install-cache-key:
@@ -108,3 +111,10 @@ runs:
108111
echo "pnpm-install-cache-key=${{ env.PNPM_INSTALL_CACHE_KEY }}" >> $GITHUB_OUTPUT
109112
shell: bash
110113
id: compute-output
114+
115+
- name: Wait for cache propagation
116+
if: ${{ inputs.cache-propagation-delay != '0' }}
117+
shell: bash
118+
run: |
119+
echo "Waiting ${{ inputs.cache-propagation-delay }}s for cache propagation..."
120+
sleep ${{ inputs.cache-propagation-delay }}

.github/workflows/main.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,14 @@ jobs:
105105
with:
106106
pnpm-run-install: false
107107
pnpm-restore-cache: false # Full build is restored below
108+
cache-propagation-delay: 120 # https://github.com/actions/cache/issues/1710
108109

109110
- name: Restore build
110111
uses: actions/cache@v4
111112
with:
112113
path: ./*
113114
key: ${{ github.sha }}
115+
fail-on-cache-miss: true
114116

115117
- name: Unit Tests
116118
run: pnpm test:unit
@@ -129,12 +131,14 @@ jobs:
129131
with:
130132
pnpm-run-install: false
131133
pnpm-restore-cache: false # Full build is restored below
134+
cache-propagation-delay: 120 # https://github.com/actions/cache/issues/1710
132135

133136
- name: Restore build
134137
uses: actions/cache@v4
135138
with:
136139
path: ./*
137140
key: ${{ github.sha }}
141+
fail-on-cache-miss: true
138142

139143
- name: Types Tests
140144
run: pnpm test:types --target '>=5.7'
@@ -150,13 +154,13 @@ jobs:
150154
outputs:
151155
matrix: ${{ steps.generate.outputs.matrix }}
152156
steps:
153-
- uses: actions/checkout@v4
157+
- uses: actions/checkout@v5
154158
with:
155159
sparse-checkout: |
156160
.github/workflows
157161
.tool-versions
158162
159-
- uses: actions/setup-node@v4
163+
- uses: actions/setup-node@v6
160164
with:
161165
node-version-file: .tool-versions
162166

@@ -197,12 +201,14 @@ jobs:
197201
with:
198202
pnpm-run-install: false
199203
pnpm-restore-cache: false # Full build is restored below
204+
cache-propagation-delay: 120 # https://github.com/actions/cache/issues/1710
200205

201206
- name: Restore build
202207
uses: actions/cache@v4
203208
with:
204209
path: ./*
205210
key: ${{ github.sha }}
211+
fail-on-cache-miss: true
206212

207213
- name: Start LocalStack
208214
run: pnpm docker:start
@@ -235,13 +241,13 @@ jobs:
235241
outputs:
236242
matrix: ${{ steps.generate.outputs.matrix }}
237243
steps:
238-
- uses: actions/checkout@v4
244+
- uses: actions/checkout@v5
239245
with:
240246
sparse-checkout: |
241247
.github/workflows
242248
.tool-versions
243249
244-
- uses: actions/setup-node@v4
250+
- uses: actions/setup-node@v6
245251
with:
246252
node-version-file: .tool-versions
247253

@@ -264,12 +270,14 @@ jobs:
264270
with:
265271
pnpm-run-install: false
266272
pnpm-restore-cache: false
273+
cache-propagation-delay: 120 # https://github.com/actions/cache/issues/1710
267274

268275
- name: Restore build
269276
uses: actions/cache@v4
270277
with:
271278
path: ./*
272279
key: ${{ github.sha }}
280+
fail-on-cache-miss: true
273281

274282
- name: Prepare prod test environment
275283
run: pnpm prepare-run-test-against-prod:ci
@@ -302,12 +310,14 @@ jobs:
302310
with:
303311
pnpm-run-install: false
304312
pnpm-restore-cache: false # Full build is restored below
313+
cache-propagation-delay: 120 # https://github.com/actions/cache/issues/1710
305314

306315
- name: Restore build
307316
uses: actions/cache@v4
308317
with:
309318
path: ./*
310319
key: ${{ github.sha }}
320+
fail-on-cache-miss: true
311321

312322
- name: Restore prepared test environment
313323
uses: actions/cache/restore@v4
@@ -492,12 +502,14 @@ jobs:
492502
with:
493503
pnpm-run-install: false
494504
pnpm-restore-cache: false # Full build is restored below
505+
cache-propagation-delay: 120 # https://github.com/actions/cache/issues/1710
495506

496507
- name: Restore build
497508
uses: actions/cache@v4
498509
with:
499510
path: ./*
500511
key: ${{ github.sha }}
512+
fail-on-cache-miss: true
501513

502514
- name: Start LocalStack
503515
run: pnpm docker:start
@@ -592,17 +604,19 @@ jobs:
592604
with:
593605
pnpm-run-install: false
594606
pnpm-restore-cache: false # Full build is restored below
607+
cache-propagation-delay: 120 # https://github.com/actions/cache/issues/1710
595608

596609
- name: Restore build
597610
uses: actions/cache@v4
598611
with:
599612
path: ./*
600613
key: ${{ github.sha }}
614+
fail-on-cache-miss: true
601615

602616
- name: Start PostgreSQL
603617
uses: CasperWA/postgresql-action@v1.2
604618
with:
605-
postgresql version: "14" # See https://hub.docker.com/_/postgres for available versions
619+
postgresql version: '14' # See https://hub.docker.com/_/postgres for available versions
606620
postgresql db: ${{ env.POSTGRES_DB }}
607621
postgresql user: ${{ env.POSTGRES_USER }}
608622
postgresql password: ${{ env.POSTGRES_PASSWORD }}
@@ -690,12 +704,14 @@ jobs:
690704
with:
691705
pnpm-run-install: false
692706
pnpm-restore-cache: false # Full build is restored below
707+
cache-propagation-delay: 120 # https://github.com/actions/cache/issues/1710
693708

694709
- name: Restore build
695710
uses: actions/cache@v4
696711
with:
697712
path: ./*
698713
key: ${{ github.sha }}
714+
fail-on-cache-miss: true
699715

700716
- name: Generate Payload Types
701717
run: pnpm dev:generate-types fields
@@ -751,12 +767,14 @@ jobs:
751767
with:
752768
pnpm-run-install: false
753769
pnpm-restore-cache: false # Full build is restored below
770+
cache-propagation-delay: 120 # https://github.com/actions/cache/issues/1710
754771

755772
- name: Restore build
756773
uses: actions/cache@v4
757774
with:
758775
path: ./*
759776
key: ${{ github.sha }}
777+
fail-on-cache-miss: true
760778

761779
- run: pnpm run build:bundle-for-analysis # Esbuild packages that haven't already been built in the build step for the purpose of analyzing bundle size
762780
env:
@@ -767,4 +785,4 @@ jobs:
767785
if: github.event.pull_request.head.repo.fork == false
768786
uses: exoego/esbuild-bundle-analyzer@v1
769787
with:
770-
metafiles: "packages/payload/meta_index.json,packages/payload/meta_shared.json,packages/ui/meta_client.json,packages/ui/meta_shared.json,packages/next/meta_index.json,packages/richtext-lexical/meta_client.json"
788+
metafiles: 'packages/payload/meta_index.json,packages/payload/meta_shared.json,packages/ui/meta_client.json,packages/ui/meta_shared.json,packages/next/meta_index.json,packages/richtext-lexical/meta_client.json'

0 commit comments

Comments
 (0)