name: CI

on:
  pull_request:
  push:
    branches: [main]

env:
  RUSTFLAGS: -D warnings

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt

      - uses: Swatinem/rust-cache@v2

      - name: Version is strictly above crates.io
        run: python3 scripts/check-version-above-crates-io.py

      - name: Format
        run: cargo fmt --check

      - name: Build (debug)
        run: cargo build

      - name: Build (release)
        run: cargo build --release

      - name: Unit tests (debug)
        run: cargo test --bin scsh

      - name: Unit tests (release)
        run: cargo test --release --bin scsh

      - name: Integration tests (debug)
        run: cargo test --test cli

      - name: Integration tests (release)
        run: cargo test --release --test cli
