Skip to content

Commit 86de253

Browse files
authored
ci: 限制 iOS 内容缓存快照,停止按 PR 提交重复保存 (#648)
* ci: add read-only PR caches with trusted daily snapshots * ci: stop duplicating iOS content caches for every PR commit
1 parent d599ec2 commit 86de253

2 files changed

Lines changed: 50 additions & 17 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Bounded content-addressed E2E cache
2+
description: Restore shared content caches; only mainline core saves a daily snapshot.
3+
inputs:
4+
path:
5+
description: Content-addressed cache directory, never a built app.
6+
required: true
7+
scope:
8+
description: Cache schema/toolchain identity.
9+
required: true
10+
write:
11+
description: The core matrix leg may write on a trusted master push.
12+
default: 'false'
13+
runs:
14+
using: composite
15+
steps:
16+
- id: epoch
17+
shell: bash
18+
run: echo "day=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
19+
- name: Restore read-only snapshot
20+
if: "!(inputs.write == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/master' && github.job == 'e2e-ios')"
21+
uses: actions/cache/restore@v6
22+
with:
23+
path: ${{ inputs.path }}
24+
key: e2e-content-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.scope }}-${{ steps.epoch.outputs.day }}
25+
restore-keys: |
26+
e2e-content-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.scope }}-
27+
- name: Restore and save trusted daily snapshot
28+
if: inputs.write == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/master' && github.job == 'e2e-ios'
29+
uses: actions/cache@v6
30+
with:
31+
path: ${{ inputs.path }}
32+
key: e2e-content-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.scope }}-${{ steps.epoch.outputs.day }}
33+
restore-keys: |
34+
e2e-content-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.scope }}-

‎.github/workflows/e2e_ios.yml‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- '**'
77
paths:
88
- '.github/workflows/e2e_ios.yml'
9+
- '.github/actions/e2e-cache/**'
910
- '.gitmodules'
1011
- 'package.json'
1112
- 'bun.lock'
@@ -23,6 +24,7 @@ on:
2324
- master
2425
paths:
2526
- '.github/workflows/e2e_ios.yml'
27+
- '.github/actions/e2e-cache/**'
2628
- '.gitmodules'
2729
- 'package.json'
2830
- 'bun.lock'
@@ -111,27 +113,25 @@ jobs:
111113
fi
112114
113115
- name: Cache Homebrew downloads
114-
# bottle 按 URL 内容寻址,restore-keys 前缀命中即省下载(装/链接照常)
115-
uses: actions/cache@v6
116+
# Bottle content addressing still controls reuse; only snapshot writes
117+
# are reduced to the successful master/core run's daily identity.
118+
uses: ./.github/actions/e2e-cache
116119
with:
117120
path: ~/Library/Caches/Homebrew
118-
key: ${{ runner.os }}-brew-e2e-${{ github.sha }}
119-
restore-keys: |
120-
${{ runner.os }}-brew-e2e-
121+
scope: brew-xcode-26.4
122+
write: ${{ matrix.suite == 'core' }}
121123

122124
- name: Install applesimutils and ccache
123125
run: brew trust wix/brew && HOMEBREW_NO_AUTO_UPDATE=1 brew install wix/brew/applesimutils ccache
124126

125127
- name: Cache ccache
126-
# ccache 按(预处理后)内容寻址,不受 fresh checkout 的 mtime 影响——
127-
# 这是 DerivedData 缓存在 -UseNewBuildSystem=NO 下做不到的。
128-
# 陈旧条目不影响正确性,只影响命中率,所以 restore-keys 用前缀即可。
129-
uses: actions/cache@v6
128+
# Old content-addressed entries affect hit rate, not build correctness.
129+
# PRs and the native matrix leg only restore; no per-commit duplicates.
130+
uses: ./.github/actions/e2e-cache
130131
with:
131132
path: ~/Library/Caches/ccache
132-
key: ${{ runner.os }}-ccache-e2e-xcode-26.4-${{ github.sha }}
133-
restore-keys: |
134-
${{ runner.os }}-ccache-e2e-xcode-26.4-
133+
scope: ccache-xcode-26.4
134+
write: ${{ matrix.suite == 'core' }}
135135

136136
- name: Install e2etest dependencies
137137
run: cd Example/e2etest && bun install --frozen-lockfile
@@ -152,13 +152,12 @@ jobs:
152152
run: cd react-native-update-cli && bun install --frozen-lockfile && bun run build
153153

154154
- name: Cache Metro transform cache
155-
# 内容寻址(等价 ccache 之于 clang):陈旧条目只影响命中率不影响正确性
156-
uses: actions/cache@v6
155+
# Metro validates its own content keys; stale snapshots only recompile.
156+
uses: ./.github/actions/e2e-cache
157157
with:
158158
path: Example/e2etest/.metro-cache
159-
key: ${{ runner.os }}-metro-e2e-${{ github.sha }}
160-
restore-keys: |
161-
${{ runner.os }}-metro-e2e-
159+
scope: metro-xcode-26.4
160+
write: ${{ matrix.suite == 'core' }}
162161

163162
- name: Prepare local update artifacts
164163
env:

0 commit comments

Comments
 (0)