name: Test

on:
  workflow_call:
  workflow_dispatch:
  push:
    branches:
      - "dev"
      - "release-**"
    paths:
      - '**.py'
      - 'pyproject.toml'
      - 'requirements/**.txt'
      - '.github/workflows/test.yml' # This workflow
  pull_request:
    branches:
      - "dev"
      - "release-**"
    paths:
      - '**.py'
      - 'pyproject.toml'
      - 'requirements/**.txt'
      - '.github/workflows/test.yml' # This workflow

env:
  LC_ALL: en_US.UTF-8
  PYTHONHASHSEED: 0

defaults:
  run:
    shell: bash

permissions:
  contents: read

jobs:
  test:
    name: "test: ${{ matrix.python }} on ${{ matrix.platform }}"
    runs-on: "${{ matrix.platform }}"
    strategy:
      matrix:
        python:
          - "3.10"
          - "3.11"
          - "3.12"
          - "3.13"
        platform:
          - "ubuntu-latest"

    steps:
      - name: "Harden Runner"
        uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
        with:
          egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

      - name: Checkout
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
        with:
          # https://github.com/actions/checkout/issues/249
          fetch-depth: 0

      - name: Free disk space
        uses: ./.github/actions/free-disk-space
  
      - name: Setup Python ${{ matrix.python }}
        uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
        with:
          python-version: ${{ matrix.python }}
          cache: pip
          cache-dependency-path: |
            **/pyproject.toml
            **/requirements/*.txt

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install vllm
          python -m pip install -r requirements/test.txt
          python -m pip install -r requirements/common.txt

      - name: "Run non-CUDA unit tests"
        run: |
          pytest --ignore=tests/disagg --ignore=tests/v1/test_nixl_storage.py \
            --ignore=tests/v1/multiprocess/ \
            --ignore=tests/v1/distributed/ \
            --ignore=tests/v1/mp_observability/ \
            --ignore=tests/skipped \
            --ignore=tests/v1/storage_backend/test_eic.py

