name: CI

on:
  push:
    branches:
      - master
  pull_request:

jobs:
  test:
    name: ${{ matrix.os }} / stable
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            toolchain: "1.85.0"
          - os: ubuntu-latest
            toolchain: stable
          - os: windows-latest
            toolchain: stable

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.toolchain }}
          components: rustfmt

      - name: Cache cargo artifacts
        uses: Swatinem/rust-cache@v2

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

      - name: Build
        run: cargo build --verbose

      - name: Run tests
        run: cargo test --verbose
