Skip to content

Commit eeb4ac1

Browse files
committed
chore: integrate opencode submodule and broker checks
1 parent 10c628d commit eeb4ac1

5 files changed

Lines changed: 120 additions & 11 deletions

File tree

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ members = [
44
"packages/core",
55
"packages/cli-rust",
66
]
7+
exclude = [
8+
"packages/opencode/packages/opencode-broker",
9+
"packages/opencode/packages/desktop/src-tauri",
10+
]
711

812
[workspace.package]
913
version = "19.0.1"

justfile

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ setup:
1414
@echo "✓ Development environment ready!"
1515

1616
# Build everything
17-
build: build-rust build-node
17+
build: build-rust build-node build-opencode build-opencode-broker
1818

1919
# Compile and run the occ binary (arguments automatically get passed to the binary)
2020
# Example: just run --version
@@ -46,6 +46,71 @@ build-node:
4646
pnpm -C packages/core build
4747
pnpm -r --filter="!@opencode-cloud/core" build
4848

49+
# --- opencode Submodule Checks ---
50+
51+
# Ensure opencode submodule is initialized in this worktree
52+
opencode-submodule-check:
53+
@if [ -f packages/opencode/.git ] || [ -d packages/opencode/.git ]; then \
54+
:; \
55+
else \
56+
echo "Submodule packages/opencode is not initialized."; \
57+
echo "Run: git submodule update --init --recursive"; \
58+
exit 1; \
59+
fi
60+
61+
# Install opencode dependencies when missing
62+
opencode-install-if-needed: opencode-submodule-check
63+
@if [ ! -d packages/opencode/node_modules ]; then \
64+
echo "Installing opencode submodule dependencies..."; \
65+
bun install --cwd packages/opencode --frozen-lockfile; \
66+
else \
67+
echo "opencode submodule dependencies already installed."; \
68+
fi
69+
70+
# Typecheck opencode workspace
71+
lint-opencode: opencode-install-if-needed
72+
bun --cwd packages/opencode turbo typecheck
73+
74+
# Build the shared app package
75+
build-opencode-app: opencode-install-if-needed
76+
bun run --cwd packages/opencode/packages/app build
77+
78+
# Build opencode single-ui artifact using local models fixture for deterministic output
79+
build-opencode-single-ui: opencode-install-if-needed
80+
@tmpfile="$(mktemp)"; \
81+
trap 'rm -f "$tmpfile"' EXIT; \
82+
perl -pe 'chomp if eof' "{{justfile_directory()}}/packages/opencode/packages/opencode/test/tool/fixtures/models-api.json" > "$tmpfile"; \
83+
MODELS_DEV_API_JSON="$tmpfile" bun run --cwd packages/opencode/packages/opencode build-single-ui
84+
85+
# Build opencode app and opencode binary/ui artifact
86+
build-opencode: build-opencode-app build-opencode-single-ui
87+
88+
# Lint opencode-broker Rust crate
89+
lint-opencode-broker: opencode-submodule-check
90+
cargo fmt --manifest-path packages/opencode/packages/opencode-broker/Cargo.toml --all -- --check
91+
cargo clippy --manifest-path packages/opencode/packages/opencode-broker/Cargo.toml --all-targets -- -D warnings
92+
93+
# Build opencode-broker Rust crate
94+
build-opencode-broker: opencode-submodule-check
95+
cargo build --manifest-path packages/opencode/packages/opencode-broker/Cargo.toml
96+
97+
# Test opencode-broker Rust crate
98+
test-opencode-broker: opencode-submodule-check
99+
cargo test --manifest-path packages/opencode/packages/opencode-broker/Cargo.toml
100+
101+
# Optional app unit test gate (not part of default pre-commit)
102+
test-opencode-ui: opencode-install-if-needed
103+
bun run --cwd packages/opencode/packages/app test:unit
104+
105+
# Optional submodule drift and dirty state check
106+
check-opencode-submodule-drift:
107+
git submodule status --recursive
108+
git submodule foreach --recursive 'git status --short --branch'
109+
110+
# Update opencode submodule + Dockerfile OPENCODE_COMMIT pin
111+
update-opencode-commit:
112+
./scripts/update-opencode-commit.sh
113+
49114
# --- Docker Sandbox Image ---
50115

51116
# Build Docker sandbox image with BuildKit caching (amd64 only, for local dev)
@@ -88,10 +153,10 @@ check-docker:
88153
@echo "✓ Dockerfile check passed"
89154

90155
# Run all tests (fast)
91-
test-all-fast: test-rust-fast test-node
156+
test-all-fast: test-rust-fast test-node test-opencode-broker
92157

93158
# Run all tests (slow, includes doc-tests)
94-
test-all-slow: test-rust test-node
159+
test-all-slow: test-rust test-node test-opencode-broker
95160

