@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

main
yml 147 lines 6.51 KB
Raw
1 name: 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.)
11 #
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.
15 on:
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
21 concurrency:
22 # A title or body edit gets its own group, so it cannot cancel the PR's real
23 # run and leave a cancelled check on the head commit.
24 group: mobile-fingerprint-check-${{ github.event.action == 'edited' && !github.event.changes.base && format('edit-{0}', github.run_id) || github.event.pull_request.number }}
25 cancel-in-progress: true
26
27 jobs:
28 fingerprint:
29 name: Native fingerprint diff
30 if: github.event.action != 'edited' || github.event.changes.base
31 runs-on: blacksmith-8vcpu-ubuntu-2404
32 permissions:
33 contents: read
34 env:
35 APP_VARIANT: production
36 NODE_OPTIONS: --max-old-space-size=8192
37 steps:
38 - name: Checkout
39 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
40 with:
41 # The merge ref can advance after the event is queued. Pin its commit
42 # and compare against its first parent, rather than the event's base.
43 ref: ${{ github.sha }}
44 fetch-depth: 2
45
46 - id: changes
47 name: Detect native fingerprint inputs
48 run: |
49 base_sha=$(git rev-parse HEAD^1)
50 echo "base_sha=$base_sha" >> "$GITHUB_OUTPUT"
51 paths=$(git diff --no-renames --name-only "$base_sha" HEAD -- \
52 apps/mobile/ packages/client-runtime/ packages/contracts/ packages/shared/ \
53 assets/ scripts/ patches/ package.json pnpm-lock.yaml pnpm-workspace.yaml \
54 .github/workflows/mobile-fingerprint-check.yml)
55 if [[ -n "$paths" ]]; then
56 echo "relevant=true" >> "$GITHUB_OUTPUT"
57 else
58 echo "relevant=false" >> "$GITHUB_OUTPUT"
59 echo "No native fingerprint inputs changed; clearing any stale native change label." >> "$GITHUB_STEP_SUMMARY"
60 fi
61
62 - name: Setup Vite+
63 if: steps.changes.outputs.relevant == 'true'
64 uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0
65 with:
66 node-version-file: package.json
67 cache: true
68 run-install: |
69 args:
70 - --filter=@t3tools/mobile...
71
72 - name: Expose pnpm
73 if: steps.changes.outputs.relevant == 'true'
74 run: |
75 pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
76 vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
77 echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
78 "$vp_pnpm_bin/pnpm" --version
79
80 - name: Fingerprint merge result
81 if: steps.changes.outputs.relevant == 'true'
82 working-directory: apps/mobile
83 run: |
84 mkdir -p "$RUNNER_TEMP/fp/head" "$RUNNER_TEMP/fp/base"
85 for platform in ios android; do
86 npx expo-updates fingerprint:generate --platform "$platform" > "$RUNNER_TEMP/fp/head/$platform.json"
87 done
88
89 - name: Fingerprint base
90 if: steps.changes.outputs.relevant == 'true'
91 env:
92 BASE_SHA: ${{ steps.changes.outputs.base_sha }}
93 run: |
94 git checkout --quiet "$BASE_SHA"
95 # Re-sync node_modules to the base commit's lockfile before
96 # fingerprinting — a dep-changing PR must not fingerprint the base
97 # against head's installed packages.
98 pnpm install --filter=@t3tools/mobile...
99 cd apps/mobile
100 for platform in ios android; do
101 npx expo-updates fingerprint:generate --platform "$platform" > "$RUNNER_TEMP/fp/base/$platform.json"
102 done
103
104 - id: compare
105 name: Compare fingerprints
106 if: steps.changes.outputs.relevant == 'true'
107 run: |
108 changed=""
109 {
110 echo "## Native fingerprint diff"
111 echo
112 for platform in ios android; do
113 head_hash="$(jq -r .hash "$RUNNER_TEMP/fp/head/$platform.json")"
114 base_hash="$(jq -r .hash "$RUNNER_TEMP/fp/base/$platform.json")"
115 if [ "$head_hash" = "$base_hash" ]; then
116 echo "- ✅ **$platform**: unchanged (\`$head_hash\`) — OTA-compatible"
117 continue
118 fi
119 changed="$changed $platform"
120 echo "- 📱 **$platform**: \`$base_hash\` → \`$head_hash\` — merging requires a new native build before OTAs work again"
121 jq -r -n \
122 --slurpfile h "$RUNNER_TEMP/fp/head/$platform.json" \
123 --slurpfile b "$RUNNER_TEMP/fp/base/$platform.json" '
124 ($b[0].sources | map({ (.filePath // .id): .hash }) | add // {}) as $bm
125 | $h[0].sources[]
126 | select($bm[(.filePath // .id)] != .hash)
127 | " - \(.type): `\(.filePath // .id)`"'
128 done
129 } >> "$GITHUB_STEP_SUMMARY"
130 echo "changed_platforms=${changed# }" >> "$GITHUB_OUTPUT"
131
132 # mobile-fingerprint-label.yml reads this from main with a write token
133 # and syncs the label; this job's token is read-only for fork PRs.
134 - name: Record changed platforms
135 env:
136 CHANGED_PLATFORMS: ${{ steps.compare.outputs.changed_platforms }}
137 run: |
138 mkdir -p "$RUNNER_TEMP/fingerprint-result"
139 printf '%s\n' "$CHANGED_PLATFORMS" > "$RUNNER_TEMP/fingerprint-result/changed-platforms"
140
141 - name: Upload changed platforms
142 uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
143 with:
144 name: fingerprint-result
145 path: ${{ runner.temp }}/fingerprint-result
146 if-no-files-found: error
147 retention-days: 1