name: CI

on:
  push:
    branches: [ master, main ]
    paths-ignore:
      - '**.md'
      - 'LICENSE'
      - '.gitignore'
  pull_request:
    branches: [ master, main ]
    paths-ignore:
      - '**.md'
      - 'LICENSE'
      - '.gitignore'

env:
  CARGO_TERM_COLOR: always

jobs:
  checks:
    name: Checks
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4

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

      - name: Setup Rust cache
        uses: Swatinem/rust-cache@v2

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

      - name: Check compilation
        run: cargo check --all-features

      - name: Run clippy
        run: cargo clippy --all-features -- -D warnings -A clippy::too-many-arguments
