Skip to content

Commit 216502e

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/affectionate-fermi-owp5ov
# Conflicts: # .github/workflows/replays-nightly.yml
2 parents f95e307 + 4e4ecde commit 216502e

113 files changed

Lines changed: 8654 additions & 1902 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/actions/setup-android-replay-host/action.yml‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
name: 'Setup Android Replay Host'
22
description: 'Prepare the Android CI host for replay tests and expose the agent-device home path'
33

4+
inputs:
5+
package-helpers:
6+
description: 'Restore or package the npm-bundled Android snapshot and IME helpers'
7+
required: false
8+
default: 'false'
9+
410
outputs:
511
agent-home-dir:
612
description: 'Resolved agent-device home directory'
713
value: ${{ steps.agent-home.outputs.dir }}
14+
helpers-cache-hit:
15+
description: 'Whether packaged Android helpers were restored from cache'
16+
value: ${{ steps.android-helpers-cache.outputs.cache-hit }}
817

918
runs:
1019
using: 'composite'
@@ -20,3 +29,64 @@ runs:
2029
sudo udevadm control --reload-rules
2130
sudo udevadm trigger --name-match=kvm
2231
shell: bash
32+
33+
- name: Resolve Android helper source hash
34+
if: inputs.package-helpers == 'true'
35+
id: android-helper-source
36+
run: |
37+
VERSION="$(node -p 'require("./package.json").version')"
38+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
39+
echo "value=${{ hashFiles('android/snapshot-helper/AndroidManifest.xml', 'android/snapshot-helper/debug.keystore', 'android/snapshot-helper/src/**', 'android/ime-helper/AndroidManifest.xml', 'android/ime-helper/res/**', 'android/ime-helper/src/**', 'scripts/build-android-helper.sh', 'scripts/package-android-helper.sh', '.github/actions/setup-android-replay-host/action.yml') }}" >> "$GITHUB_OUTPUT"
40+
shell: bash
41+
42+
- name: Restore packaged Android helpers
43+
if: inputs.package-helpers == 'true'
44+
id: android-helpers-cache
45+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3
46+
with:
47+
path: |
48+
android/snapshot-helper/dist
49+
android/ime-helper/dist
50+
key: android-helpers-${{ runner.os }}-${{ runner.arch }}-api36-v${{ steps.android-helper-source.outputs.version }}-${{ steps.android-helper-source.outputs.value }}
51+
52+
- name: Install Android helper SDK packages
53+
if: inputs.package-helpers == 'true' && steps.android-helpers-cache.outputs.cache-hit != 'true'
54+
run: |
55+
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
56+
SDKMANAGER="$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
57+
if [ ! -x "$SDKMANAGER" ]; then
58+
SDKMANAGER="$SDK_ROOT/cmdline-tools/bin/sdkmanager"
59+
fi
60+
if [ ! -x "$SDKMANAGER" ]; then
61+
echo "sdkmanager not found under $SDK_ROOT" >&2
62+
exit 1
63+
fi
64+
yes | "$SDKMANAGER" --licenses >/dev/null || true
65+
"$SDKMANAGER" "platforms;android-36" "build-tools;36.0.0"
66+
shell: bash
67+
68+
- name: Package npm-bundled Android helpers
69+
if: inputs.package-helpers == 'true' && steps.android-helpers-cache.outputs.cache-hit != 'true'
70+
run: |
71+
VERSION="${{ steps.android-helper-source.outputs.version }}"
72+
rm -rf android/snapshot-helper/dist android/ime-helper/dist
73+
sh ./scripts/package-android-helper.sh snapshot "$VERSION" "v$VERSION" android/snapshot-helper/dist
74+
sh ./scripts/package-android-helper.sh ime "$VERSION" android/ime-helper/dist
75+
shell: bash
76+
77+
- name: Verify packaged Android helpers
78+
if: inputs.package-helpers == 'true'
79+
run: |
80+
VERSION="$(node -p 'require("./package.json").version')"
81+
test -f "android/snapshot-helper/dist/agent-device-android-snapshot-helper-$VERSION.manifest.json"
82+
test -f "android/ime-helper/dist/agent-device-android-ime-helper-$VERSION.manifest.json"
83+
shell: bash
84+
85+
- name: Save packaged Android helpers
86+
if: inputs.package-helpers == 'true' && steps.android-helpers-cache.outputs.cache-hit != 'true'
87+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3
88+
with:
89+
path: |
90+
android/snapshot-helper/dist
91+
android/ime-helper/dist
92+
key: android-helpers-${{ runner.os }}-${{ runner.arch }}-api36-v${{ steps.android-helper-source.outputs.version }}-${{ steps.android-helper-source.outputs.value }}

