Skip to content

Commit 9d9e93a

Browse files
authored
ci: avoid unrelated Apple runner cache invalidation (#2303)
1 parent 2dabe29 commit 9d9e93a

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

  • .github/actions/setup-apple-runner-build

.github/actions/setup-apple-runner-build/action.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ runs:
4444
id: source-hash
4545
run: |
4646
set -euo pipefail
47-
echo "value=${{ hashFiles('apple/runner/**', 'apple/snapshot-presentation/**', 'scripts/build-xcuitest-apple.sh', 'scripts/patch-xcuitest-runner-icon.ts', 'scripts/write-xcuitest-cache-metadata.mjs', 'packages/platform-apple/src/runner/apple-runner-platform.ts', 'packages/platform-apple/src/runner/runner-cache-metadata.ts', 'packages/platform-apple/src/runner/runner-icon.ts', 'packages/platform-apple/src/runner/runner-xctestrun.ts', 'packages/platform-apple/src/runner/runner-xctestrun-products.ts', '.github/actions/setup-apple-runner-build/action.yml', 'package.json', 'pnpm-lock.yaml') }}" >> "$GITHUB_OUTPUT"
47+
echo "value=${{ hashFiles('apple/runner/**', 'apple/snapshot-presentation/**', 'scripts/build-xcuitest-apple.sh', 'scripts/swift-toolchain-tmpdir.ts', 'scripts/patch-xcuitest-runner-icon.ts', 'scripts/write-xcuitest-cache-metadata.mjs', 'packages/platform-apple/src/runner/apple-runner-platform.ts', 'packages/platform-apple/src/runner/runner-cache-metadata.ts', 'packages/platform-apple/src/runner/runner-icon.ts', 'packages/platform-apple/src/runner/runner-xctestrun.ts', 'packages/platform-apple/src/runner/runner-xctestrun-products.ts', '.github/actions/setup-apple-runner-build/action.yml') }}" >> "$GITHUB_OUTPUT"
4848
shell: bash
4949

5050
- name: Resolve Apple runner build variant
@@ -55,12 +55,19 @@ runs:
5555
INPUT_XCUITEST_DESTINATION: ${{ inputs.xcuitest-destination }}
5656
run: |
5757
set -euo pipefail
58+
BUILD_COMMANDS="$(node -p 'JSON.stringify(Object.entries(require("./package.json").scripts).filter(([name]) => name.startsWith("build:xcuitest:")))')"
5859
VARIANT="$(
5960
printf '%s\n' \
6061
"$INPUT_GATE" \
62+
"$BUILD_COMMANDS" \
63+
"$(uname -m)" \
6164
"$INPUT_XCUITEST_PLATFORM" \
6265
"$INPUT_XCUITEST_DESTINATION" \
6366
"${AGENT_DEVICE_XCUITEST_INCLUDE_UNIT_TESTS:-0}" \
67+
"${AGENT_DEVICE_XCUITEST_ARCHS:-}" \
68+
"${AGENT_DEVICE_IOS_BUNDLE_ID:-}" \
69+
"${AGENT_DEVICE_IOS_RUNNER_APP_BUNDLE_ID:-}" \
70+
"${AGENT_DEVICE_IOS_RUNNER_TEST_BUNDLE_ID:-}" \
6471
| shasum -a 256 \
6572
| cut -c1-16
6673
)"
@@ -89,4 +96,23 @@ runs:
8996
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3
9097
with:
9198
path: ${{ inputs.derived-path }}
92-
key: ${{ inputs.cache-key-prefix }}-${{ steps.xcode.outputs.key }}${{ inputs.cache-key-suffix }}-${{ steps.build-variant.outputs.key }}-${{ steps.source-hash.outputs.value }}
99+
key: ${{ steps.restore-runner-build.outputs.cache-primary-key }}
100+
101+
- name: Report Apple runner build cache
102+
env:
103+
CACHE_HIT: ${{ steps.restore-runner-build.outputs.cache-hit }}
104+
CACHE_KEY: ${{ steps.restore-runner-build.outputs.cache-primary-key }}
105+
BUILD_GATE: ${{ inputs.gate }}
106+
run: |
107+
set -euo pipefail
108+
if [ "$CACHE_HIT" = 'true' ]; then
109+
RESULT='restored exact prebuilt runner; compilation skipped'
110+
else
111+
RESULT='cache miss; built runner and attempted cache save'
112+
fi
113+
{
114+
printf '### Apple runner cache (%s)\n\n' "$BUILD_GATE"
115+
printf '%s\n\n' "$RESULT"
116+
printf 'Key: `%s`\n' "$CACHE_KEY"
117+
} >> "$GITHUB_STEP_SUMMARY"
118+
shell: bash

0 commit comments

Comments
 (0)