name: Rust CI

on:
  push:
    branches: [ '*', '*/*' ]

jobs:
  test:
    name: Test for Rust ${{ matrix.rustver }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        rustver: ['1.87.0', '1.89.0', '1.94.0']
        os: [ubuntu-latest]
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.rustver }}
      - run: docker compose -f env/standalone-docker/docker-compose.yml up -d
      - run: cargo test -- --show-output
      - run: cargo test --features standalone-async --no-default-features -- --show-output

  cover:
    name: Coverage for Rust ${{ matrix.rustver }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        rustver: [stable]
        os: [ubuntu-latest]
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.rustver }}
          components: llvm-tools-preview
      - run: docker compose -f env/standalone-docker/docker-compose.yml up -d
      - run: cargo install cargo-llvm-cov
      - run: cargo llvm-cov