‎.github/actions/setup-apple-replay/action.yml‎

Lines changed: 0 additions & 77 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: 'Set Up Apple Runner Build'
2+
description: 'Restore an exact Apple runner build or build and cache it on a miss'
3+
4+
inputs:
5+
derived-path:
6+
description: 'DerivedData path used by the Apple runner'
7+
required: true
8+
cache-key-prefix:
9+
description: 'Prefix for the cache key'
10+
required: true
11+
cache-key-suffix:
12+
description: 'Optional suffix for the cache key'
13+
required: false
14+
default: ''
15+
build-command:
16+
description: 'Command used to build Apple runner artifacts'
17+
required: true
18+
xcuitest-platform:
19+
description: 'Optional AGENT_DEVICE_XCUITEST_PLATFORM value'
20+
required: false
21+
default: ''
22+
xcuitest-destination:
23+
description: 'Optional AGENT_DEVICE_XCUITEST_DESTINATION value'
24+
required: false
25+
default: ''
26+
outputs:
27+
cache-hit:
28+
description: 'Whether an exact Apple runner build cache was restored'
29+
value: ${{ steps.restore-runner-build.outputs.cache-hit }}
30+
31+
runs:
32+
using: 'composite'
33+
steps:
34+
- name: Resolve Xcode cache identity
35+
id: xcode
36+
run: |
37+
set -euo pipefail
38+
XCODE_VERSION="$(xcodebuild -version | tr '\n' ' ' | sed -E 's/[[:space:]]+/ /g; s/[[:space:]]$//')"
39+
XCODE_KEY="$(echo "$XCODE_VERSION" | tr ' ' '-' | tr -cd '[:alnum:]._-')"
40+
echo "key=$XCODE_KEY" >> "$GITHUB_OUTPUT"
41+
shell: bash
42+
43+
- name: Resolve Apple runner source hash
44+
id: source-hash
45+
run: |
46+
set -euo pipefail
47+
echo "value=${{ hashFiles('apple/runner/**', 'scripts/build-xcuitest-apple.sh', 'scripts/patch-xcuitest-runner-icon.ts', 'scripts/write-xcuitest-cache-metadata.mjs', 'src/platforms/apple/core/apple-runner-platform.ts', 'src/platforms/apple/core/runner/runner-cache-metadata.ts', 'src/platforms/apple/core/runner/runner-icon.ts', 'src/platforms/apple/core/runner/runner-xctestrun.ts', 'src/platforms/apple/core/runner/runner-xctestrun-products.ts', '.github/actions/setup-apple-runner-build/action.yml', 'package.json', 'pnpm-lock.yaml') }}" >> "$GITHUB_OUTPUT"
48+
shell: bash
49+
50+
- name: Resolve Apple runner build variant
51+
id: build-variant
52+
run: |
53+
set -euo pipefail
54+
VARIANT="$(
55+
printf '%s\n' \
56+
'${{ inputs.build-command }}' \
57+
'${{ inputs.xcuitest-platform }}' \
58+
'${{ inputs.xcuitest-destination }}' \
59+
"${AGENT_DEVICE_XCUITEST_INCLUDE_UNIT_TESTS:-0}" \
60+
| shasum -a 256 \
61+
| cut -c1-16
62+
)"
63+
echo "key=$VARIANT" >> "$GITHUB_OUTPUT"
64+
shell: bash
65+
66+
- name: Restore Apple runner build cache
67+
id: restore-runner-build
68+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3
69+
with:
70+
path: ${{ inputs.derived-path }}
71+
key: ${{ inputs.cache-key-prefix }}-${{ steps.xcode.outputs.key }}${{ inputs.cache-key-suffix }}-${{ steps.build-variant.outputs.key }}-${{ steps.source-hash.outputs.value }}
72+
73+
- name: Build Apple runner artifacts on cache miss
74+
if: steps.restore-runner-build.outputs.cache-hit != 'true'
75+
run: ${{ inputs.build-command }}
76+
shell: bash
77+
env:
78+
AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH: ${{ inputs.derived-path }}
79+
AGENT_DEVICE_XCUITEST_PLATFORM: ${{ inputs.xcuitest-platform }}
80+
AGENT_DEVICE_XCUITEST_DESTINATION: ${{ inputs.xcuitest-destination }}
81+
82+
- name: Save Apple runner build cache
83+
if: steps.restore-runner-build.outputs.cache-hit != 'true'
84+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3
85+
with:
86+
path: ${{ inputs.derived-path }}
87+
key: ${{ inputs.cache-key-prefix }}-${{ steps.xcode.outputs.key }}${{ inputs.cache-key-suffix }}-${{ steps.build-variant.outputs.key }}-${{ steps.source-hash.outputs.value }}

