Skip to content

Commit 5de928b

Browse files
committed
ci: establish fork/local customization layer
Two-branch fork model: - dev mirrors upstream/dev (clean, fast-forward only) - fork/local carries fork customizations on top of dev Includes: - Fork CI workflows (ci.yml on fork/local, local-build.yml) + fork-templates - Rewritten sync-upstream.yml: FF dev to upstream, rebase fork/local, issue on conflict - Removed upstream publish/release workflows (publish*, release-github-action) - pre-push hook runs bun install --frozen-lockfile before typecheck - submodules/pvrdrxtd pinned at 53daaa17 Note: prior runtime-flag customizations (disableChannelDb, skipMigrations, disableLspDownload, disableClaudeCodePrompt) are now upstream-native and were NOT re-added. See agent-harness fork-customizations-roadmap.md.
1 parent abaabdc commit 5de928b

13 files changed

Lines changed: 376 additions & 587 deletions
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build-and-test:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
submodules: recursive
20+
21+
# TODO: AGENT/HUMAN MUST MODIFY THESE STEPS TO MATCH THE SPECIFIC PROJECT'S BUILD PROCESS
22+
23+
- uses: oven-sh/setup-bun@v2
24+
with:
25+
bun-version: "latest"
26+
27+
- name: Install dependencies
28+
run: bun install --frozen-lockfile
29+
30+
- name: Run tests
31+
run: bun test
32+
33+
- name: Build
34+
run: bun run build
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build (local trigger)
2+
3+
on:
4+
repository_dispatch:
5+
types: [local-build]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
submodules: recursive
17+
18+
# TODO: AGENT/HUMAN MUST MODIFY THESE STEPS TO MATCH THE SPECIFIC PROJECT'S BUILD PROCESS
19+
20+
- uses: oven-sh/setup-bun@v2
21+
with:
22+
bun-version: "latest"
23+
24+
- name: Install dependencies
25+
run: bun install --frozen-lockfile
26+
27+
- name: Build
28+
run: bun run buildname: Build (local trigger)
29+
30+
on:
31+
repository_dispatch:
32+
types: [local-build]
33+
34+
permissions:
35+
contents: write
36+
37+
jobs:
38+
build:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
submodules: recursive
44+
45+
# TODO: AGENT/HUMAN MUST MODIFY THESE STEPS TO MATCH THE SPECIFIC PROJECT'S BUILD PROCESS
46+
47+
- uses: oven-sh/setup-bun@v2
48+
with:
49+
bun-version: "latest"
50+
51+
- name: Install dependencies
52+
run: bun install --frozen-lockfile
53+
54+
- name: Build
55+
run: ./packages/opencode/script/build.ts --single
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Sync Upstream
2+
3+
on:
4+
schedule:
5+
- cron: "0 10 * * 1"
6+
workflow_dispatch:
7+
inputs:
8+
upstream_branch:
9+
description: "Upstream branch to merge"
10+
required: true
11+
default: dev
12+
type: choice
13+
options:
14+
- dev
15+
- main
16+
- master
17+
18+
permissions:
19+
contents: write
20+
pull-requests: write
21+
22+
jobs:
23+
sync:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
submodules: recursive
30+
token: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Configure upstream remote
33+
run: |
34+
# TODO: AGENT/HUMAN MUST REPLACE THIS URL DURING SETUP
35+
git remote add upstream <UPSTREAM_REPO_URL>
36+
git fetch upstream
37+
echo "UPSTREAM_BRANCH=${{ inputs.upstream_branch || 'dev' }}" >> $GITHUB_ENV
38+
39+
- name: Attempt merge
40+
id: merge
41+
run: |
42+
git config user.name "github-actions[bot]"
43+
git config user.email "github-actions[bot]@users.noreply.github.com"
44+
45+
BRANCH="${{ env.UPSTREAM_BRANCH }}"
46+
echo "Merging upstream/${BRANCH} into main..."
47+
48+
if git merge "upstream/${BRANCH}" --no-edit --no-ff 2>&1; then
49+
echo "result=clean" >> $GITHUB_OUTPUT
50+
else
51+
echo "result=conflict" >> $GITHUB_OUTPUT
52+
fi
53+
54+
- name: Resolve protected file conflicts
55+
if: steps.merge.outputs.result == 'conflict'
56+
id: resolve
57+
run: |
58+
# These files we always keep our (fork) version
59+
PROTECTED_FILES=".gitmodules .github/workflows/ci.yml .github/workflows/sync-upstream.yml"
60+
61+
for f in $PROTECTED_FILES; do
62+
if git diff --name-only --diff-filter=U | grep -qxF "$f"; then
63+
echo "Resolving $f in favor of ours (fork)"
64+
git checkout --ours "$f"
65+
git add "$f"
66+
fi
67+
done
68+
69+
# For branch-specific CI references, keep ours
70+
if git diff --name-only --diff-filter=U | grep -qF ".github/workflows"; then
71+
echo "Resolving any remaining workflow conflicts in favor of fork"
72+
for f in $(git diff --name-only --diff-filter=U | grep "^.github/workflows/"); do
73+
git checkout --ours "$f"
74+
git add "$f"
75+
done
76+
fi
77+
78+
REMAINING=$(git diff --name-only --diff-filter=U)
79+
if [ -n "$REMAINING" ]; then
80+
echo "UNRESOLVED CONFLICTS:"
81+
echo "$REMAINING"
82+
echo "result=unresolved" >> $GITHUB_OUTPUT
83+
else
84+
echo "All conflicts resolved, committing..."
85+
git commit --no-edit
86+
echo "result=resolved" >> $GITHUB_OUTPUT
87+
fi
88+
89+
- name: Handle submodules after merge
90+
if: steps.merge.outputs.result == 'clean' || steps.resolve.outputs.result == 'resolved'
91+
run: |
92+
# Try to sync submodules to our fork URLs
93+
git submodule sync
94+
git submodule update --init --recursive 2>&1 || {
95+
echo "WARNING: Submodule update failed. This usually means upstream updated the submodule pointer to a commit not present in our local/enhancements branch."
96+
echo "Falling back to our existing submodule pointers..."
97+
git submodule status | awk '{print $2}' | xargs -I {} git checkout --ours {}
98+
git submodule status | awk '{print $2}' | xargs -I {} git add {}
99+
100+
# If we still have uncommitted submodule changes, commit them
101+
if ! git diff --cached --quiet; then
102+
git commit -m "chore: pin submodules to fork branches after upstream merge"
103+
fi
104+
}
105+
106+
- name: Create PR for unresolved conflicts
107+
if: steps.resolve.outputs.result == 'unresolved'
108+
uses: peter-evans/create-pull-request@v7
109+
with:
110+
token: ${{ secrets.GITHUB_TOKEN }}
111+
commit-message: "chore: merge upstream/${{ inputs.upstream_branch || 'dev' }} -- continue manually"
112+
title: "chore: merge upstream/${{ env.UPSTREAM_BRANCH }} (manual resolution needed)"
113+
body: |
114+
Auto-merge from upstream/${{ env.UPSTREAM_BRANCH }} had conflicts that could not be resolved automatically.
115+
116+
Unresolved files:
117+
$(git diff --name-only --diff-filter=U)
118+
119+
Please resolve these conflicts and merge manually.
120+
branch: auto-sync/upstream-${{ env.UPSTREAM_BRANCH }}-${{ github.run_id }}
121+
delete-branch: true
122+
123+
- name: Push clean merge to main
124+
if: steps.merge.outputs.result == 'clean' || steps.resolve.outputs.result == 'resolved'
125+
run: |
126+
git push origin main
127+
echo "Merge pushed to main. CI will build automatically."

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [fork/local]
6+
pull_request:
7+
branches: [fork/local]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build-and-test:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
submodules: recursive
20+
21+
- uses: ./.github/actions/setup-bun
22+
23+
- name: Install dependencies
24+
run: bun install --frozen-lockfile
25+
26+
- name: Build Single Binary
27+
run: ./packages/opencode/script/build.ts --single

.github/workflows/local-build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build (local trigger)
2+
3+
on:
4+
repository_dispatch:
5+
types: [local-build]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
submodules: recursive
17+
18+
- uses: ./.github/actions/setup-bun
19+
20+
- name: Install dependencies
21+
run: bun install --frozen-lockfile
22+
23+
- name: Run typecheck
24+
run: bun typecheck
25+
26+
- name: Build Single Binary
27+
run: ./packages/opencode/script/build.ts --single

.github/workflows/publish-github-action.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/publish-vscode.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)