Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/check-cli-rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: check-cli-rs

# Checks packages/cli-rs, the Rust client, which check-test.yml leaves out. Pull requests run it only when they change
# the client. Its tests and check:drift also compare it with the TypeScript packages below, so a dev push that changes
# one runs it too: a TypeScript change that breaks the client shows on dev, not on other teams' pull requests.
on:
pull_request:
paths:
- packages/cli-rs/**
- .github/workflows/check-cli-rs.yml
push:
branches: [dev]
paths:
- packages/cli-rs/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check:drift reruns generators and oracles that read TypeScript outside this package (@opencode/protocol, @opencode/plugin, @opencode/tui, the httpapi codegen), and the parity machines run the TypeScript TUI. A PR that only touches those packages can leave cli-rs's generated files or fixtures stale. With this filter neither that PR nor the push to dev runs the check, so the failure lands on the next unrelated cli-rs PR. Could you add those source paths, at least for push to dev?

- packages/cli/src/**
- packages/client/**
- packages/plugin/**
- packages/protocol/**
- packages/schema/**
- packages/theme/**
- packages/tui/**
- packages/util/**
- bun.lock
- .github/workflows/check-cli-rs.yml
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
check:
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 45
defaults:
run:
working-directory: packages/cli-rs
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
# Bun and node_modules: the tests and check:drift run the TypeScript side they compare against.
- uses: ./.github/actions/setup-bun
# rustup reads rust-toolchain.toml; `bun run cargo` first fetches OpenTUI's native library from its release.
- run: rustup toolchain install
- run: bun run cargo fmt --check
- run: bun run cargo clippy --locked --workspace --all-targets -- -D warnings
# Every crate's tests, even after one fails, so one run shows every failure.
- run: bun run cargo test --locked --workspace --no-fail-fast
- run: bun run check:drift

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says this step fails until the port PR lands. If this PR merges first, check-cli-rs fails on every cli-rs PR and on every matching dev push until then, and a check that is always red stops getting looked at. Could this PR merge after the port PR, or the step use continue-on-error: true until then?

126 changes: 126 additions & 0 deletions .github/workflows/release-cli-rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: cli-rs release

# Builds opencode-native, the Rust client in packages/cli-rs, natively on each runner below and keeps each archive as an
# artifact. A cli-rs-v<version> tag also publishes them as a GitHub release. It never becomes Latest: the monorepo's
# Latest release drives OpenCode's own update paths.
on:
push:
tags:
- "cli-rs-v*"
pull_request:
paths:
- .github/workflows/release-cli-rs.yml
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
# Zig links Linux against glibc 2.17, OpenTUI's floor. zig_sha is the archive's, from ziglang.org.
- runner: ubuntu-24.04
target: x86_64-unknown-linux-gnu
zig: x86_64-linux-gnu.2.17
zig_sha: 3581863e3cbcfd0fce0efc682ce7e9e93da96668a977791d356a26d2a7e9b17a
- runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
zig: aarch64-linux-gnu.2.17
zig_sha: a1546d5646eb184437918d6635ca6b762a0e889eac09cef720ee7a1ed3fe7795
- { runner: macos-15-intel, target: x86_64-apple-darwin }
- { runner: macos-15, target: aarch64-apple-darwin }
- { runner: windows-2025, target: x86_64-pc-windows-msvc, exe: .exe }
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
defaults:
run:
shell: bash
working-directory: packages/cli-rs
env:
OPENCODE_NATIVE_COMMIT: ${{ github.sha }}
CARGO_PROFILE_DIST_STRIP: symbols
MACOSX_DEPLOYMENT_TARGET: "13.0"
# No Visual C++ runtime to install beside the .exe.
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS: -C target-feature=+crt-static
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version-file: package.json
# The version opencode-native --version prints: the tag's, or 0.0.0-<commit> for any other run.
- name: Version
run: |
version=0.0.0-$GITHUB_SHA
if [[ $GITHUB_REF == refs/tags/cli-rs-v* ]]; then version=${GITHUB_REF_NAME#cli-rs-v}; fi
echo "OPENCODE_VERSION=$version" >> "$GITHUB_ENV"
# Zig 0.17.1 as the C and C++ compiler and the linker. The wrapper drops flags zig rejects: cc's --target, and
# rustc's Cortex-A53 erratum fix on aarch64.
- if: matrix.zig
working-directory: ${{ runner.temp }}
run: |
file=zig-$(uname -m)-linux-0.17.1
curl -fsSL --retry 3 -o zig.tar.xz "https://ziglang.org/download/0.17.1/$file.tar.xz"
echo "${{ matrix.zig_sha }} zig.tar.xz" | sha256sum -c
tar -xJf zig.tar.xz
for tool in cc c++; do
cat > "zig-$tool" <<EOF
#!/bin/sh
for a; do shift; case \$a in --target=*|-Wl,--fix-cortex-a53-843419) ;; *) set -- "\$@" "\$a" ;; esac; done
exec "$PWD/$file/zig" $tool -target ${{ matrix.zig }} "\$@"
EOF
chmod +x "zig-$tool"
done
triple=$(tr a-z- A-Z_ <<< "${{ matrix.target }}")
{ echo "CARGO_TARGET_${triple}_LINKER=$PWD/zig-cc"; echo "CC_${triple,,}=$PWD/zig-cc"
echo "CXX_${triple,,}=$PWD/zig-c++"; echo "CXXSTDLIB_${triple,,}=c++"; } >> "$GITHUB_ENV"
# rustup reads rust-toolchain.toml; `bun run cargo` first fetches OpenTUI's native library from its release.
- run: rustup toolchain install
- run: bun run cargo build --locked --profile dist --bin opencode-native
- name: Check glibc 2.17 and no libstdc++
if: matrix.zig
run: "! readelf -dV target/dist/opencode-native | grep -E 'GLIBC_2\\.(1[89]|[2-9][0-9])|libstdc\\+\\+'"
- name: Package
run: |
name=opencode-native-$OPENCODE_VERSION-${{ matrix.target }}
mkdir -p "dist/$name"
cp "target/dist/opencode-native${{ matrix.exe }}" "dist/$name/"
# Our licence, and OpenTUI's licences (FFmpeg's among them) from its native release zip.
cp ../../LICENSE "dist/$name/"
cp -r .opentui/*/host/licenses "dist/$name/"
tar -C dist -czf "dist/$name.tar.gz" "$name"
ls -l "dist/$name" "dist/$name.tar.gz"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: opencode-native-${{ matrix.target }}
path: packages/cli-rs/dist/*.tar.gz
if-no-files-found: error
compression-level: 0

release:
needs: build
if: startsWith(github.ref, 'refs/tags/cli-rs-v')
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
pattern: opencode-native-*
merge-multiple: true
- name: Publish
env:
GH_TOKEN: ${{ github.token }}
run: |
sha256sum ./*.tar.gz > SHA256SUMS
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --verify-tag --latest=false \
--title "opencode-native ${GITHUB_REF_NAME#cli-rs-v}" --notes "The Rust client (packages/cli-rs) at $GITHUB_SHA." \
./*.tar.gz SHA256SUMS
7 changes: 6 additions & 1 deletion packages/cli-rs/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ say "native"; crates, this directory, and `OPENCODE_RS_*` variables say "rs".

## Checks

Before merging, the whole package must pass:
CI (`.github/workflows/check-cli-rs.yml`) runs:

- `bun run cargo fmt --check`
- `bun run cargo clippy --locked --workspace --all-targets -- -D warnings`
- `bun run cargo test --locked --workspace --no-fail-fast`
- `bun run check:drift`

CI has no `opencode` binary, so a few tests that need one skip. Before merging, also run these locally:

- `OPENCODE_RS_REQUIRE_TS=1 bun run cargo test --locked --workspace --no-fail-fast`, with an `opencode` binary on
`PATH`. Then the TypeScript interop tests fail instead of skipping.
- `bun run parity:machines`

Each of `opencode-tui` and `opencode-ui` has one integration test binary, `tests/all/main.rs`, with one module per
Expand Down
Loading