‎.github/actions/setup-fixture-app/action.yml‎

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ description: 'Install a ready Release build of examples/test-app on the booted i
1111
# Release build embedded may be stale — @expo/repack-app swaps in a bundle built
1212
# from the current source. If no artifact exists yet (the producer has not run
1313
# for this fingerprint), it falls back to building inline, so a caller is never
14-
# left without an app.
14+
# left without an app. Callers that run alongside the producer can opt into a
15+
# bounded wait first, avoiding two simultaneous native builds on a cold key.
16+
# Artifact hits are accepted only from this repository's designated producer
17+
# workflow at the current head or from a default-branch push.
1518
#
1619
# The caller's job needs `permissions: actions: read` for the artifact lookup.
1720
# Relevant to #320 (move replay coverage off system apps onto a stable fixture).
@@ -25,7 +28,10 @@ inputs:
2528
description: 'Install the app onto the booted simulator'
2629
required: false
2730
default: 'true'
28-
31+
wait-for-artifact-seconds:
32+
description: 'How long to poll for a concurrently produced artifact before building inline'
33+
required: false
34+
default: '0'
2935
outputs:
3036
app-path:
3137
description: 'Path to the ready .app bundle'
@@ -40,11 +46,10 @@ outputs:
4046
runs:
4147
using: 'composite'
4248
steps:
43-
# Installed even on a hit, because the fingerprint is derived from the
44-
# dependency graph and cannot be computed without it.
45-
- name: Install test app dependencies
46-
shell: bash
47-
run: pnpm test-app:install
49+
# The fingerprint/repack commands need the dependency graph. This shared
50+
# action avoids recreating it on every warm native-artifact consumer.
51+
- name: Setup test app dependencies
52+
uses: ./.github/actions/setup-test-app-dependencies
4853

