name: CI

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Check architecture guardrails
        run: python3 scripts/check_architecture.py
      - name: Test architecture guardrails
        run: python3 scripts/check_architecture.py --self-test
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Cargo registry
        uses: swatinem/rust-cache@v2
      - name: Check formatting
        run: cargo fmt --all -- --check
      - name: Run tests
        run: cargo test --all
      - name: Run clippy
        run: cargo clippy --all-targets --all-features -- -D warnings
      - name: Check crate package
        run: cargo publish --dry-run --locked

  platform-check:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [windows-latest, macos-latest]
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Cargo registry
        uses: swatinem/rust-cache@v2
      - name: Check platform build
        run: cargo check --all-targets --locked