From c5faab6d9eb8ec13fab12b13a2abcde131c0fca5 Mon Sep 17 00:00:00 2001 From: Sunny Luo Date: Mon, 28 Sep 2026 10:52:03 +0800 Subject: [PATCH 1/2] ci: add read-only PR caches with trusted daily snapshots --- .github/actions/e2e-cache/action.yml | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/actions/e2e-cache/action.yml diff --git a/.github/actions/e2e-cache/action.yml b/.github/actions/e2e-cache/action.yml new file mode 100644 index 00000000..d598441a --- /dev/null +++ b/.github/actions/e2e-cache/action.yml @@ -0,0 +1,34 @@ +name: Bounded content-addressed E2E cache +description: Restore shared content caches; only mainline core saves a daily snapshot. +inputs: + path: + description: Content-addressed cache directory, never a built app. + required: true + scope: + description: Cache schema/toolchain identity. + required: true + write: + description: The core matrix leg may write on a trusted master push. + default: 'false' +runs: + using: composite + steps: + - id: epoch + shell: bash + run: echo "day=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT" + - name: Restore read-only snapshot + if: "!(inputs.write == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/master' && github.job == 'e2e-ios')" + uses: actions/cache/restore@v6 + with: + path: ${{ inputs.path }} + key: e2e-content-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.scope }}-${{ steps.epoch.outputs.day }} + restore-keys: | + e2e-content-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.scope }}- + - name: Restore and save trusted daily snapshot + if: inputs.write == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/master' && github.job == 'e2e-ios' + uses: actions/cache@v6 + with: + path: ${{ inputs.path }} + key: e2e-content-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.scope }}-${{ steps.epoch.outputs.day }} + restore-keys: | + e2e-content-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.scope }}- From fc562d664adeb17ebae7c0535b2c461d20f7121a Mon Sep 17 00:00:00 2001 From: Sunny Luo Date: Mon, 28 Sep 2026 10:52:49 +0800 Subject: [PATCH 2/2] ci: stop duplicating iOS content caches for every PR commit --- .github/workflows/e2e_ios.yml | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/e2e_ios.yml b/.github/workflows/e2e_ios.yml index 2070d2aa..f3219a12 100644 --- a/.github/workflows/e2e_ios.yml +++ b/.github/workflows/e2e_ios.yml @@ -6,6 +6,7 @@ on: - '**' paths: - '.github/workflows/e2e_ios.yml' + - '.github/actions/e2e-cache/**' - '.gitmodules' - 'package.json' - 'bun.lock' @@ -23,6 +24,7 @@ on: - master paths: - '.github/workflows/e2e_ios.yml' + - '.github/actions/e2e-cache/**' - '.gitmodules' - 'package.json' - 'bun.lock' @@ -111,27 +113,25 @@ jobs: fi - name: Cache Homebrew downloads - # bottle 按 URL 内容寻址,restore-keys 前缀命中即省下载(装/链接照常) - uses: actions/cache@v6 + # Bottle content addressing still controls reuse; only snapshot writes + # are reduced to the successful master/core run's daily identity. + uses: ./.github/actions/e2e-cache with: path: ~/Library/Caches/Homebrew - key: ${{ runner.os }}-brew-e2e-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-brew-e2e- + scope: brew-xcode-26.4 + write: ${{ matrix.suite == 'core' }} - name: Install applesimutils and ccache run: brew trust wix/brew && HOMEBREW_NO_AUTO_UPDATE=1 brew install wix/brew/applesimutils ccache - name: Cache ccache - # ccache 按(预处理后)内容寻址,不受 fresh checkout 的 mtime 影响—— - # 这是 DerivedData 缓存在 -UseNewBuildSystem=NO 下做不到的。 - # 陈旧条目不影响正确性,只影响命中率,所以 restore-keys 用前缀即可。 - uses: actions/cache@v6 + # Old content-addressed entries affect hit rate, not build correctness. + # PRs and the native matrix leg only restore; no per-commit duplicates. + uses: ./.github/actions/e2e-cache with: path: ~/Library/Caches/ccache - key: ${{ runner.os }}-ccache-e2e-xcode-26.4-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-ccache-e2e-xcode-26.4- + scope: ccache-xcode-26.4 + write: ${{ matrix.suite == 'core' }} - name: Install e2etest dependencies run: cd Example/e2etest && bun install --frozen-lockfile @@ -152,13 +152,12 @@ jobs: run: cd react-native-update-cli && bun install --frozen-lockfile && bun run build - name: Cache Metro transform cache - # 内容寻址(等价 ccache 之于 clang):陈旧条目只影响命中率不影响正确性 - uses: actions/cache@v6 + # Metro validates its own content keys; stale snapshots only recompile. + uses: ./.github/actions/e2e-cache with: path: Example/e2etest/.metro-cache - key: ${{ runner.os }}-metro-e2e-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-metro-e2e- + scope: metro-xcode-26.4 + write: ${{ matrix.suite == 'core' }} - name: Prepare local update artifacts env: