name: CI

on:
  push:
    branches: [main, "rel/**"]
    paths:
      - "src/**"
      - "tests/**"
      - "Cargo.*"
  pull_request:
    paths:
      - "src/**"
      - "tests/**"
      - "Cargo.*"

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        rust: [stable]
        include:
          # Also test on our declared MSRV
          - os: ubuntu-latest
            rust: "1.94"
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}
      - run: cargo test --workspace
      # Also test with jj feature enabled
      - run: cargo test --workspace --features jj

  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - run: cargo clippy
      - run: cargo clippy --features jj

  # Verify it builds without default features (no git, no jj)
  no-default-features:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo check --no-default-features