96161
# Run all tests (fast)
97162
test: test-all-fast
@@ -115,7 +180,7 @@ test-doc-slow:
115180
cargo test --workspace --doc
116181

117182
# Lint everything
118-
lint: lint-rust lint-node lint-shell
183+
lint: lint-rust lint-node lint-shell lint-opencode lint-opencode-broker
119184

120185
# Lint Rust code
121186
lint-rust:

packages/core/src/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ USER opencode
489489
# Clone the fork and build opencode from source (as non-root user)
490490
# Pin to specific commit for reproducibility
491491
# NOTE: OPENCODE_COMMIT is not tied to releases/tags; it tracks the latest stable
492-
# commit on the main branch of https://github.com/pRizz/opencode.
492+
# commit on the dev branch of https://github.com/pRizz/opencode.
493493
# Update it by running: ./scripts/update-opencode-commit.sh
494494
# Build opencode from source (BuildKit cache mounts disabled for now)
495495
RUN OPENCODE_COMMIT="ac8b3a8010c6a31d28e167c7f3cf1bd9e63c9229" \

packages/opencode

Submodule opencode updated 39 files

scripts/update-opencode-commit.sh

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,61 @@ set -euo pipefail
33

44
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
55
dockerfile="${root_dir}/packages/core/src/docker/Dockerfile"
6+
submodule_dir="${root_dir}/packages/opencode"
7+
gitmodules="${root_dir}/.gitmodules"
68

79
if [[ ! -f "${dockerfile}" ]]; then
810
echo "Dockerfile not found at ${dockerfile}" >&2
911
exit 1
1012
fi
1113

12-
latest_commit="$(
13-
git ls-remote https://github.com/pRizz/opencode.git HEAD | awk '{print $1}'
14-
)"
14+
if [[ ! -d "${submodule_dir}" || (! -f "${submodule_dir}/.git" && ! -d "${submodule_dir}/.git") ]]; then
15+
echo "Submodule is not initialized at ${submodule_dir}." >&2
16+
echo "Run: git submodule update --init --recursive" >&2
17+
exit 1
18+
fi
19+
20+
dirty_state="$(git -C "${submodule_dir}" status --porcelain)"
21+
if [[ -n "${dirty_state}" ]]; then
22+
echo "Submodule ${submodule_dir} has uncommitted changes; clean or stash first." >&2
23+
echo "${dirty_state}" >&2
24+
exit 1
25+
fi
26+
27+
submodule_branch="dev"
28+
if [[ -f "${gitmodules}" ]]; then
29+
configured_branch="$(git config -f "${gitmodules}" --get submodule.packages/opencode.branch 2>/dev/null || true)"
30+
if [[ -n "${configured_branch}" ]]; then
31+
submodule_branch="${configured_branch}"
32+
fi
33+
fi
1534

35+
git -C "${submodule_dir}" fetch --prune origin "${submodule_branch}"
36+
latest_commit="$(git -C "${submodule_dir}" rev-parse FETCH_HEAD)"
1637
if [[ -z "${latest_commit}" ]]; then
17-
echo "Failed to resolve latest commit for pRizz/opencode." >&2
38+
echo "Failed to resolve latest commit for branch ${submodule_branch}." >&2
39+
exit 1
40+
fi
41+
42+
git -C "${submodule_dir}" checkout --detach "${latest_commit}"
43+
44+
current_pin="$(grep -oE 'OPENCODE_COMMIT="[^\"]+"' "${dockerfile}" | head -n1 || true)"
45+
if [[ -z "${current_pin}" ]]; then
46+
echo "Failed to find OPENCODE_COMMIT in ${dockerfile}." >&2
1847
exit 1
1948
fi
2049

2150
perl -0pi -e "s/OPENCODE_COMMIT=\"[^\"]+\"/OPENCODE_COMMIT=\"${latest_commit}\"/" "${dockerfile}"
2251

23-
echo "Updated OPENCODE_COMMIT to ${latest_commit}"
52+
expected_pin="OPENCODE_COMMIT=\"${latest_commit}\""
53+
updated_pin="$(grep -oE 'OPENCODE_COMMIT="[^\"]+"' "${dockerfile}" | head -n1 || true)"
54+
if [[ "${updated_pin}" != "${expected_pin}" ]]; then
55+
echo "Failed to update OPENCODE_COMMIT in ${dockerfile}." >&2
56+
exit 1
57+
fi
58+
59+
echo "Updated opencode submodule and Dockerfile pin."
60+
echo " Branch: ${submodule_branch}"
61+
echo " Commit: ${latest_commit}"
62+
echo " Submodule: ${submodule_dir}"
63+
echo " Dockerfile: ${dockerfile}"

0 commit comments

Comments
 (0)