Skip to content

Commit ad3f49a

Browse files
committed
ci(fork): run fork tests in Fork Sync and report Fork CI failures
A Fork Sync merge without conflicts went to main while it broke a fork feature (pingdotgg#37), and Fork CI stayed red on main for a day (pingdotgg#38). Fork Sync now runs the test files that differ from upstream before it pushes. A failed Fork CI run on main calls the repair agent, like Fork Sync and Fork Release.
1 parent cfc2f0e commit ad3f49a

4 files changed

Lines changed: 53 additions & 8 deletions

File tree

‎.github/workflows/fork-ci.yml‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ name: Fork CI
33
# The commands of ci.yml on GitHub-hosted runners. ci.yml uses upstream's
44
# Blacksmith runners, which this fork does not have, so the fork disables it.
55
# Limit: this file copies the ci.yml commands by hand. When upstream changes
6-
# them, update this file. See docs/fork.md.
6+
# them, update this file. A failure on main calls the repair agent. See docs/fork.md.
77

88
on:
99
push:
1010
branches:
1111
- main
1212
workflow_dispatch:
13+
inputs:
14+
notify_agent:
15+
description: Call the agent webhook if this run fails. The agent sets false on its own retries.
16+
type: boolean
17+
default: true
1318

1419
permissions:
1520
contents: read
@@ -162,3 +167,27 @@ jobs:
162167
cargo fmt --manifest-path "native/$crate/Cargo.toml" -- --check
163168
cargo test --locked --manifest-path "native/$crate/Cargo.toml"
164169
done
170+
171+
# Starts the repair agent, like Fork Sync and Fork Release. Without it, a red
172+
# main goes unnoticed. Off until the T3_AGENT_WEBHOOK_URL secret is set.
173+
notify_agent:
174+
name: Notify repair agent
175+
needs: [lint, typecheck, build, test, test_web, test_server, rust]
176+
if: failure() && github.event.inputs.notify_agent != 'false'
177+
runs-on: ubuntu-24.04
178+
timeout-minutes: 5
179+
permissions:
180+
actions: read
181+
steps:
182+
- uses: actions/checkout@v6
183+
with:
184+
sparse-checkout: scripts/fork-notify-agent.sh
185+
sparse-checkout-cone-mode: false
186+
- name: Call agent webhook
187+
env:
188+
GH_TOKEN: ${{ github.token }}
189+
WEBHOOK_URL: ${{ secrets.T3_AGENT_WEBHOOK_URL }}
190+
CF_ACCESS_CLIENT_ID: ${{ secrets.CF_ACCESS_CLIENT_ID }}
191+
CF_ACCESS_CLIENT_SECRET: ${{ secrets.CF_ACCESS_CLIENT_SECRET }}
192+
NEEDS_JSON: ${{ toJSON(needs) }}
193+
run: scripts/fork-notify-agent.sh

‎.github/workflows/fork-sync.yml‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Fork Sync
22

33
# Merges pingdotgg/t3code main into fork main once a day. Main only moves
44
# forward: no rebase and no force-push, so checkouts and tags stay valid.
5-
# A merge conflict or a failed typecheck stops the sync, reports it in an
6-
# issue and calls the repair agent. See docs/fork.md.
5+
# A merge conflict, a failed typecheck or a failed fork test stops the sync,
6+
# reports it in an issue and calls the repair agent. See docs/fork.md.
77

88
on:
99
schedule:
@@ -81,6 +81,21 @@ jobs:
8181
name: Typecheck
8282
run: vp run typecheck
8383

84+
# A merge without conflicts can still break a fork feature. The fork tests
85+
# are the test files that differ from upstream main after the merge.
86+
- id: fork_tests
87+
if: steps.merge.outputs.merged == 'true'
88+
name: Fork tests
89+
run: |
90+
set -euo pipefail
91+
mapfile -t files < <(git diff --name-only --diff-filter=AMR upstream/main HEAD -- '*.test.ts' '*.test.tsx')
92+
if (( ${#files[@]} == 0 )); then
93+
echo "No fork test files."
94+
exit 0
95+
fi
96+
printf '%s\n' "${files[@]}"
97+
vp test run "${files[@]}"
98+
8499
# A fast-forward push. If main moved during the run, merge the new main
85100
# into the sync commit and push again. Main is never force-pushed.
86101
- name: Push to main
@@ -103,7 +118,7 @@ jobs:
103118
if: failure()
104119
env:
105120
GH_TOKEN: ${{ github.token }}
106-
REASON: ${{ steps.merge.outputs.reason || (steps.checks.outcome == 'failure' && 'typecheck failed') || 'workflow step failed' }}
121+
REASON: ${{ steps.merge.outputs.reason || (steps.checks.outcome == 'failure' && 'typecheck failed') || (steps.fork_tests.outcome == 'failure' && 'fork tests failed') || 'workflow step failed' }}
107122
run: |
108123
set -euo pipefail
109124
run_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"

‎docs/fork.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ The installed app updates itself from the fork releases through the built-in upd
77

88
Fork main only moves forward. Nothing rebases or force-pushes it.
99

10-
- `.github/workflows/fork-sync.yml` merges `pingdotgg/t3code` main into fork main every day. It typechecks the merge and pushes it as a fast-forward. If main moved during the run, it merges the new main and pushes again.
11-
- If the merge conflicts or the typecheck fails, the sync comments on the issue "Fork sync: upstream merge failed" and stops.
10+
- `.github/workflows/fork-sync.yml` merges `pingdotgg/t3code` main into fork main every day. It typechecks the merge, runs the fork tests and pushes it as a fast-forward. The fork tests are the test files that differ from upstream main. If main moved during the run, it merges the new main and pushes again.
11+
- If the merge conflicts, the typecheck fails or a fork test fails, the sync comments on the issue "Fork sync: upstream merge failed" and stops.
1212
- `.github/workflows/fork-release.yml` builds the desktop apps. It runs when a push to main changes the app shell (`apps/desktop` without its tests, icons, build config, dependencies), once a day, and on manual dispatch. If the commit already has a release, it stops early. Server and web changes reach the machines without a release, see "Live server updates" and "Deploy to the VPS".
1313
- The release builds macOS arm64 (signed) and Windows x64 (unsigned) at the same time. Each platform publishes to the release when its build is done, so the Mac does not wait for Windows.
1414
- The release carries `nightly-mac.yml` and `nightly.yml` for electron-updater. Until the Windows build adds `nightly.yml`, Windows apps find no update in the new release.
15-
- If a sync or a release fails, its `notify_agent` job runs `scripts/fork-notify-agent.sh`. The script posts the run to `T3_AGENT_WEBHOOK_URL`, a webhook scheduled task on a T3 server that starts a repair agent. A manual run with `notify_agent=false` does not post. A failure right after a failure of the same workflow does not post either, because the agent that the first failure started watches the next run.
15+
- If a sync, a release or a Fork CI run fails, its `notify_agent` job runs `scripts/fork-notify-agent.sh`. The script posts the run to `T3_AGENT_WEBHOOK_URL`, a webhook scheduled task on a T3 server that starts a repair agent. A manual run with `notify_agent=false` does not post. A failure right after a failure of the same workflow does not post either, because the agent that the first failure started watches the next run.
1616
- `.github/workflows/fork-ci.yml` runs the `ci.yml` commands on GitHub-hosted runners for each push to main. `ci.yml` needs upstream's Blacksmith runners, so it is disabled on the fork.
1717
- To see all fork changes, run `git diff upstream/main...main`.
1818
- The top of `README.md` lists the fork features and fixes, up to the first `---` line. A pull request that adds, removes or changes a fork feature or fix updates its line in that list.
1919
- If a Fork Sync merge conflicts in `README.md`, keep the fork section on top and take the upstream text below the `---` line.
20+
- A merge without conflicts can still break a fork feature. Each fork feature that changes upstream behaviour needs a test of that behaviour, so that the fork tests catch the break.
2021

2122
The builds use the `nightly` update channel, the app id `com.t3tools.t3code` and the data directory `~/.t3`.
2223
They replace the upstream Nightly app and keep its data.

‎scripts/fork-notify-agent.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
# Posts a failed fork workflow run to the repair agent webhook (a T3 scheduled task).
3-
# Called by the notify_agent job of fork-release.yml and fork-sync.yml. See docs/fork.md.
3+
# Called by the notify_agent job of fork-ci.yml, fork-release.yml and fork-sync.yml. See docs/fork.md.
44
# Env: WEBHOOK_URL, CF_ACCESS_CLIENT_ID, CF_ACCESS_CLIENT_SECRET, GH_TOKEN, NEEDS_JSON
55
# (the workflow's toJSON(needs)), plus the default GITHUB_* variables.
66
set -euo pipefail

0 commit comments

Comments
 (0)