name: CI

on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always
  SCHEDX_BACKEND: none

jobs:
  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install toolchain
        run: |
          rustup toolchain install 1.85.0 --profile minimal --component rustfmt --component clippy
          rustup default 1.85.0

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

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

      - name: Cargo package
        run: cargo package --locked

  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
    steps:
      - uses: actions/checkout@v6
        with:
          persist-credentials: false

      - name: Install toolchain
        shell: bash
        run: |
          rustup toolchain install 1.85.0 --profile minimal
          rustup default 1.85.0

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