name: CI (Linux)

on: [push, pull_request]

jobs:
  build_and_test:
    strategy:
      fail-fast: false
      matrix:
        version:
          - 1.88.0 # MSRV
          - stable
          - nightly

    name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Install ${{ matrix.version }}
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu

      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - name: Generate Cargo.lock
        run: cargo generate-lockfile

      - name: Cache Dependencies
        uses: Swatinem/rust-cache@v1.0.1

      - name: Run tests [tokio]
        uses: actions-rs/cargo@v1
        timeout-minutes: 15
        with:
          command: test
          args: --all --features=ntex/tokio

      - name: Run tests [neon-polling]
        uses: actions-rs/cargo@v1
        timeout-minutes: 15
        with:
          command: test
          args: --all --features=ntex/neon-polling

      - name: Run tests [neon-uring]
        uses: actions-rs/cargo@v1
        timeout-minutes: 15
        with:
          command: test
          args: --all --features=ntex/neon-uring

      - name: Run tests [compio]
        uses: actions-rs/cargo@v1
        timeout-minutes: 15
        with:
          command: test
          args: --all --features=ntex/compio
