Files
vllm-omni/.github/workflows/ci.yml
T
2025-11-18 20:54:26 +08:00

125 lines
4.3 KiB
YAML

name: CI
on:
pull_request:
branches: [main]
workflow_dispatch:
inputs:
test_changed_only:
description: 'Only test changed files (true) or all files (false)'
required: false
default: 'true'
type: choice
options:
- 'true'
- 'false'
enable_changed_files_detection:
description: 'Enable changed files detection feature'
required: false
default: 'true'
type: choice
options:
- 'true'
- 'false'
workflow_call:
inputs:
test_changed_only:
description: 'Only test changed files (true) or all files (false)'
required: false
type: string
default: 'true'
enable_changed_files_detection:
description: 'Enable changed files detection feature'
required: false
type: string
default: 'true'
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Free disk space
run: |
# Remove large, preinstalled toolchains we don't need on the runner
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/hostedtoolcache/CodeQL
# Prune docker to reclaim space (safe on GH runners)
docker system prune -af || true
df -h
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Prepare environment with uv
run: |
python -m pip install --upgrade pip uv
uv venv --python "${{ matrix.python-version }}" --seed
echo "VIRTUAL_ENV=${PWD}/.venv" >> "$GITHUB_ENV"
echo "PATH=${PWD}/.venv/bin:${PATH}" >> "$GITHUB_ENV"
# Activate env to ensure subsequent commands succeed in this step
source .venv/bin/activate
uv pip install -e ".[dev]"
- name: Determine test scope
id: test-scope
env:
ENABLE_CHANGED_FILES_DETECTION: ${{ inputs.enable_changed_files_detection || 'true' }}
TEST_CHANGED_ONLY: ${{ inputs.test_changed_only || 'true' }}
run: |
# Determine if we should test only changed files
# If detection is disabled, always test all files
if [ "$ENABLE_CHANGED_FILES_DETECTION" != "true" ]; then
TEST_CHANGED_ONLY="false"
fi
echo "test_changed_only=$TEST_CHANGED_ONLY" >> "$GITHUB_OUTPUT"
echo "enable_detection=$ENABLE_CHANGED_FILES_DETECTION" >> "$GITHUB_OUTPUT"
echo "Test scope: $TEST_CHANGED_ONLY"
echo "Changed files detection: $ENABLE_CHANGED_FILES_DETECTION"
- name: Get changed test files
id: changed-tests
if: steps.test-scope.outputs.test_changed_only == 'true' && steps.test-scope.outputs.enable_detection == 'true'
env:
GITHUB_BASE_REF: ${{ github.event.pull_request.base.sha || '' }}
GITHUB_SHA: ${{ github.sha }}
run: |
chmod +x .github/scripts/detect_changed_tests.sh
.github/scripts/detect_changed_tests.sh \
"${{ github.event.pull_request.base.sha || github.event.before || '' }}" \
"${{ github.sha }}" \
"${{ github.event_name }}"
- name: Run tests (changed files only)
if: steps.test-scope.outputs.test_changed_only == 'true' && steps.changed-tests.outputs.has_tests == 'true'
run: |
pytest "${{ steps.changed-tests.outputs.test_files }}" -v -m "not slow"
- name: Run tests (all files)
if: steps.test-scope.outputs.test_changed_only == 'false' || steps.changed-tests.outputs.has_tests == 'false'
run: |
if [ ! -d tests ]; then
echo "tests/ directory not found. Skipping pytest run."
exit 0
fi
TEST_FILES=$(find tests -type f \( -name "test_*.py" -o -name "*_test.py" \))
if [ -z "$TEST_FILES" ]; then
echo "No pytest-compatible test files detected under tests/. Skipping pytest run."
exit 0
fi
pytest tests/ -v -m "not slow"