Skip to content

feat: Add JSON-aware mermaid diagram validation #1484

feat: Add JSON-aware mermaid diagram validation

feat: Add JSON-aware mermaid diagram validation #1484

Workflow file for this run

name: Rust Tests
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
jobs:
check-changes:
name: Check what code changed
runs-on: ubuntu-latest
outputs:
rust-changed: ${{ steps.changes.outputs.rust }}
npm-changed: ${{ steps.changes.outputs.npm }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for changes
id: changes
run: |
if [ "${{ github.event_name }}" == "push" ]; then
# For push events, check changes since the previous commit
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
else
# For pull requests, check changes against the base branch
git fetch origin "${{ github.base_ref }}"
CHANGED_FILES=$(git diff --name-only "origin/${{ github.base_ref }}" HEAD)
fi
echo "Changed files:"
echo "$CHANGED_FILES"
# Check if any Rust-related files changed
if echo "$CHANGED_FILES" | grep -E '\.(rs|toml)$|^Cargo\.|^Makefile$|^\.github/workflows/rust-tests\.yml$|^\.githooks/|^scripts/|^tests/' > /dev/null; then
echo "Rust code or related files changed"
echo "rust=true" >> "$GITHUB_OUTPUT"
else
echo "No Rust code changes detected"
echo "rust=false" >> "$GITHUB_OUTPUT"
fi
# Check if any NPM-related files changed
if echo "$CHANGED_FILES" | grep -E '^npm/|package\.json$|package-lock\.json$|\.js$|\.ts$|\.json$|^examples/chat/' > /dev/null; then
echo "NPM/Node.js code or related files changed"
echo "npm=true" >> "$GITHUB_OUTPUT"
else
echo "No NPM code changes detected"
echo "npm=false" >> "$GITHUB_OUTPUT"
fi
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: check-changes
if: needs.check-changes.outputs.rust-changed == 'true'
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.88.0
with:
components: rustfmt, clippy
- name: Setup Rust cache
uses: actions/cache@v4
timeout-minutes: 5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('rust-toolchain', 'rust-toolchain.toml') || 'stable' }}
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-
${{ runner.os }}-cargo-
- name: Show Rust version
run: |
rustc --version
cargo --version
cargo clippy --version
- name: Check formatting
run: cargo fmt --all -- --check
- name: Lint with clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build
- name: Run unit tests
run: cargo test --lib
- name: Run integration tests
run: cargo test --test integration_tests
- name: Run property tests
run: cargo test --test property_tests
- name: Run CLI tests
run: cargo test --test cli_tests
npm-tests:
name: NPM Agent Tests on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: check-changes
if: needs.check-changes.outputs.npm-changed == 'true'
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [20]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Rust toolchain (for building local binary)
uses: dtolnay/rust-toolchain@1.88.0
with:
components: rustfmt
- name: Setup Node.js cache
uses: actions/cache@v4
with:
path: |
npm/node_modules
~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('npm/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
run: |
cd npm
npm install
- name: Build Rust binary for tests and place in npm/bin
shell: bash
run: |
# Ensure a local binary exists to avoid network downloads during tests
rustup show
cargo build --release
mkdir -p npm/bin
if [[ "${{ runner.os }}" == "Windows" ]]; then
cp target/release/probe.exe npm/bin/probe.exe
else
cp target/release/probe npm/bin/probe-binary
chmod +x npm/bin/probe-binary
fi
- name: Build npm package
run: |
cd npm
npm run build
- name: Run npm agent tests
run: |
cd npm
npm test
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: npm-coverage-${{ matrix.os }}-node${{ matrix.node-version }}
path: npm/coverage/
retention-days: 7