name: CI

on:
  pull_request:
  push:
    branches: [master]

env:
  CARGO_TERM_COLOR: always

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

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

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

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

      - name: Build
        run: cargo build --all-targets --locked --verbose

      - name: Test
        run: cargo test --locked --verbose
