permissions:
  contents: read
on:
  push:
    branches: [ main ]
  pull_request:
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true
name: check
jobs:
  fmt:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        toolchain: [ nightly ]
    name: ${{ matrix.toolchain }} / fmt
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - name: Install ${{ matrix.toolchain }}
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.toolchain }}
          components: rustfmt
      - name: cargo +${{ matrix.toolchain }} fmt --check
        run: cargo +${{ matrix.toolchain }} fmt --check
  clippy:
    runs-on: ubuntu-latest
    name: ${{ matrix.toolchain }} / clippy
    permissions:
      contents: read
      checks: write
    strategy:
      fail-fast: false
      matrix:
        toolchain: [ stable, beta ]
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - name: Install ${{ matrix.toolchain }}
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.toolchain }}
          components: clippy
      - name: cargo clippy
        uses: giraffate/clippy-action@v1
        with:
          reporter: "github-pr-check"
          github_token: ${{ secrets.GITHUB_TOKEN }}
          clippy_flags: '--all --all-features --all-targets'
  docs:
    runs-on: ubuntu-latest
    name: stable / doc
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - name: Install stable
        uses: dtolnay/rust-toolchain@stable
      - name: cargo doc
        run: cargo doc
