name: CI

on:
  push:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - name: rustfmt
        run: cargo fmt --all --check

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

      - name: doc
        run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps

      - name: examples
        run: cargo build --examples --all-features

      - name: test
        run: cargo test --all-features

      - name: Semver check
        if: github.event_name == 'pull_request'
        run: |
          cargo install cargo-semver-checks --locked || true
          cargo semver-checks
