Skip to content

Commit 3994d64

Browse files
Merge pull request #149 from ScriptedAlchemy/codex/merge-upstream-main-2026-11-17
chore: merge upstream main into the fork
2 parents 9d28a97 + a6093ef commit 3994d64

1,055 files changed

Lines changed: 119502 additions & 9807 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.

‎.gitattributes‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# Batch files need CRLF for cmd.exe to parse them reliably.
44
*.cmd text eol=crlf
55
*.bat text eol=crlf
6-
# GitHub's and Expo's GraphQL schemas and the operations graphqlgen writes from them.
6+
# GitHub's, Linear's and Expo's GraphQL schemas and the operations graphqlgen writes from them.
77
packages/source-control-github/schema/** linguist-generated
8+
packages/issue-tracker-linear/schema/** linguist-generated
89
apps/server/schema/** linguist-generated
910
**/*.graphql.ts linguist-generated
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Drop checkout credentials
2+
description: Removes the token actions/checkout leaves behind, so later steps can run dependency and build scripts.
3+
4+
# checkout keeps the token in a file under RUNNER_TEMP that .git/config includes, so
5+
# both go. `persist-credentials: false` fails in this repo: its cleanup runs `git
6+
# submodule foreach`, which stops at the vendored gitlinks under .repos (no .gitmodules).
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Drop checkout credentials
11+
shell: bash
12+
run: |
13+
# Status 1 means no match; any other failure stops the step.
14+
lookup() {
15+
local status=0
16+
git -C "$dir" config --local "$@" || status=$?
17+
if [ "$status" -gt 1 ]; then exit "$status"; fi
18+
}
19+
for dir in . .trusted; do
20+
[ -e "$dir/.git" ] || continue
21+
lookup --get-regexp '^includeif\..*\.path$' | while read -r key file; do
22+
rm -f "$file"
23+
git -C "$dir" config --local --unset-all "$key"
24+
done
25+
lookup --name-only --get-regexp '^http\..*\.extraheader$' | while read -r key; do
26+
git -C "$dir" config --local --unset-all "$key"
27+
done
28+
remaining="$(lookup --get-regexp 'extraheader|includeif')"
29+
if [ -n "$remaining" ]; then
30+
echo "::error::checkout credentials are still configured in $dir"
31+
exit 1
32+
fi
33+
done
34+
rm -f "$RUNNER_TEMP"/git-credentials-*.config
35+
if ls "$RUNNER_TEMP"/git-credentials-*.config 2>/dev/null; then
36+
echo "::error::a checkout credential file is still present"
37+
exit 1
38+
fi
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
name: EAS local build
2+
description: Installs the toolchain and mobile dependencies, then runs `eas build --local` on this runner.
3+
4+
inputs:
5+
platform:
6+
description: android or ios
7+
required: true
8+
profile:
9+
description: eas.json build profile
10+
required: true
11+
environment:
12+
description: EAS environment to pull, preview or production
13+
required: true
14+
expo-token:
15+
description: Expo token for that environment
16+
required: true
17+
output:
18+
description: Path the build artifact is written to
19+
required: true
20+
cache:
21+
description: "false for untrusted code: no build cache and no EAS cache, so nothing it writes reaches trusted builds"
22+
default: "true"
23+
sourcemaps-r2:
24+
description: R2 credentials for the eas-build-on-success source map upload; EAS secrets don't reach local builds
25+
default: ""
26+
27+
runs:
28+
using: composite
29+
steps:
30+
- name: Prepare Android build cache
31+
if: inputs.platform == 'android' && inputs.cache == 'true'
32+
shell: bash
33+
env:
34+
CACHE_NAME: ${{ inputs.environment == 'production' && 'store' || 'preview' }}
35+
run: |
36+
cache="$HOME/.cache/t3-android-$CACHE_NAME"
37+
{
38+
echo "GRADLE_USER_HOME=$cache/gradle"
39+
echo "CCACHE_DIR=$cache/ccache"
40+
echo "CCACHE_MAXSIZE=5G"
41+
# Gradle installs the NDK fresh each run, so key on the compiler's version, not its mtime.
42+
echo "CCACHE_COMPILERCHECK=%compiler% -v"
43+
echo "pnpm_config_store_dir=$cache/pnpm-store"
44+
# eas build --local copies the project here. A fixed path keeps
45+
# ccache keys stable, and the same disk as the store lets pnpm hardlink.
46+
echo "EAS_LOCAL_BUILD_WORKINGDIR=$cache/eas-build"
47+
echo "CCACHE_BASEDIR=$cache/eas-build"
48+
# CMake (3.17+) reads these, and AGP passes Gradle's environment through.
49+
echo "CMAKE_C_COMPILER_LAUNCHER=ccache"
50+
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache"
51+
} >> "$GITHUB_ENV"
52+
53+
- name: Mount Android build cache
54+
if: inputs.platform == 'android' && inputs.cache == 'true'
55+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
56+
with:
57+
key: ${{ github.repository }}-android-${{ inputs.environment == 'production' && 'store' || 'preview' }}-build-${{ github.run_id }}
58+
restore-keys: ${{ github.repository }}-android-${{ inputs.environment == 'production' && 'store' || 'preview' }}-build-
59+
path: ~/.cache/t3-android-${{ inputs.environment == 'production' && 'store' || 'preview' }}
60+
61+
- name: Configure Gradle and ccache
62+
if: inputs.platform == 'android' && inputs.cache == 'true'
63+
shell: bash
64+
run: |
65+
mkdir -p "$GRADLE_USER_HOME" "$CCACHE_DIR"
66+
rm -rf "$EAS_LOCAL_BUILD_WORKINGDIR"
67+
# No daemon: nothing should hold the cache directory open when it is saved.
68+
printf 'org.gradle.caching=true\norg.gradle.daemon=false\n' > "$GRADLE_USER_HOME/gradle.properties"
69+
sudo apt-get update -qq && sudo apt-get install -y -qq ccache
70+
ccache --zero-stats
71+
72+
# Matches the EAS build image in eas.json.
73+
- name: Select Xcode 27.1
74+
if: inputs.platform == 'ios'
75+
shell: bash
76+
run: |
77+
xcode=/Applications/Xcode_27.1.app
78+
if [ ! -d "$xcode" ]; then
79+
ls -d /Applications/Xcode*.app
80+
echo "::error::Xcode 27.1 is not on this runner."
81+
exit 1
82+
fi
83+
sudo xcode-select -s "$xcode/Contents/Developer"
84+
xcodebuild -version
85+
echo "- Xcode: \`$(basename "$xcode")\`" >> "$GITHUB_STEP_SUMMARY"
86+
87+
# EAS's credentials step fails to import the distribution certificate without it.
88+
- name: Install Apple WWDR G3 intermediate
89+
if: inputs.platform == 'ios'
90+
shell: bash
91+
run: |
92+
curl -fsSL -o "$RUNNER_TEMP/AppleWWDRCAG3.cer" https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer
93+
sudo security add-certificates -k /Library/Keychains/System.keychain "$RUNNER_TEMP/AppleWWDRCAG3.cer" || true
94+
security find-certificate -c "Apple Worldwide Developer Relations" /Library/Keychains/System.keychain | grep labl
95+
96+
- name: Setup Node
97+
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
98+
with:
99+
node-version-file: package.json
100+
101+
- name: Enable corepack
102+
shell: bash
103+
run: |
104+
npm install --global corepack@latest
105+
corepack enable
106+
pnpm --version
107+
108+
# EAS commands load app.config.ts, whose plugins must resolve. Keep install
109+
# scripts: some download native assets that the build's fingerprint check hashes.
110+
- name: Install mobile dependencies
111+
shell: bash
112+
run: pnpm install --frozen-lockfile --prefer-offline --filter=@t3tools/mobile...
113+
114+
- name: Setup Java
115+
if: inputs.platform == 'android'
116+
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
117+
with:
118+
distribution: temurin
119+
java-version: 17
120+
121+
- name: Setup EAS
122+
uses: expo/expo-github-action@c7b66a9c327a43a8fa7c0158e7f30d6040d2481e # v8.2.1
123+
with:
124+
eas-version: latest
125+
eas-cache: ${{ inputs.cache }}
126+
token: ${{ inputs.expo-token }}
127+
# npm, not pnpm: this only installs eas-cli into the action's own
128+
# tool dir, and pnpm 11 hard-fails that install on dtrace-provider's
129+
# ignored build script (no allowBuilds config outside the repo).
130+
packager: npm
131+
132+
- name: Build tools
133+
if: inputs.platform == 'ios'
134+
shell: bash
135+
run: |
136+
command -v pod || sudo gem install cocoapods --no-document
137+
command -v fastlane || brew install fastlane
138+
pod --version
139+
fastlane --version | tail -1
140+
141+
# EAS commands skip dotenv, and the Android fingerprint hashes this file.
142+
- name: Pull ${{ inputs.environment }} environment variables
143+
shell: bash
144+
working-directory: apps/mobile
145+
env:
146+
EXPO_TOKEN: ${{ inputs.expo-token }}
147+
ENVIRONMENT: ${{ inputs.environment }}
148+
PLATFORM: ${{ inputs.platform }}
149+
run: |
150+
eas env:pull "$ENVIRONMENT" --non-interactive
151+
node --input-type=module <<'NODE'
152+
import { appendFileSync, readFileSync } from "node:fs";
153+
import { parseEnv } from "node:util";
154+
const env = parseEnv(readFileSync(".env.local", "utf8"));
155+
const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
156+
if (!googleServicesFile && process.env.PLATFORM === "android") {
157+
throw new Error(`T3CODE_ANDROID_GOOGLE_SERVICES_FILE is missing from the ${process.env.ENVIRONMENT} environment`);
158+
}
159+
if (googleServicesFile) {
160+
appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
161+
}
162+
NODE
163+
164+
- name: Build
165+
shell: bash
166+
working-directory: apps/mobile
167+
env:
168+
EXPO_TOKEN: ${{ inputs.expo-token }}
169+
MOBILE_SOURCEMAPS_R2: ${{ inputs.sourcemaps-r2 }}
170+
PLATFORM: ${{ inputs.platform }}
171+
PROFILE: ${{ inputs.profile }}
172+
OUTPUT: ${{ inputs.output }}
173+
run: |
174+
if [ "$PLATFORM" = "ios" ]; then
175+
# A real path: /var -> /private/var symlinks break the expo-widgets bundle step.
176+
export EAS_LOCAL_BUILD_WORKINGDIR="$RUNNER_TEMP/eas-build"
177+
fi
178+
eas build --local --platform "$PLATFORM" --profile "$PROFILE" --non-interactive --output "$OUTPUT"
179+
180+
- name: Report ccache
181+
if: inputs.platform == 'android' && inputs.cache == 'true'
182+
shell: bash
183+
run: |
184+
{
185+
echo '```'
186+
ccache --show-stats
187+
echo '```'
188+
} >> "$GITHUB_STEP_SUMMARY"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Record build tag
2+
description: Pushes the tag that tells later runs a build for this fingerprint exists.
3+
4+
inputs:
5+
tag:
6+
description: Tag name, without refs/tags/
7+
required: true
8+
message:
9+
description: Annotated tag message; empty makes a lightweight tag
10+
default: ""
11+
replace:
12+
description: "true replaces an existing tag; otherwise an existing tag counts as recorded"
13+
default: "false"
14+
token:
15+
description: Token with contents write
16+
required: true
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- name: Record build tag
22+
shell: bash
23+
env:
24+
TAG: ${{ inputs.tag }}
25+
MESSAGE: ${{ inputs.message }}
26+
REPLACE: ${{ inputs.replace }}
27+
GH_TOKEN: ${{ inputs.token }}
28+
run: |
29+
git config user.name "github-actions[bot]"
30+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
31+
remote="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
32+
# GitHub occasionally fails ref writes server-side ("fatal error in commit_refs").
33+
for attempt in 1 2 3; do
34+
if refs="$(git ls-remote "$remote" "refs/tags/$TAG")"; then
35+
old="$(printf '%s\n' "$refs" | while read -r sha ref; do
36+
if [ "$ref" = "refs/tags/$TAG" ]; then echo "$sha"; fi
37+
done)"
38+
if [ -n "$old" ] && [ "$REPLACE" != "true" ]; then
39+
echo "$TAG exists."
40+
exit 0
41+
fi
42+
if [ -n "$MESSAGE" ]; then
43+
git tag -f -a "$TAG" -m "$MESSAGE"
44+
else
45+
git tag -f "$TAG"
46+
fi
47+
# An empty lease means the tag must not exist yet.
48+
if git push --force-with-lease="refs/tags/$TAG:$old" "$remote" "refs/tags/$TAG"; then
49+
exit 0
50+
fi
51+
fi
52+
if [ "$attempt" = 3 ]; then
53+
echo "::error::Could not push $TAG."
54+
exit 1
55+
fi
56+
sleep $((attempt * 15))
57+
done
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const { readFileSync } = require("node:fs");
2+
3+
function readClient(value, now = Date.now()) {
4+
try {
5+
const record = JSON.parse(value);
6+
return typeof record?.link === "string" && Date.parse(record.expiresAt) > now
7+
? record.link
8+
: "";
9+
} catch {
10+
return "";
11+
}
12+
}
13+
14+
function createRecord(link, profile) {
15+
const expiration = /<key>ExpirationDate<\/key>\s*<date>([^<]+)<\/date>/.exec(profile)?.[1];
16+
if (!expiration || !Number.isFinite(Date.parse(expiration))) {
17+
throw new Error("The provisioning profile has no valid ExpirationDate.");
18+
}
19+
return JSON.stringify({ link, expiresAt: new Date(expiration).toISOString() });
20+
}
21+
22+
if (require.main === module) {
23+
if (process.argv[2] === "read") {
24+
process.stdout.write(readClient(readFileSync(0, "utf8")));
25+
} else if (process.argv[2] === "create") {
26+
process.stdout.write(createRecord(process.argv[3], readFileSync(process.argv[4], "utf8")));
27+
} else {
28+
throw new Error("Expected read or create.");
29+
}
30+
}
31+
32+
module.exports = { createRecord, readClient };
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const assert = require("node:assert/strict");
2+
const test = require("node:test");
3+
const { createRecord, readClient } = require("./mobile-ios-preview-record.cjs");
4+
5+
test("only clients with an unexpired provisioning profile are reused", () => {
6+
const link = "https://expo.dev/accounts/pingdotgg/projects/t3-code/builds/client";
7+
const profile =
8+
"<plist><dict><key>ExpirationDate</key><date>2027-01-01T00:00:00Z</date></dict></plist>";
9+
const record = createRecord(link, profile);
10+
assert.equal(readClient(record, Date.parse("2026-12-31T00:00:00Z")), link);
11+
assert.equal(readClient(record, Date.parse("2027-01-01T00:00:00Z")), "");
12+
assert.equal(readClient(record, Date.parse("2027-01-02T00:00:00Z")), "");
13+
for (const invalid of [link, "{}", "null", JSON.stringify({ link, expiresAt: "invalid" })]) {
14+
assert.equal(readClient(invalid, 0), "");
15+
}
16+
assert.throws(() => createRecord(link, "<plist></plist>"), /ExpirationDate/);
17+
});

0 commit comments

Comments
 (0)