Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

mobile-fingerprint-check.yml

150 lines6.5 KB

1name: Mobile Fingerprint Check
2​
3# Detects whether a PR changes the native fingerprint β€” i.e. whether merging
4# it would leave main un-OTA-able until a new store build ships. Native-change
5# PRs get the "πŸ“± Native Change" label (applied by mobile-fingerprint-label.yml,
6# which runs from main so fork PRs get it too) so they can be held and merged as a
7# batch right before the next store submission, keeping main OTA-able for
8# everything else in between. (Once one native PR merges, every later merge
9# inherits the drifted fingerprint and loses OTA reach too β€” that is why the
10# signal has to fire before merge, not after.)
12# The check is advisory: it always passes, the label is the signal. Both
13# fingerprints are computed in this one job (same OS, same corepack-pinned
14# pnpm), so the comparison is self-consistent; no EXPO_TOKEN needed.
15on:
16 pull_request:
17 # Run even when a rebase or base change removes every native input from the
18 # diff, so the label can be cleared without installing Expo dependencies.
19 types: [opened, synchronize, reopened, edited]
20​
21permissions:
22 contents: read
23​
24concurrency:
25 # A title or body edit gets its own group, so it cannot cancel the PR's real
26 # run and leave a cancelled check on the head commit.
27 group: mobile-fingerprint-check-${{ github.event.action == 'edited' && !github.event.changes.base && format('edit-{0}', github.run_id) || github.event.pull_request.number }}
28 cancel-in-progress: true
29​
30jobs:
31 fingerprint:
32 name: Native fingerprint diff
33 if: github.event.action != 'edited' || github.event.changes.base
34 runs-on: blacksmith-8vcpu-ubuntu-2404
35 permissions:
36 contents: read
37 env:
38 APP_VARIANT: production
39 NODE_OPTIONS: --max-old-space-size=8192
40 steps:
41 - name: Checkout
42 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
43 with:
44 # The merge ref can advance after the event is queued. Pin its commit
45 # and compare against its first parent, rather than the event's base.
46 ref: ${{ github.sha }}
47 fetch-depth: 2
48​
49 - id: changes
50 name: Detect native fingerprint inputs
51 run: |
52 base_sha=$(git rev-parse HEAD^1)
53 echo "base_sha=$base_sha" >> "$GITHUB_OUTPUT"
54 paths=$(git diff --no-renames --name-only "$base_sha" HEAD -- \
55 apps/mobile/ packages/client-runtime/ packages/contracts/ packages/shared/ \
56 assets/ scripts/ patches/ package.json pnpm-lock.yaml pnpm-workspace.yaml \
57 .github/workflows/mobile-fingerprint-check.yml)
58 if [[ -n "$paths" ]]; then
59 echo "relevant=true" >> "$GITHUB_OUTPUT"
60 else
61 echo "relevant=false" >> "$GITHUB_OUTPUT"
62 echo "No native fingerprint inputs changed; clearing any stale native change label." >> "$GITHUB_STEP_SUMMARY"
63 fi
64​
65 - name: Setup Vite+
66 if: steps.changes.outputs.relevant == 'true'
67 uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0
68 with:
69 node-version-file: package.json
70 cache: true
71 run-install: |
72 args:
73 - --filter=@t3tools/mobile...
74​
75 - name: Expose pnpm
76 if: steps.changes.outputs.relevant == 'true'
77 run: |
78 pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
79 vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
80 echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
81 "$vp_pnpm_bin/pnpm" --version
82​
83 - name: Fingerprint merge result
84 if: steps.changes.outputs.relevant == 'true'
85 working-directory: apps/mobile
86 run: |
87 mkdir -p "$RUNNER_TEMP/fp/head" "$RUNNER_TEMP/fp/base"
88 for platform in ios android; do
89 npx expo-updates fingerprint:generate --platform "$platform" > "$RUNNER_TEMP/fp/head/$platform.json"
90 done
91​
92 - name: Fingerprint base
93 if: steps.changes.outputs.relevant == 'true'
94 env:
95 BASE_SHA: ${{ steps.changes.outputs.base_sha }}
96 run: |
97 git checkout --quiet "$BASE_SHA"
98 # Re-sync node_modules to the base commit's lockfile before
99 # fingerprinting β€” a dep-changing PR must not fingerprint the base
100 # against head's installed packages.
101 pnpm install --filter=@t3tools/mobile...
102 cd apps/mobile
103 for platform in ios android; do
104 npx expo-updates fingerprint:generate --platform "$platform" > "$RUNNER_TEMP/fp/base/$platform.json"
105 done
106​
107 - id: compare
108 name: Compare fingerprints
109 if: steps.changes.outputs.relevant == 'true'
110 run: |
111 changed=""
112 {
113 echo "## Native fingerprint diff"
114 echo
115 for platform in ios android; do
116 head_hash="$(jq -r .hash "$RUNNER_TEMP/fp/head/$platform.json")"
117 base_hash="$(jq -r .hash "$RUNNER_TEMP/fp/base/$platform.json")"
118 if [ "$head_hash" = "$base_hash" ]; then
119 echo "- βœ… **$platform**: unchanged (\`$head_hash\`) β€” OTA-compatible"
120 continue
121 fi
122 changed="$changed $platform"
123 echo "- πŸ“± **$platform**: \`$base_hash\` β†’ \`$head_hash\` β€” merging requires a new native build before OTAs work again"
124 jq -r -n \
125 --slurpfile h "$RUNNER_TEMP/fp/head/$platform.json" \
126 --slurpfile b "$RUNNER_TEMP/fp/base/$platform.json" '
127 ($b[0].sources | map({ (.filePath // .id): .hash }) | add // {}) as $bm
128 | $h[0].sources[]
129 | select($bm[(.filePath // .id)] != .hash)
130 | " - \(.type): `\(.filePath // .id)`"'
131 done
132 } >> "$GITHUB_STEP_SUMMARY"
133 echo "changed_platforms=${changed# }" >> "$GITHUB_OUTPUT"
134​
135 # mobile-fingerprint-label.yml reads this from main with a write token
136 # and syncs the label; this job's token is read-only for fork PRs.
137 - name: Record changed platforms
138 env:
139 CHANGED_PLATFORMS: ${{ steps.compare.outputs.changed_platforms }}
140 run: |
141 mkdir -p "$RUNNER_TEMP/fingerprint-result"
142 printf '%s\n' "$CHANGED_PLATFORMS" > "$RUNNER_TEMP/fingerprint-result/changed-platforms"
143​
144 - name: Upload changed platforms
145 uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
146 with:
147 name: fingerprint-result
148 path: ${{ runner.temp }}/fingerprint-result
149 if-no-files-found: error
150 retention-days: 1