on:
  push:
    branches:
      - master
  pull_request:

name: CI

jobs:
  test:
    name: Test Suite
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest, macos-14]
        additional_args: ["", "--no-default-features --features native-tls", "--features http3"]
        # vsock feature is only on linux
        include:
          - os: ["ubuntu-latest"]
            additional_args: "--features vsock"
    steps:
      # We need nasm to build aws-lc on windows
      - uses: ilammy/setup-nasm@v1
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo test ${{ matrix.additional_args }}

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - name: Enforce formatting
        run: cargo fmt --all --check

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
      - name: Linting
        run: cargo clippy --all-targets --all-features -- -D warnings
