Skip to content

Commit 41731ed

Browse files
committed
Add upstream sync automation
1 parent d61147b commit 41731ed

9 files changed

Lines changed: 3704 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: sync-upstream
2+
3+
on:
4+
schedule:
5+
- cron: "0 */3 * * *"
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: sync-upstream
10+
cancel-in-progress: true
11+
12+
jobs:
13+
sync:
14+
runs-on: ubuntu-24.04
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
token: ${{ secrets.UPSTREAM_SYNC_TOKEN }}
21+
22+
- name: Setup Bun
23+
uses: ./.github/actions/setup-bun
24+
25+
- name: Sync upstream
26+
run: ./script/sync-upstream.ts
27+
env:
28+
GH_TOKEN: ${{ secrets.UPSTREAM_SYNC_TOKEN }}
29+
UPSTREAM_SYNC_TOKEN: ${{ secrets.UPSTREAM_SYNC_TOKEN }}

docs/upstream-sync.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Upstream Sync Playbook
2+
3+
## Baseline Snapshot (2026-02-05)
4+
- Upstream repo/branch: `anomalyco/opencode` `dev`
5+
- Fork repo/branch: `pRizz/opencode` `dev`
6+
- Merge base: `dac099a4892689d11abedb0fcc1098b50e0958c8` (source: `docs/upstream-sync/merge-base.txt`)
7+
- Fork commits ahead: 410 (source: `docs/upstream-sync/fork-commits.log`)
8+
- Upstream first-parent commits behind: 1307 (source: `docs/upstream-sync/upstream-first-parent.txt`)
9+
- Batch boundaries (every 200 commits): 6 (source: `docs/upstream-sync/boundary-commits.txt`)
10+
11+
## Patchset Report
12+
- Fork commits: `docs/upstream-sync/fork-commits.log`
13+
- Range-diff: `docs/upstream-sync/range-diff.txt`
14+
- Upstream first-parent list: `docs/upstream-sync/upstream-first-parent.txt`
15+
- Boundary commits: `docs/upstream-sync/boundary-commits.txt`
16+
17+
To regenerate:
18+
```bash
19+
git fetch upstream --tags
20+
git branch -f parent-dev upstream/dev
21+
git log --oneline parent-dev..dev > docs/upstream-sync/fork-commits.log
22+
git range-diff parent-dev...dev > docs/upstream-sync/range-diff.txt
23+
MERGE_BASE=$(git merge-base parent-dev dev)
24+
echo "$MERGE_BASE" > docs/upstream-sync/merge-base.txt
25+
git rev-list --first-parent ${MERGE_BASE}..parent-dev > docs/upstream-sync/upstream-first-parent.txt
26+
awk 'NR % 200 == 0 {print NR ":" $0}' docs/upstream-sync/upstream-first-parent.txt > docs/upstream-sync/boundary-commits.txt
27+
wc -l docs/upstream-sync/upstream-first-parent.txt > docs/upstream-sync/upstream-first-parent.count
28+
```
29+
30+
## Must-Keep Fork Areas (Verify and Extend)
31+
- `docs/docker-install-fork.md` (fork installation guidance)
32+
- `docs/README.md` references fork-specific usage
33+
- Any fork-only auth features or configuration paths (audit during conflict resolution)
34+
35+
## Known Conflict Notes
36+
- None recorded yet. Add entries here as they appear during the merge train.
37+
38+
## Merge Train Procedure (One-Time Catch-Up)
39+
1. Pause new work on `dev` until catch-up completes.
40+
2. Use `docs/upstream-sync/boundary-commits.txt` to select boundary commits.
41+
3. For each boundary commit:
42+
- Create a branch `sync/catchup-<n>` from `dev`.
43+
- Merge the boundary commit, resolve conflicts, and update this doc with resolutions.
44+
- Regenerate SDK artifacts if the SDK changes: `./packages/sdk/js/script/build.ts`.
45+
- Open a PR to `dev` labeled `sync` and merge after CI passes.
46+
47+
## Ongoing Sync Automation
48+
- Script: `script/sync-upstream.ts`
49+
- Workflow: `.github/workflows/sync-upstream.yml` (runs every 3 hours)
50+
- Secrets required: `UPSTREAM_SYNC_TOKEN` (fine-grained PAT or GitHub App token)
51+
- Workflow behavior:
52+
- Updates `parent-dev` to match `upstream/dev` (force push).
53+
- Opens a sync PR when upstream is ahead.
54+
- Enables auto-merge once checks pass.
55+
- On conflict, opens an issue labeled `sync-conflict` with merge details.
56+
57+
## Repo Settings Checklist
58+
- Enable auto-merge on the repository.
59+
- Require `test` and `typecheck` checks on `dev`.
60+
- Allow merge commits.
61+
- Ensure the PAT/App used by `UPSTREAM_SYNC_TOKEN` can create PRs, labels, and enable auto-merge.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
200:3577d829c2b0002e3697932b71a22dd9fbabc28a
2+
400:7ad165fbdce352786c52b99503cc6f34422e3084
3+
600:32a0dcedcbc01243ecc81d4d0144fb22138c3088
4+
800:75cccc305aea05bc605da93ba441e0891461e8df
5+
1000:b746c006cfacb1729e40829fa598fb77f94e1e9a
6+
1200:4ddfa86e7fe8d6eb23ab973fdf65175cd8a750a7

docs/upstream-sync/fork-commits.log

Lines changed: 410 additions & 0 deletions
Large diffs are not rendered by default.

docs/upstream-sync/merge-base.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dac099a4892689d11abedb0fcc1098b50e0958c8

docs/upstream-sync/range-diff.txt

Lines changed: 1717 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1307 docs/upstream-sync/upstream-first-parent.txt

0 commit comments

Comments
 (0)