4954
- name: Fetch the cached Release binary
5055
id: fetch
@@ -53,19 +58,80 @@ runs:
5358
GH_TOKEN: ${{ github.token }}
5459
run: |
5560
set -euo pipefail
56-
HASH="$(pnpm --dir examples/test-app exec fingerprint fingerprint:generate | jq -r .hash)"
57-
NAME="fingerprint.${HASH}.ios"
61+
NAME="$(sh "$GITHUB_ACTION_PATH/resolve-artifact-name.sh" ios)"
5862
DEST="${{ github.workspace }}/.tmp/fixture-app"
63+
REPOSITORY="${{ github.repository }}"
64+
EXPECTED_HEAD_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
65+
TRUSTED_ARTIFACT="$GITHUB_ACTION_PATH/trusted-artifact.mjs"
5966
rm -rf "$DEST"; mkdir -p "$DEST"
67+
WAIT_SECONDS="${{ inputs.wait-for-artifact-seconds }}"
68+
case "$WAIT_SECONDS" in
69+
''|*[!0-9]*)
70+
echo "::error::wait-for-artifact-seconds must be a non-negative integer."
71+
exit 1
72+
;;
73+
esac
6074
6175
# A lookup failure (API outage, auth, transient 5xx) must not fail the
62-
# caller: it degrades to an inline build exactly as a cache miss does. The
63-
# assignment sits in an `if` so `set -e` cannot exit on it, and an empty
64-
# ART_ID then takes the same path as "no artifact found".
65-
if ! ART_ID="$(gh api "repos/${{ github.repository }}/actions/artifacts?name=${NAME}&per_page=1" \
66-
--jq '[.artifacts[] | select(.expired == false)][0].id // empty' 2>/dev/null)"; then
76+
# caller or trigger a pointless wait: it takes the inline-build path.
77+
query_artifact() {
78+
node "$TRUSTED_ARTIFACT" find "$REPOSITORY" "$NAME" "$EXPECTED_HEAD_SHA" 2>/dev/null
79+
}
80+
query_producer_state() {
81+
node "$TRUSTED_ARTIFACT" producer-state "$REPOSITORY" "$EXPECTED_HEAD_SHA" 2>/dev/null
82+
}
83+
if ! ART_ID="$(query_artifact)"; then
6784
echo "::warning::Could not query the build cache for $NAME; building inline."
6885
ART_ID=""
86+
WAIT_SECONDS=0
87+
fi
88+
if [ -z "$ART_ID" ] && [ "$WAIT_SECONDS" -gt 0 ]; then
89+
DEADLINE=$((SECONDS + WAIT_SECONDS))
90+
MISSING_PRODUCER_POLLS=0
91+
echo "$NAME is not available; waiting up to ${WAIT_SECONDS}s for its producer."
92+
while [ -z "$ART_ID" ] && [ "$SECONDS" -lt "$DEADLINE" ]; do
93+
if ! PRODUCER_STATE="$(query_producer_state)"; then
94+
echo "::warning::Could not inspect the fixture producer; building inline."
95+
break
96+
fi
97+
case "$PRODUCER_STATE" in
98+
queued)
99+
echo "Fixture producer is queued; building inline instead of waiting for a macOS runner."
100+
break
101+
;;
102+
failed)
103+
echo "Fixture producer failed; building inline."
104+
break
105+
;;
106+
success)
107+
echo "Fixture producer completed without $NAME; building inline."
108+
break
109+
;;
110+
absent)
111+
MISSING_PRODUCER_POLLS=$((MISSING_PRODUCER_POLLS + 1))
112+
if [ "$MISSING_PRODUCER_POLLS" -ge 3 ]; then
113+
echo "No fixture producer appeared for $EXPECTED_HEAD_SHA; building inline."
114+
break
115+
fi
116+
;;
117+
in_progress)
118+
MISSING_PRODUCER_POLLS=0
119+
;;
120+
*)
121+
echo "::warning::Fixture producer returned unknown state '$PRODUCER_STATE'; building inline."
122+
break
123+
;;
124+
esac
125+
sleep 30
126+
if ! ART_ID="$(query_artifact)"; then
127+
echo "::warning::Build cache polling failed for $NAME; building inline."
128+
ART_ID=""
129+
break
130+
fi
131+
if [ -n "$ART_ID" ]; then
132+
break
133+
fi
134+
done
69135
fi
70136
71137
SOURCE=build
@@ -84,7 +150,7 @@ runs:
84150
fi
85151
rm -rf "$STAGE"
86152
else
87-
echo "$NAME not in the cache yet; building inline."
153+
echo "$NAME not in the cache after the configured wait; building inline."
88154
fi
89155
echo "source=$SOURCE" >> "$GITHUB_OUTPUT"
90156

0 commit comments

Comments
 (0)