on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

env:
  RUSTFLAGS: '-Dwarnings'

name: check
jobs:
  fmt:
    runs-on: ubuntu-latest
    name: fmt
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - name: cargo fmt --check --all
        run: cargo fmt --check --all

  clippy:
    runs-on: ubuntu-latest
    name: clippy
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - run: cargo clippy --all-features --all-targets --tests

  test:
    runs-on: ubuntu-latest
    name: test
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo test --workspace --all-features

  features:
    runs-on: ubuntu-latest
    name: features
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-hack
      - name: features powerset
        run: cargo hack check --feature-powerset --tests
