name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
version-check:
name: Version Consistency
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify all package versions match
shell: bash
run: |
# Extract version strings from the four canonical files listed in
# CLAUDE.md's "Version Bump Checklist". CI fails fast when any are
# out of sync — a full release can't ship mismatched versions.
root=$(grep -m1 '^version = ' Cargo.toml | sed 's/.*"\(.*\)".*/\1/')
cli=$(grep -m1 '^version = ' cli/Cargo.toml | sed 's/.*"\(.*\)".*/\1/')
py=$(grep -m1 '^version = ' bindings/python/pyproject.toml | sed 's/.*"\(.*\)".*/\1/')
cs=$(grep -oE '<Version>[^<]+</Version>' bindings/csharp/Undoc/Undoc.csproj | head -1 | sed 's/<[^>]*>//g')
# Also verify cli/Cargo.toml's undoc dep points at the same version
# so consumers of the published crate aren't broken.
dep=$(grep -m1 'undoc = { version =' cli/Cargo.toml | sed 's/.*version = "\([^"]*\)".*/\1/')
echo "Root Cargo.toml: $root"
echo "cli/Cargo.toml: $cli"
echo "bindings/python/pyproject.toml: $py"
echo "bindings/csharp/Undoc/Undoc.csproj: $cs"
echo "cli -> undoc dep version: $dep"
fail=0
for v in "$cli" "$py" "$cs" "$dep"; do
if [ "$v" != "$root" ]; then
fail=1
fi
done
if [ $fail -eq 1 ]; then
echo "::error::Version mismatch — update all four canonical files AND cli's undoc dep together per CLAUDE.md Version Bump Checklist."
exit 1
fi
echo "All versions match: $root"
test:
name: Test
needs: version-check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build
run: cargo build --release
- name: Run tests
run: cargo test
- name: Build with FFI
run: cargo build --release --features ffi
lint:
name: Lint
needs: version-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy -- -D warnings