---
name: Rust

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

env:
  CARGO_TERM_COLOR: always
  # Limit parallel jobs to avoid lld crashes due to memory pressure during doctest linking
  CARGO_BUILD_JOBS: 2

jobs:
  build:

    strategy:
      matrix:
        os: [ubuntu-latest]

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - run: python -m pip install breezy launchpadlib
      - name: Install OpenSSL on macOS
        if: matrix.os == 'macos-latest'
        run: brew install openssl@3
      - name: Install all-features
        run: cargo install cargo-all-features
      - name: Format check
        run: cargo fmt --all -- --check
      - name: Build
        run: cargo build-all-features -- --all
      - name: Run tests
        run: cargo all-features test --jobs 1

  minimal-versions:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - run: python -m pip install breezy launchpadlib
      - name: Install minimal-versions
        run: cargo install cargo-minimal-versions cargo-hack
      - name: Test with minimal versions
        run: cargo minimal-versions --direct test --jobs 1
