name: CI

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

env:
  CARGO_TERM_COLOR: always

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

      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable
          components: rustfmt, clippy

      - uses: Swatinem/rust-cache@v2

      - name: Install rust-analyzer for E2E tests
        run: rustup component add rust-analyzer

      - name: Check formatting
        timeout-minutes: 3
        run: cargo fmt --check --all

      - name: Run clippy
        timeout-minutes: 5
        run: cargo clippy --all-targets -- -D warnings

      - name: Run tests
        timeout-minutes: 10
        run: cargo test

      - name: Build API docs
        timeout-minutes: 5
        run: cargo doc --no-deps --all-features

      - name: Run doc tests
        timeout-minutes: 5
        run: cargo test --doc --all-features
