name: Quick Check

on:
  pull_request:
    types: [opened, synchronize, reopened]

env:
  CARGO_TERM_COLOR: always

jobs:
  quick:
    name: Quick checks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

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

      - uses: swatinem/rust-cache@v2
        with:
          shared-key: "quick-check"

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

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

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

      - name: Unit tests
        run: cargo test --lib --all-features

      - name: Mechanical CLI tests
        run: cargo test --test cli --all-features

  release-build:
    name: Release build check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - uses: dtolnay/rust-toolchain@stable

      - uses: swatinem/rust-cache@v2
        with:
          shared-key: "release-build"

      - name: Build release
        run: cargo build --release --all-features
