name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  CARGO_TERM_COLOR: always

jobs:
  check:
    name: Clippy + Test
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

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

      - uses: Swatinem/rust-cache@v2

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

      # Unit tests (no external tools required).
      - name: Unit tests
        run: cargo test --lib

      # CLI argument tests — invoke the compiled binary, no QEMU needed.
      - name: CLI tests
        run: cargo test --test cli_test
