agent-rules-tool 0.1.0-rc.2

Lint and migrate agent rules per agent-rules-spec
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  changes:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: read
    outputs:
      rust: ${{ steps.filter.outputs.rust }}
      rules: ${{ steps.filter.outputs.rules }}
      md: ${{ steps.filter.outputs.md }}
      spec: ${{ steps.filter.outputs.spec }}
    steps:
      - uses: actions/checkout@v6

      - uses: dorny/paths-filter@v4
        id: filter
        with:
          filters: |
            rust:
              - '**/*.rs'
              - '**/Cargo.toml'
              - 'examples/**'
              - 'rust-toolchain.toml'
              - '.github/workflows/ci.yml'
            rules:
              - '.agents/rules/**'
            md:
              - '**/*.md'
              - '.rumdl.toml'
            spec:
              - 'spec/**'
              - 'xtask/**'
              - 'docs/maintenance.md'

  # Separate jobs (not a matrix): skipped jobs must report names branch
  # protection expects, not CI (${{ matrix.os }}).
  rust-ubuntu:
    name: CI (ubuntu-latest)
    needs: changes
    if: |
      needs.changes.outputs.rust == 'true' ||
      needs.changes.outputs.rules == 'true'
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry and build
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: ci-ubuntu-latest-all-features

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Run clippy
        run: cargo clippy --workspace --all-targets --all-features -- -D warnings

      - name: Lint agent rules
        run: cargo run --bin agent-rules-tool -- lint -d .agents/rules

      - name: Run tests
        run: cargo test --workspace --all-targets

      - name: Check rustdoc (no warnings)
        env:
          RUSTDOCFLAGS: "-D warnings"
        run: cargo doc --no-deps -p agent-rules-tool --all-features

      - name: Package consistency (publish dry-run)
        run: cargo publish -p agent-rules-tool --dry-run

      - name: Security audit
        # rustsec has yet to cut a new version: https://github.com/rustsec/audit-check/issues/47
        uses: rustsec/audit-check@858dc40f52ca2b8570b7a997c1c4e35c6fc9a432
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

  rust-macos:
    name: CI (macos-latest)
    needs: changes
    if: |
      needs.changes.outputs.rust == 'true' ||
      needs.changes.outputs.rules == 'true'
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@v6

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry and build
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: ci-macos-latest-all-features

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Run clippy
        run: cargo clippy --workspace --all-targets --all-features -- -D warnings

      - name: Lint agent rules
        run: cargo run --bin agent-rules-tool -- lint -d .agents/rules

      - name: Run tests
        run: cargo test --workspace --all-targets

      - name: Check rustdoc (no warnings)
        env:
          RUSTDOCFLAGS: "-D warnings"
        run: cargo doc --no-deps -p agent-rules-tool --all-features

  rust-windows:
    name: CI (windows-latest)
    needs: changes
    if: |
      needs.changes.outputs.rust == 'true' ||
      needs.changes.outputs.rules == 'true'
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v6

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry and build
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: ci-windows-latest-all-features

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Run clippy
        run: cargo clippy --workspace --all-targets --all-features -- -D warnings

      - name: Lint agent rules
        run: cargo run --bin agent-rules-tool -- lint -d .agents/rules

      - name: Run tests
        run: cargo test --workspace --all-targets

      - name: Check rustdoc (no warnings)
        env:
          RUSTDOCFLAGS: "-D warnings"
        run: cargo doc --no-deps -p agent-rules-tool --all-features

  rumdl:
    name: Markdown Hygiene
    needs: changes
    if: needs.changes.outputs.md == 'true'
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

      - uses: rvben/rumdl@v0
        with:
          config: .rumdl.toml

  check-spec:
    name: Check Spec
    needs: changes
    if: needs.changes.outputs.spec == 'true'
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Check vendored spec is current with upstream
        run: cargo xtask spec-update check