150 lines
5.1 KiB
YAML
150 lines
5.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ["v*"]
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
inputs:
|
|
skip_npm:
|
|
description: "Skip npm publish"
|
|
type: boolean
|
|
default: false
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
rust:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dtolnay/rust-toolchain@nightly
|
|
with:
|
|
components: clippy, rustfmt
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Check formatting
|
|
run: cargo fmt --all -- --check
|
|
- name: Clippy
|
|
run: cargo clippy --workspace -- -D warnings
|
|
- name: Check
|
|
run: cargo check --workspace
|
|
|
|
wasm:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
lfs: true
|
|
- uses: dtolnay/rust-toolchain@nightly
|
|
with:
|
|
targets: wasm32-unknown-unknown
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Install wasm-pack
|
|
run: cargo install wasm-pack
|
|
- name: Install binaryen (wasm-opt)
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y binaryen
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: "1.3"
|
|
- name: Build WASM
|
|
run: bun --cwd=packages/natives run build:wasm
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
lfs: true
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: "1.3"
|
|
- name: Cache bun dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.bun/install/cache
|
|
key: bun-${{ runner.os }}-${{ hashFiles('**/bun.lock') }}
|
|
- name: Install system deps
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev fd-find ripgrep imagemagick
|
|
sudo ln -s $(which fdfind) /usr/local/bin/fd
|
|
sudo ln -sf /usr/bin/convert /usr/local/bin/magick
|
|
- run: bun install --frozen-lockfile
|
|
- run: bun run check
|
|
- run: bun run test
|
|
- name: CLI smoke test
|
|
run: |
|
|
bun packages/coding-agent/src/cli.ts --version
|
|
bun packages/coding-agent/src/cli.ts --help
|
|
bun packages/coding-agent/src/cli.ts stats --help
|
|
|
|
release:
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
needs: [rust, wasm, test]
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
lfs: true
|
|
- uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: "1.3"
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "24"
|
|
registry-url: "https://registry.npmjs.org"
|
|
- name: Cache bun dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.bun/install/cache
|
|
key: bun-${{ runner.os }}-${{ hashFiles('**/bun.lock') }}
|
|
- run: bun install --frozen-lockfile
|
|
|
|
- name: Build binaries
|
|
run: |
|
|
mkdir -p packages/coding-agent/binaries
|
|
ENTRYPOINT="./packages/coding-agent/src/cli.ts"
|
|
WORKERS="./packages/natives/src/grep/worker.ts ./packages/natives/src/html/worker.ts ./packages/natives/src/image/worker.ts"
|
|
DEFINES="--define OMP_COMPILED=true --root ."
|
|
bun build --compile $DEFINES --target=bun-darwin-arm64 $ENTRYPOINT $WORKERS --outfile packages/coding-agent/binaries/omp-darwin-arm64
|
|
bun build --compile $DEFINES --target=bun-darwin-x64 $ENTRYPOINT $WORKERS --outfile packages/coding-agent/binaries/omp-darwin-x64
|
|
bun build --compile $DEFINES --target=bun-linux-x64 $ENTRYPOINT $WORKERS --outfile packages/coding-agent/binaries/omp-linux-x64
|
|
bun build --compile $DEFINES --target=bun-linux-arm64 $ENTRYPOINT $WORKERS --outfile packages/coding-agent/binaries/omp-linux-arm64
|
|
bun build --compile $DEFINES --target=bun-windows-x64 $ENTRYPOINT $WORKERS --outfile packages/coding-agent/binaries/omp-windows-x64.exe
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: packages/coding-agent/binaries/*
|
|
generate_release_notes: true
|
|
- name: Publish to npm
|
|
if: ${{ !inputs.skip_npm }}
|
|
env:
|
|
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
run: |
|
|
for pkg in packages/*/; do
|
|
pkg_name=$(basename "$pkg")
|
|
# Skip private packages
|
|
if jq -e '.private == true' "$pkg/package.json" > /dev/null 2>&1; then
|
|
echo "Skipping $pkg_name (private)"
|
|
continue
|
|
fi
|
|
echo "Publishing $pkg_name..."
|
|
output=$(cd "$pkg" && bun publish --access public 2>&1) && echo "$output" && continue
|
|
echo "$output"
|
|
if echo "$output" | grep -q "previously published\|cannot publish over\|You cannot publish over"; then
|
|
echo "Already published, skipping"
|
|
else
|
|
echo "Failed to publish $pkg_name"
|
|
exit 1
|
|
fi
|
|
done
|