name: Checks
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

on:
  push:
    branches: [main]
  pull_request:

jobs:
  build-and-test:
    timeout-minutes: 15
    strategy:
      matrix:
        os: [ubuntu-24.04, macos-26]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - uses: jdx/mise-action@v2

      - name: Install Rust components
        if: matrix.os == 'ubuntu-24.04'
        run: rustup component add rustfmt clippy

      - uses: Swatinem/rust-cache@v2

      - name: Format
        if: matrix.os == 'ubuntu-24.04'
        run: cargo fmt --check

      - name: Clippy
        if: matrix.os == 'ubuntu-24.04'
        run: cargo clippy --release -- -D warnings

      - name: Build
        run: cargo build --release

      - name: Test
        run: cargo test --release
