Skip to content

Tests

Tests #110

Workflow file for this run

name: Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
schedule:
# Run tests daily at 2 AM UTC
- cron: '0 2 * * *'
env:
PYTHON_VERSION: "3.12"
UV_VERSION: "0.4.30"
TESTING: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint-and-format:
name: Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --dev
- name: Format check
run: uv run ruff format --check src tests
- name: Lint check
run: uv run ruff check src tests
- name: Type check
run: uv run mypy src
continue-on-error: true
test-matrix:
name: Test Suite
runs-on: ${{ matrix.os }}
needs: lint-and-format
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.12", "3.13"]
test-type: ["unit", "integration"]
exclude:
# Reduce matrix size for faster CI
- os: macos-latest
python-version: "3.13"
- os: windows-latest
python-version: "3.13"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --dev
- name: Run ${{ matrix.test-type }} tests
run: uv run python scripts/run_tests.py ${{ matrix.test-type }}
- name: Upload coverage to Codecov
if: matrix.test-type == 'unit' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
performance-tests:
name: Performance Tests
runs-on: ubuntu-latest
needs: lint-and-format
if: github.event_name == 'push' || github.event_name == 'schedule'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --dev
- name: Run performance tests
run: uv run python scripts/run_tests.py performance
continue-on-error: true
- name: Store benchmark results
uses: benchmark-action/github-action-benchmark@v1
if: github.ref == 'refs/heads/main'
with:
tool: 'pytest'
output-file-path: '.benchmarks/Linux-CPython-3.12-64bit/benchmark.json'
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
comment-on-alert: true
alert-threshold: '200%'
smoke-tests:
name: Smoke Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --dev
- name: Run smoke tests
run: uv run python scripts/run_tests.py smoke
security-scan:
name: Security Scan
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'schedule'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --dev
- name: Run Bandit security scan
run: uv run bandit -r src -f json -o security-report.json || true
- name: Upload security scan results
uses: actions/upload-artifact@v4
with:
name: security-scan-results
path: security-report.json
dependency-check:
name: Dependency Security Check
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'schedule'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --dev
- name: Check for known security vulnerabilities
run: uv run pip-audit --format=json --output=vulnerability-report.json || true
- name: Upload vulnerability scan results
uses: actions/upload-artifact@v4
with:
name: vulnerability-scan-results
path: vulnerability-report.json
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [test-matrix, smoke-tests]
if: always()
steps:
- name: Check test results
run: |
echo "Test Matrix Results: ${{ needs.test-matrix.result }}"
echo "Smoke Tests Results: ${{ needs.smoke-tests.result }}"
if [[ "${{ needs.test-matrix.result }}" == "failure" || "${{ needs.smoke-tests.result }}" == "failure" ]]; then
echo "❌ Critical tests failed"
exit 1
else
echo "✅ All critical tests passed"
fi
nightly-regression:
name: Nightly Regression Tests
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --dev
- name: Run comprehensive test suite
run: uv run python scripts/run_tests.py ci
- name: Store test artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: nightly-test-results
path: |
htmlcov/
coverage.xml
.benchmarks/
benchmark_results/
security-report.json
publish-coverage:
name: Publish Coverage
runs-on: ubuntu-latest
needs: test-matrix
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --dev
- name: Generate coverage report
run: uv run python scripts/run_tests.py coverage
- name: Deploy coverage to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./htmlcov
destination_dir: coverage
auto-merge-dependabot:
name: Auto-merge Dependabot PRs
runs-on: ubuntu-latest
needs: [test-matrix, smoke-tests]
if: ${{ github.actor == 'dependabot[bot]' && needs.test-matrix.result == 'success' && needs.smoke-tests.result == 'success' }}
steps:
- name: Auto-merge Dependabot PRs
uses: dependabot/fetch-metadata@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
id: metadata
- name: Enable auto-merge for Dependabot PRs
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' }}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}