From cea4c5fcde5fd5ded5164e36ae092b6c6f648044 Mon Sep 17 00:00:00 2001 From: Tim Biggs Date: Fri, 23 Oct 2026 23:29:33 +0000 Subject: [PATCH 1/8] ci(fork): build fork releases and sync upstream nightlies Every push to main builds the Windows desktop app, the Linux x64 server and the Android APK, and publishes them as a nightly-channel prerelease when typecheck and the fork-changed packages' tests pass. Pull requests run the same builds without publishing. A daily T3 scheduled task runs .github/fork/sync.sh to merge upstream's newest nightly tag into main, and opens PRs for conflicts and for fork features upstream has replaced. Co-Authored-By: Claude Opus 5.5 --- .github/fork/daily-sync.md | 89 ++++++ .github/fork/sync.sh | 75 ++++++ .github/fork/upstream-tag | 1 + .github/workflows/fork-release.yml | 420 +++++++++++++++++++++++++++++ FORK.md | 25 ++ 5 files changed, 610 insertions(+) create mode 100644 .github/fork/daily-sync.md create mode 100755 .github/fork/sync.sh create mode 100644 .github/fork/upstream-tag create mode 100644 .github/workflows/fork-release.yml create mode 100644 FORK.md diff --git a/.github/fork/daily-sync.md b/.github/fork/daily-sync.md new file mode 100644 index 0000000000000..10319d64313d8 --- /dev/null +++ b/.github/fork/daily-sync.md @@ -0,0 +1,89 @@ +# Daily fork sync + +A T3 scheduled task on pylon2 follows these steps once a day. Work only in the +sync worktree, `~/work/t3code-sync`, a detached worktree of `~/work/t3code`. +Never touch the main checkout or other worktrees. + +Hard rules: + +- Never push to `upstream`, and never open or comment on anything in + `pingdotgg/t3code`. PRs go to the fork: `gh pr create --repo tebiggs/t3code --base main`. +- Never force-push, never merge a PR, and never push to `main` except through + `sync.sh`. +- pylon2 is small. Run any install, typecheck or test as `heavy `, and + only the targeted ones you need. CI on the PR runs the rest. +- After opening a PR, register it with `link_pull_request`. + +## 1. Merge upstream + +```sh +cd ~/work/t3code-sync +git fetch --quiet origin main && git checkout --quiet --detach origin/main +.github/fork/sync.sh +``` + +Note the `previous=` and `latest=` lines it prints. + +- **Exit 0:** main is current. Go to step 2. +- **Exit 4:** a sync-conflict PR is still open. Report it and go to step 2. +- **Exit 3:** the merge conflicts. Resolve it: + - Take upstream's side unless the conflict touches a feature listed in + `FORK.md`. Then keep the fork behavior working on top of upstream's new code. + - Don't make unrelated changes. + - Commit as `chore(fork): merge upstream ` with the + `Co-Authored-By: Claude ` trailer. + - Push the commit to `sync-conflict/` and open a PR with the same title. + - Start the body with "Merge this with **Create a merge commit**, not squash, so + upstream history stays intact." Then list each conflicted file and how you + resolved it. +- **Any other exit:** report the output. Then run `git merge --abort` if a merge + is in progress, and `git checkout --quiet --detach origin/main`. + +## 2. Check the last release build + +```sh +gh run list --repo tebiggs/t3code --workflow fork-release.yml --branch main \ + --event push --status completed --limit 1 --json conclusion,headSha,url +``` + +If that run failed, read `gh run view --repo tebiggs/t3code --log-failed`. + +- If the failure looks like runner or network trouble, rerun it once with + `gh run rerun --failed`. +- If the code broke, fix it on a `fix/fork-` branch from `origin/main` + and open a PR. Skip this if an open PR already fixes it. + +## 3. Look for upstream features that replace fork features + +Skip this step when `previous` equals `latest`. Otherwise list what upstream +merged in that range: + +```sh +git log --first-parent --format='%s' .. +``` + +Compare those titles with the features in `FORK.md`. Read an upstream PR's diff +when its title alone doesn't tell you. A title ending in `(#N)` links to +`https://github.com/pingdotgg/t3code/pull/N`. + +When upstream now covers what a fork feature does for the user, even if it +works differently, open a PR on `dedup/`. The PR should: + +- remove the fork version +- keep anything upstream doesn't cover +- update `FORK.md` +- link the upstream PRs + +Skip the PR if one is already open for that feature. If the overlap is only +partial, don't open a PR; mention it in the report instead. + +## 4. Report + +Write a few sentences: + +- what merged, or that main was already current +- every PR you opened, with its link +- any failed build and what you did about it +- any partial overlaps + +Leave out steps that found nothing. diff --git a/.github/fork/sync.sh b/.github/fork/sync.sh new file mode 100755 index 0000000000000..f14bd3b847a16 --- /dev/null +++ b/.github/fork/sync.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +# Merges upstream's newest nightly tag into the fork's main and pushes it. +# Runs on pylon2 from the sync worktree; .github/fork/daily-sync.md drives it. +# +# Exit codes: +# 0 main already has the newest tag, or the clean merge was pushed +# 3 the merge conflicts; it is left in progress for resolution +# 4 a sync-conflict PR is still open, so nothing was merged +# 1 anything else +# +# Prints `previous=` and `latest=` so the caller can review the +# upstream range. + +set -euo pipefail + +FORK_REPO=tebiggs/t3code +TAG_FILE=.github/fork/upstream-tag + +main() { + cd "$(git rev-parse --show-toplevel)" + if [[ -n "$(git status --porcelain)" ]]; then + echo "sync: the worktree has local changes; resolve or discard them first" >&2 + exit 1 + fi + + # A later merge on top of an unmerged resolution would conflict the same way. + local open_pr + open_pr="$(gh pr list --repo "$FORK_REPO" --state open --json number,headRefName \ + --jq '[.[] | select(.headRefName | startswith("sync-conflict/")) | .number] | first // empty')" + if [[ -n "$open_pr" ]]; then + echo "sync: waiting on sync-conflict PR #$open_pr" + exit 4 + fi + + git fetch --quiet origin main + local latest current + latest="$(git ls-remote --tags --refs upstream 'refs/tags/v*-nightly.*' | + sed 's#.*refs/tags/##' | sort -V | tail -n 1)" + current="$(git show "origin/main:$TAG_FILE" | tr -d '[:space:]')" + if [[ -z "$latest" || -z "$current" ]]; then + echo "sync: could not read the upstream nightly tags or $TAG_FILE" >&2 + exit 1 + fi + echo "previous=$current" + echo "latest=$latest" + if [[ "$latest" == "$current" ]]; then + echo "sync: main already has $latest" + exit 0 + fi + + git fetch --quiet --no-tags upstream \ + "refs/tags/$latest:refs/tags/$latest" "refs/tags/$current:refs/tags/$current" + git checkout --quiet --detach origin/main + + # --no-ff even when main has no fork commits, so the tag file lands in a merge commit. + if ! git merge --quiet --no-ff --no-commit "$latest"; then + printf '%s\n' "$latest" > "$TAG_FILE" + git add "$TAG_FILE" + echo "sync: merging $latest conflicts in:" + git diff --name-only --diff-filter=U + exit 3 + fi + + printf '%s\n' "$latest" > "$TAG_FILE" + git add "$TAG_FILE" + git commit --quiet \ + -m "chore(fork): merge upstream $latest" \ + -m "Co-Authored-By: Claude " + # Not forced: if main moved since the fetch, this fails and the next run retries. + git push --quiet origin HEAD:refs/heads/main + echo "sync: pushed $(git rev-parse --short=8 HEAD) to main" +} + +# Wrapped in main so bash parses the whole file before the checkout above can replace it. +main "$@" diff --git a/.github/fork/upstream-tag b/.github/fork/upstream-tag new file mode 100644 index 0000000000000..a8a50c17a0bee --- /dev/null +++ b/.github/fork/upstream-tag @@ -0,0 +1 @@ +v0.1.1-nightly.20261020.3438 diff --git a/.github/workflows/fork-release.yml b/.github/workflows/fork-release.yml new file mode 100644 index 0000000000000..44ae9b83b1265 --- /dev/null +++ b/.github/workflows/fork-release.yml @@ -0,0 +1,420 @@ +name: Fork release + +# Fork-only (tebiggs/t3code). Builds what the fork ships: the Windows x64 +# desktop app, the Linux x64 server archive and the Android APK. A push to +# main publishes them as a nightly-channel prerelease, which the fork's +# updaters read. Pull requests run the same checks and builds without +# publishing. Upstream merges reach main through .github/fork/sync.sh on +# pylon2. The workflow token cannot move main itself, because GitHub refuses +# that token any ref update that changes workflow files, and upstream merges +# often do. + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + +concurrency: + group: fork-release-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + prepare: + name: Prepare + if: github.repository == 'tebiggs/t3code' + runs-on: ubuntu-24.04 + timeout-minutes: 5 + outputs: + version: ${{ steps.meta.outputs.version }} + ref: ${{ steps.meta.outputs.ref }} + upstream_tag: ${{ steps.meta.outputs.upstream_tag }} + clerk_publishable_key: ${{ steps.meta.outputs.clerk_publishable_key }} + clerk_jwt_template: ${{ steps.meta.outputs.clerk_jwt_template }} + clerk_cli_oauth_client_id: ${{ steps.meta.outputs.clerk_cli_oauth_client_id }} + relay_url: ${{ steps.meta.outputs.relay_url }} + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + sparse-checkout: | + .github/fork + .env.example + sparse-checkout-cone-mode: false + + # Fork versions keep upstream's nightly shape (cliRelease.ts and + # updateChannels.ts parse it) and sort by build date, then by this + # workflow's run number. + - id: meta + name: Resolve version and public config + shell: bash + env: + REF: ${{ github.event.pull_request.head.sha || github.sha }} + run: | + set -euo pipefail + upstream_tag="$(tr -d '[:space:]' < .github/fork/upstream-tag)" + if [[ ! "$upstream_tag" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)-nightly\.[0-9]{8}\.[0-9]+$ ]]; then + echo "::error::.github/fork/upstream-tag must hold an upstream nightly tag, got '$upstream_tag'." + exit 1 + fi + version="${BASH_REMATCH[1]}-nightly.$(date -u +%Y%m%d).${GITHUB_RUN_NUMBER}" + { + echo "version=$version" + echo "ref=$REF" + echo "upstream_tag=$upstream_tag" + } >> "$GITHUB_OUTPUT" + # .env.example carries the public T3 Connect identifiers that official builds use. + for pair in \ + clerk_publishable_key=T3CODE_CLERK_PUBLISHABLE_KEY \ + clerk_jwt_template=T3CODE_CLERK_JWT_TEMPLATE \ + clerk_cli_oauth_client_id=T3CODE_CLERK_CLI_OAUTH_CLIENT_ID \ + relay_url=T3CODE_RELAY_URL; do + value="$(sed -n "s/^${pair#*=}=//p" .env.example)" + if [[ -z "$value" ]]; then + echo "::error::.env.example has no ${pair#*=}." + exit 1 + fi + echo "${pair%%=*}=$value" >> "$GITHUB_OUTPUT" + done + echo "Building $version from $REF (upstream $upstream_tag)." + + checks: + name: Typecheck and fork tests + needs: prepare + runs-on: ubuntu-24.04 + timeout-minutes: 60 + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ needs.prepare.outputs.ref }} + sparse-checkout: | + /* + !/.repos/ + sparse-checkout-cone-mode: false + + - name: Setup dependencies + uses: ./.github/actions/setup-ci-deps + + - name: Ensure Electron runtime is installed + run: vp run --filter @t3tools/desktop ensure:electron + + - uses: ./.github/actions/setup-apt-mirrors + + - name: Install browser secret helper build libraries + run: sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config + + # Upstream's own CI already passed on the nightly being merged. What can + # break here is fork code against upstream's newest APIs. + - name: Typecheck + run: vp run typecheck + + - id: fork_packages + name: Find packages the fork changes + shell: bash + env: + UPSTREAM_TAG: ${{ needs.prepare.outputs.upstream_tag }} + run: | + set -euo pipefail + git fetch --quiet --no-tags --depth=1 https://github.com/pingdotgg/t3code.git "refs/tags/$UPSTREAM_TAG" + packages=() + while read -r dir; do + [[ -f "$dir/package.json" ]] || continue + jq -e '.scripts.test' "$dir/package.json" > /dev/null || continue + packages+=("$(jq -r .name "$dir/package.json")") + done < <(git diff --name-only FETCH_HEAD HEAD | sed -nE 's#^((apps|packages)/[^/]+)/.*#\1#p' | sort -u) + echo "packages=${packages[*]}" >> "$GITHUB_OUTPUT" + echo "Fork-changed packages with tests: ${packages[*]:-none}" + + - name: Test fork packages + if: steps.fork_packages.outputs.packages != '' + shell: bash + env: + PACKAGES: ${{ steps.fork_packages.outputs.packages }} + run: | + set -euo pipefail + for package in $PACKAGES; do + case "$package" in + @t3tools/web) node apps/web/node_modules/playwright/cli.js install --with-deps --only-shell chromium ;; + t3) node apps/server/node_modules/playwright-core/cli.js install --with-deps --only-shell chromium ;; + esac + vp run --filter "$package" test + done + + bundle: + name: Build JS bundle + needs: prepare + runs-on: ubuntu-24.04 + timeout-minutes: 30 + env: + T3CODE_CLERK_PUBLISHABLE_KEY: ${{ needs.prepare.outputs.clerk_publishable_key }} + T3CODE_CLERK_JWT_TEMPLATE: ${{ needs.prepare.outputs.clerk_jwt_template }} + T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ needs.prepare.outputs.clerk_cli_oauth_client_id }} + T3CODE_RELAY_URL: ${{ needs.prepare.outputs.relay_url }} + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ needs.prepare.outputs.ref }} + sparse-checkout: | + /* + !/.repos/ + sparse-checkout-cone-mode: false + + - name: Setup Vite+ + uses: voidzero-dev/setup-vp@v1 + with: + node-version-file: package.json + cache: true + run-install: false + + - name: Install bundle dependencies + run: vp install --filter=t3... --filter=@t3tools/web... --filter=@t3tools/desktop... --filter=@t3tools/scripts... + + - name: Align package versions to release version + run: node scripts/update-release-package-versions.ts "${{ needs.prepare.outputs.version }}" + + - uses: ./.github/actions/setup-apt-mirrors + + - name: Install browser secret helper build libraries + run: sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config + + - name: Build JS bundle + env: + T3CODE_TELEMETRY_CHANNEL: dev + run: vp run build:desktop + + - name: Upload JS bundle + uses: actions/upload-artifact@v7 + with: + name: js-bundle + path: | + apps/server/dist + apps/desktop/dist-electron + if-no-files-found: error + retention-days: 1 + + # Upstream's per-platform build, on standard runners and without signing + # secrets. The Linux job produces the server archive that pylon2 installs; + # the Windows job waits on it for the bundled WSL runtime. + linux: + name: Linux x64 + needs: [prepare, bundle] + permissions: + actions: read + contents: read + uses: ./.github/workflows/release-desktop.yml + with: + version: ${{ needs.prepare.outputs.version }} + ref: ${{ needs.prepare.outputs.ref }} + release_channel: nightly + relay_client_tracing: false + clerk_publishable_key: ${{ needs.prepare.outputs.clerk_publishable_key }} + clerk_jwt_template: ${{ needs.prepare.outputs.clerk_jwt_template }} + clerk_cli_oauth_client_id: ${{ needs.prepare.outputs.clerk_cli_oauth_client_id }} + relay_url: ${{ needs.prepare.outputs.relay_url }} + label: Linux x64 + runner: ubuntu-24.04 + platform: linux + target: AppImage + arch: x64 + rust_target: x86_64-unknown-linux-gnu + resource_key: linux-x64 + cli_archive: true + + windows: + name: Windows x64 + needs: [prepare, bundle] + permissions: + actions: read + contents: read + uses: ./.github/workflows/release-desktop.yml + with: + version: ${{ needs.prepare.outputs.version }} + ref: ${{ needs.prepare.outputs.ref }} + release_channel: nightly + relay_client_tracing: false + clerk_publishable_key: ${{ needs.prepare.outputs.clerk_publishable_key }} + clerk_jwt_template: ${{ needs.prepare.outputs.clerk_jwt_template }} + clerk_cli_oauth_client_id: ${{ needs.prepare.outputs.clerk_cli_oauth_client_id }} + relay_url: ${{ needs.prepare.outputs.relay_url }} + label: Windows x64 + runner: windows-2025 + platform: win + target: nsis + arch: x64 + rust_target: x86_64-pc-windows-msvc + resource_key: win32-x64 + cli_archive: true + + android: + name: Android APK + needs: prepare + runs-on: ubuntu-24.04 + timeout-minutes: 90 + env: + APP_VARIANT: preview + EXPO_NO_GIT_STATUS: "1" + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + ref: ${{ needs.prepare.outputs.ref }} + sparse-checkout: | + /* + !/.repos/ + sparse-checkout-cone-mode: false + + - name: Setup dependencies + uses: ./.github/actions/setup-ci-deps + + - name: Setup Java + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: "17" + + # The APK's JavaScript ships inside it; OTA updates would swap in + # upstream's preview bundles. + - name: Configure the build + run: | + cp .env.example .env + echo "T3CODE_MOBILE_UPDATES_ENABLED=0" >> .env + + - name: Generate the native project + working-directory: apps/mobile + run: ./node_modules/.bin/expo prebuild --platform android --clean --no-install + + # Release builds sign with the React Native template's debug keystore, + # the same key as the APK already installed from earlier fork builds. + - name: Build release APK + working-directory: apps/mobile/android + run: ./gradlew :app:assembleRelease -PreactNativeArchitectures=arm64-v8a -x lintVitalAnalyzeRelease --no-daemon + + - name: Collect APK + env: + VERSION: ${{ needs.prepare.outputs.version }} + run: | + mkdir -p release-android + cp apps/mobile/android/app/build/outputs/apk/release/app-release.apk \ + "release-android/t3code-android-${VERSION}-arm64-v8a.apk" + + - name: Upload APK + uses: actions/upload-artifact@v7 + with: + name: android-apk + path: release-android/*.apk + if-no-files-found: error + retention-days: 1 + + # Pull requests stop after assembling the assets, so a renamed build output + # fails there rather than on main. + publish: + name: Release assets + needs: [prepare, checks, linux, windows, android] + runs-on: ubuntu-24.04 + timeout-minutes: 20 + permissions: + contents: write + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + VERSION: ${{ needs.prepare.outputs.version }} + REF: ${{ needs.prepare.outputs.ref }} + UPSTREAM_TAG: ${{ needs.prepare.outputs.upstream_tag }} + steps: + - name: Download Windows desktop + uses: actions/download-artifact@v8 + with: + name: desktop-win-x64 + path: release-assets + + - name: Download CLI archives + uses: actions/download-artifact@v8 + with: + pattern: cli-* + merge-multiple: true + path: release-assets + + - name: Download APK + uses: actions/download-artifact@v8 + with: + name: android-apk + path: release-assets + + # electron-updater reads nightly.yml; the build job suffixed it with the arch. + - name: Prepare release assets + shell: bash + run: | + set -euo pipefail + cd release-assets + rm -f builder-debug.yml + mv nightly-win-x64.yml nightly.yml + sha256sum t3-*.tar.gz t3-*.zip > SHA256SUMS + ls -l + + - name: Publish release + if: github.event_name == 'push' + shell: bash + run: | + set -euo pipefail + notes="Fork build of [upstream ${UPSTREAM_TAG}](https://github.com/pingdotgg/t3code/releases/tag/${UPSTREAM_TAG}) plus the features in [FORK.md](https://github.com/${GH_REPO}/blob/${REF}/FORK.md), from ${REF}." + gh release create "v${VERSION}" release-assets/* \ + --target "$REF" \ + --prerelease \ + --title "T3 Code v${VERSION} (fork)" \ + --notes "$notes" + + # Keeps the newest few so a client mid-update still finds its files. + - name: Prune old releases + if: github.event_name == 'push' + shell: bash + run: | + set -euo pipefail + gh release list --limit 100 --json tagName,isPrerelease,createdAt \ + --jq '[.[] | select(.isPrerelease and (.tagName | test("-nightly\\.")))] | sort_by(.createdAt) | reverse | .[5:] | .[].tagName' | + while read -r tag; do + echo "Deleting $tag" + gh release delete "$tag" --cleanup-tag --yes + done + + # Upstream's workflows wait forever for runners this fork doesn't have. This + # re-disables any that an upstream merge adds. release-desktop.yml stays + # enabled because this workflow calls it. + disable_upstream_workflows: + name: Disable upstream workflows + if: github.repository == 'tebiggs/t3code' && github.event_name == 'push' + runs-on: ubuntu-24.04 + timeout-minutes: 5 + permissions: + actions: write + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + steps: + - name: Disable upstream workflows and cancel their runs + shell: bash + run: | + set -euo pipefail + gh api "repos/$GH_REPO/actions/workflows" --paginate \ + --jq '.workflows[] | select(.state == "active") | [.id, .path] | @tsv' | + while IFS=$'\t' read -r id path; do + case "$path" in + .github/workflows/fork-release.yml | .github/workflows/release-desktop.yml) continue ;; + .github/workflows/*) ;; + *) continue ;; + esac + echo "Disabling $path" + gh api -X PUT "repos/$GH_REPO/actions/workflows/$id/disable" --silent + gh run list --workflow "$id" --limit 100 --json databaseId,status \ + --jq '.[] | select(.status != "completed") | .databaseId' | + while read -r run; do + gh run cancel "$run" || true + done + done diff --git a/FORK.md b/FORK.md new file mode 100644 index 0000000000000..da8bc66ebb835 --- /dev/null +++ b/FORK.md @@ -0,0 +1,25 @@ +# Fork notes + +This is Tim Biggs's fork of T3 Code. `main` is upstream's newest nightly plus +the features listed below. + +- **Releases.** Every push to `main` builds the Windows x64 desktop app, the + Linux x64 server and the Android APK. The build runs in + `.github/workflows/fork-release.yml`. When typecheck and the tests for + fork-changed packages pass, it publishes everything as a prerelease here. + The fork's apps update from these releases. Pull requests get the same + checks and builds but publish nothing. +- **Upstream sync.** A T3 scheduled task on pylon2 follows + `.github/fork/daily-sync.md` once a day: + - It merges upstream's newest nightly tag into `main`. + - It opens a `sync-conflict/*` PR when the merge conflicts. + - It opens a `dedup/*` PR when upstream ships something that replaces a + fork feature. +- **Merge sync-conflict PRs with a merge commit, never squash.** Squashing + drops upstream's history, and every later sync would then conflict. + +## Fork features + +Give each feature one line: its PR, what it does, and its main paths. The daily +sync compares upstream changes against this list. Add the line in the PR that +adds the feature, and remove it in the PR that drops the feature. From 71452ed98fc6e0ee02b88766a14df4f468c31dad Mon Sep 17 00:00:00 2001 From: Tim Biggs Date: Fri, 23 Oct 2026 23:32:04 +0000 Subject: [PATCH 2/8] ci(fork): run the release checks on stacked pull requests too Co-Authored-By: Claude Opus 5.5 --- .github/workflows/fork-release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/fork-release.yml b/.github/workflows/fork-release.yml index 44ae9b83b1265..abea2e3f711dd 100644 --- a/.github/workflows/fork-release.yml +++ b/.github/workflows/fork-release.yml @@ -14,8 +14,6 @@ on: branches: - main pull_request: - branches: - - main permissions: contents: read From 189c26af180be6b79dc0970d558cce6fa3b90c7b Mon Sep 17 00:00:00 2001 From: Tim Biggs Date: Fri, 23 Oct 2026 23:33:49 +0000 Subject: [PATCH 3/8] ci(fork): test only the files the fork changes Co-Authored-By: Claude Opus 5.5 --- .github/workflows/fork-release.yml | 52 ++++++++++++++++++------------ FORK.md | 4 +-- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/.github/workflows/fork-release.yml b/.github/workflows/fork-release.yml index abea2e3f711dd..5bd51e9c83013 100644 --- a/.github/workflows/fork-release.yml +++ b/.github/workflows/fork-release.yml @@ -113,36 +113,48 @@ jobs: - name: Typecheck run: vp run typecheck - - id: fork_packages - name: Find packages the fork changes + # Runs the test files the fork changes and the tests beside source files + # it changes, through each package's own test script. + - name: Test what the fork changes shell: bash env: UPSTREAM_TAG: ${{ needs.prepare.outputs.upstream_tag }} run: | set -euo pipefail git fetch --quiet --no-tags --depth=1 https://github.com/pingdotgg/t3code.git "refs/tags/$UPSTREAM_TAG" - packages=() - while read -r dir; do - [[ -f "$dir/package.json" ]] || continue - jq -e '.scripts.test' "$dir/package.json" > /dev/null || continue - packages+=("$(jq -r .name "$dir/package.json")") - done < <(git diff --name-only FETCH_HEAD HEAD | sed -nE 's#^((apps|packages)/[^/]+)/.*#\1#p' | sort -u) - echo "packages=${packages[*]}" >> "$GITHUB_OUTPUT" - echo "Fork-changed packages with tests: ${packages[*]:-none}" - - - name: Test fork packages - if: steps.fork_packages.outputs.packages != '' - shell: bash - env: - PACKAGES: ${{ steps.fork_packages.outputs.packages }} - run: | - set -euo pipefail - for package in $PACKAGES; do + declare -A tests + while read -r file; do + [[ "$file" =~ ^((apps|packages)/[^/]+)/(.+)$ ]] || continue + dir="${BASH_REMATCH[1]}" + rel="${BASH_REMATCH[3]}" + if [[ "$rel" =~ \.test\.tsx?$ ]]; then + candidates=("$rel") + else + base="${rel%.*}" + candidates=("$base.test.ts" "$base.test.tsx" "$base.browser.test.ts" "$base.browser.test.tsx") + fi + for candidate in "${candidates[@]}"; do + if [[ -f "$dir/$candidate" ]]; then + tests[$dir]+=" $candidate" + fi + done + done < <(git diff --name-only FETCH_HEAD HEAD) + + if [[ ${#tests[@]} -eq 0 ]]; then + echo "The fork changes no tested files." + exit 0 + fi + for dir in "${!tests[@]}"; do + package="$(jq -r .name "$dir/package.json")" + files="$(tr ' ' '\n' <<< "${tests[$dir]}" | sort -u | xargs)" + echo "::group::$package: $files" case "$package" in @t3tools/web) node apps/web/node_modules/playwright/cli.js install --with-deps --only-shell chromium ;; t3) node apps/server/node_modules/playwright-core/cli.js install --with-deps --only-shell chromium ;; esac - vp run --filter "$package" test + # shellcheck disable=SC2086 # one argument per test file + vp run --filter "$package" test $files + echo "::endgroup::" done bundle: diff --git a/FORK.md b/FORK.md index da8bc66ebb835..85afa43b9b4ff 100644 --- a/FORK.md +++ b/FORK.md @@ -5,8 +5,8 @@ the features listed below. - **Releases.** Every push to `main` builds the Windows x64 desktop app, the Linux x64 server and the Android APK. The build runs in - `.github/workflows/fork-release.yml`. When typecheck and the tests for - fork-changed packages pass, it publishes everything as a prerelease here. + `.github/workflows/fork-release.yml`. When typecheck and the tests + covering the fork's changes pass, it publishes everything as a prerelease here. The fork's apps update from these releases. Pull requests get the same checks and builds but publish nothing. - **Upstream sync.** A T3 scheduled task on pylon2 follows From f4379caf7bacb76fe83fed17fea11fa4a09ae756 Mon Sep 17 00:00:00 2001 From: Tim Biggs Date: Fri, 23 Oct 2026 23:37:42 +0000 Subject: [PATCH 4/8] ci(fork): initialize the test list so an empty fork diff passes Co-Authored-By: Claude Opus 5.5 --- .github/workflows/fork-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fork-release.yml b/.github/workflows/fork-release.yml index 5bd51e9c83013..fafac1677bf6c 100644 --- a/.github/workflows/fork-release.yml +++ b/.github/workflows/fork-release.yml @@ -122,7 +122,7 @@ jobs: run: | set -euo pipefail git fetch --quiet --no-tags --depth=1 https://github.com/pingdotgg/t3code.git "refs/tags/$UPSTREAM_TAG" - declare -A tests + declare -A tests=() while read -r file; do [[ "$file" =~ ^((apps|packages)/[^/]+)/(.+)$ ]] || continue dir="${BASH_REMATCH[1]}" From d45e712ba3cac2a234a2f958302af22dde853a25 Mon Sep 17 00:00:00 2001 From: Tim Biggs Date: Fri, 23 Oct 2026 23:47:26 +0000 Subject: [PATCH 5/8] ci(fork): build the Windows app on Linux and verify it on Windows Co-Authored-By: Claude Opus 5.5 --- .github/workflows/fork-release.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fork-release.yml b/.github/workflows/fork-release.yml index fafac1677bf6c..85af6ea678a15 100644 --- a/.github/workflows/fork-release.yml +++ b/.github/workflows/fork-release.yml @@ -255,7 +255,11 @@ jobs: clerk_cli_oauth_client_id: ${{ needs.prepare.outputs.clerk_cli_oauth_client_id }} relay_url: ${{ needs.prepare.outputs.relay_url }} label: Windows x64 - runner: windows-2025 + # Built on Linux like upstream's arm64 target: on GitHub's Windows image, + # Git Bash's GNU tar shadows the system bsdtar and cannot unpack C:\ paths. + # The Windows runner only verifies the natives and smoke-tests the CLI. + runner: ubuntu-24.04 + verify_runner: windows-2025 platform: win target: nsis arch: x64 From ca203f5947392aff8c57357a42029f7b352582db Mon Sep 17 00:00:00 2001 From: Tim Biggs Date: Sat, 24 Oct 2026 00:11:04 +0000 Subject: [PATCH 6/8] docs(fork): fall back to reporting when a rerun is refused Co-Authored-By: Claude Opus 5.5 --- .github/fork/daily-sync.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/fork/daily-sync.md b/.github/fork/daily-sync.md index 10319d64313d8..eb982266260f2 100644 --- a/.github/fork/daily-sync.md +++ b/.github/fork/daily-sync.md @@ -49,7 +49,8 @@ gh run list --repo tebiggs/t3code --workflow fork-release.yml --branch main \ If that run failed, read `gh run view --repo tebiggs/t3code --log-failed`. - If the failure looks like runner or network trouble, rerun it once with - `gh run rerun --failed`. + `gh run rerun --repo tebiggs/t3code --failed`. If the token lacks + permission to rerun, report the failure instead. - If the code broke, fix it on a `fix/fork-` branch from `origin/main` and open a PR. Skip this if an open PR already fixes it. From 8c8468c60a06379a631a825d19c23bf309398222 Mon Sep 17 00:00:00 2001 From: Tim Biggs Date: Sat, 24 Oct 2026 03:40:58 +0000 Subject: [PATCH 7/8] docs(fork): keep host details out of the fork docs The sync docs and comments named the machine that runs the sync and its job wrapper. They now defer those details to the scheduled task's prompt and the host's own instructions. Co-Authored-By: Claude Opus 5.5 --- .github/fork/daily-sync.md | 14 ++++++++------ .github/fork/sync.sh | 3 ++- .github/workflows/fork-release.yml | 10 +++++----- FORK.md | 8 ++++---- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/fork/daily-sync.md b/.github/fork/daily-sync.md index eb982266260f2..c1c634f3c52ec 100644 --- a/.github/fork/daily-sync.md +++ b/.github/fork/daily-sync.md @@ -1,8 +1,9 @@ # Daily fork sync -A T3 scheduled task on pylon2 follows these steps once a day. Work only in the -sync worktree, `~/work/t3code-sync`, a detached worktree of `~/work/t3code`. -Never touch the main checkout or other worktrees. +A T3 scheduled task follows these steps once a day. Its prompt names the sync +worktree: a detached worktree of the fork, with an `upstream` remote for +`pingdotgg/t3code`, used only for this sync. Work only there, and never touch +other checkouts or worktrees. Hard rules: @@ -10,14 +11,15 @@ Hard rules: `pingdotgg/t3code`. PRs go to the fork: `gh pr create --repo tebiggs/t3code --base main`. - Never force-push, never merge a PR, and never push to `main` except through `sync.sh`. -- pylon2 is small. Run any install, typecheck or test as `heavy `, and - only the targeted ones you need. CI on the PR runs the rest. +- Follow the host's own instructions for installs, typechecks and tests, and + run only the targeted ones you need. CI on the PR runs the rest. - After opening a PR, register it with `link_pull_request`. ## 1. Merge upstream +From the sync worktree: + ```sh -cd ~/work/t3code-sync git fetch --quiet origin main && git checkout --quiet --detach origin/main .github/fork/sync.sh ``` diff --git a/.github/fork/sync.sh b/.github/fork/sync.sh index f14bd3b847a16..59d8563d98ebe 100755 --- a/.github/fork/sync.sh +++ b/.github/fork/sync.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # Merges upstream's newest nightly tag into the fork's main and pushes it. -# Runs on pylon2 from the sync worktree; .github/fork/daily-sync.md drives it. +# .github/fork/daily-sync.md drives it. Needs an `upstream` remote for +# pingdotgg/t3code. # # Exit codes: # 0 main already has the newest tag, or the clean merge was pushed diff --git a/.github/workflows/fork-release.yml b/.github/workflows/fork-release.yml index 85af6ea678a15..b55e792cdbe8f 100644 --- a/.github/workflows/fork-release.yml +++ b/.github/workflows/fork-release.yml @@ -4,10 +4,10 @@ name: Fork release # desktop app, the Linux x64 server archive and the Android APK. A push to # main publishes them as a nightly-channel prerelease, which the fork's # updaters read. Pull requests run the same checks and builds without -# publishing. Upstream merges reach main through .github/fork/sync.sh on -# pylon2. The workflow token cannot move main itself, because GitHub refuses -# that token any ref update that changes workflow files, and upstream merges -# often do. +# publishing. Upstream merges reach main through .github/fork/sync.sh, run by +# the daily sync task. The workflow token cannot move main itself, because +# GitHub refuses that token any ref update that changes workflow files, and +# upstream merges often do. on: push: @@ -211,7 +211,7 @@ jobs: retention-days: 1 # Upstream's per-platform build, on standard runners and without signing - # secrets. The Linux job produces the server archive that pylon2 installs; + # secrets. The Linux job produces the server archive that fork servers install; # the Windows job waits on it for the bundled WSL runtime. linux: name: Linux x64 diff --git a/FORK.md b/FORK.md index 85afa43b9b4ff..a0c98ae7ac3f8 100644 --- a/FORK.md +++ b/FORK.md @@ -1,7 +1,7 @@ # Fork notes -This is Tim Biggs's fork of T3 Code. `main` is upstream's newest nightly plus -the features listed below. +This is a fork of T3 Code. `main` is upstream's newest nightly plus the +features listed below. - **Releases.** Every push to `main` builds the Windows x64 desktop app, the Linux x64 server and the Android APK. The build runs in @@ -9,8 +9,8 @@ the features listed below. covering the fork's changes pass, it publishes everything as a prerelease here. The fork's apps update from these releases. Pull requests get the same checks and builds but publish nothing. -- **Upstream sync.** A T3 scheduled task on pylon2 follows - `.github/fork/daily-sync.md` once a day: +- **Upstream sync.** A T3 scheduled task follows `.github/fork/daily-sync.md` + once a day: - It merges upstream's newest nightly tag into `main`. - It opens a `sync-conflict/*` PR when the merge conflicts. - It opens a `dedup/*` PR when upstream ships something that replaces a From a0c940d757549f4d1d85dd9f41b9ee7cd1aa95ce Mon Sep 17 00:00:00 2001 From: Tim Biggs Date: Sat, 24 Oct 2026 03:59:00 +0000 Subject: [PATCH 8/8] fix(fork): address the adversarial review of the sync pipeline - sync.sh exits 1, not 3, when git refuses a merge without conflicts, so the sync task never commits a tag bump without upstream's code. Failed commands now say which one failed. - The open sync-conflict PR check looks past gh's default 30 PRs. - The daily task reruns a whole failed build instead of only its failed jobs, because the passing jobs' artifacts expire after a day, and only when that build is still main's newest and on its first attempt. - The fork test selection covers the scripts package. Co-Authored-By: Claude Opus 5.5 --- .github/fork/daily-sync.md | 12 ++++++++---- .github/fork/sync.sh | 13 +++++++++++-- .github/workflows/fork-release.yml | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/fork/daily-sync.md b/.github/fork/daily-sync.md index c1c634f3c52ec..31288c341c450 100644 --- a/.github/fork/daily-sync.md +++ b/.github/fork/daily-sync.md @@ -45,14 +45,18 @@ Note the `previous=` and `latest=` lines it prints. ```sh gh run list --repo tebiggs/t3code --workflow fork-release.yml --branch main \ - --event push --status completed --limit 1 --json conclusion,headSha,url + --event push --status completed --limit 1 \ + --json databaseId,attempt,conclusion,headSha,url ``` If that run failed, read `gh run view --repo tebiggs/t3code --log-failed`. -- If the failure looks like runner or network trouble, rerun it once with - `gh run rerun --repo tebiggs/t3code --failed`. If the token lacks - permission to rerun, report the failure instead. +- If the failure looks like runner or network trouble, rerun the whole run with + `gh run rerun --repo tebiggs/t3code`, but only when `attempt` is 1 and + `headSha` is still `origin/main`. A newer build replaces an older one. + Don't use `--failed`: build artifacts expire after a day, so the retried jobs + couldn't download what the passing jobs built. If the token lacks permission + to rerun, report the failure instead. - If the code broke, fix it on a `fix/fork-` branch from `origin/main` and open a PR. Skip this if an open PR already fixes it. diff --git a/.github/fork/sync.sh b/.github/fork/sync.sh index 59d8563d98ebe..e7c4092e8db22 100755 --- a/.github/fork/sync.sh +++ b/.github/fork/sync.sh @@ -12,7 +12,9 @@ # Prints `previous=` and `latest=` so the caller can review the # upstream range. -set -euo pipefail +set -Eeuo pipefail +# The quiet git commands would otherwise fail without saying which one did. +trap 'echo "sync: failed: $BASH_COMMAND" >&2' ERR FORK_REPO=tebiggs/t3code TAG_FILE=.github/fork/upstream-tag @@ -26,7 +28,7 @@ main() { # A later merge on top of an unmerged resolution would conflict the same way. local open_pr - open_pr="$(gh pr list --repo "$FORK_REPO" --state open --json number,headRefName \ + open_pr="$(gh pr list --repo "$FORK_REPO" --state open --limit 1000 --json number,headRefName \ --jq '[.[] | select(.headRefName | startswith("sync-conflict/")) | .number] | first // empty')" if [[ -n "$open_pr" ]]; then echo "sync: waiting on sync-conflict PR #$open_pr" @@ -55,6 +57,13 @@ main() { # --no-ff even when main has no fork commits, so the tag file lands in a merge commit. if ! git merge --quiet --no-ff --no-commit "$latest"; then + # Exit 3 promises a merge stopped on conflicts. Any other refusal, such as + # unrelated histories, leaves nothing to resolve. + if [[ -z "$(git ls-files --unmerged)" ]]; then + echo "sync: merging $latest failed without conflicts" >&2 + git merge --abort 2>/dev/null || true + exit 1 + fi printf '%s\n' "$latest" > "$TAG_FILE" git add "$TAG_FILE" echo "sync: merging $latest conflicts in:" diff --git a/.github/workflows/fork-release.yml b/.github/workflows/fork-release.yml index b55e792cdbe8f..b384fb4f42827 100644 --- a/.github/workflows/fork-release.yml +++ b/.github/workflows/fork-release.yml @@ -124,7 +124,7 @@ jobs: git fetch --quiet --no-tags --depth=1 https://github.com/pingdotgg/t3code.git "refs/tags/$UPSTREAM_TAG" declare -A tests=() while read -r file; do - [[ "$file" =~ ^((apps|packages)/[^/]+)/(.+)$ ]] || continue + [[ "$file" =~ ^((apps|packages)/[^/]+|scripts)/(.+)$ ]] || continue dir="${BASH_REMATCH[1]}" rel="${BASH_REMATCH[3]}" if [[ "$rel" =~ \.test\.tsx?$ ]]; then