Skip to content

DeepStack Test Suite #467

DeepStack Test Suite

DeepStack Test Suite #467

Workflow file for this run

name: DeepStack Test Suite
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
schedule:
# Run nightly tests at 2 AM UTC
- cron: '0 2 * * *'
# Permissions needed for test result publishing and PR comments
permissions:
contents: read
checks: write
pull-requests: write
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov pytest-asyncio pytest-xdist
- name: Run unit tests
run: |
pytest tests/unit/ -v -n auto \
--cov=core \
--cov-report=xml \
--cov-report=term-missing \
--junit-xml=test-results/unit-tests.xml
- name: Upload unit test results
uses: actions/upload-artifact@v4
if: always()
with:
name: unit-test-results
path: test-results/unit-tests.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unit
name: unit-tests
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: unit-tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov pytest-asyncio
- name: Run integration tests
run: |
pytest tests/integration/ -v \
--cov=core \
--cov-report=xml \
--cov-report=term-missing \
--cov-fail-under=0 \
--junit-xml=test-results/integration-tests.xml
- name: Upload integration test results
uses: actions/upload-artifact@v4
if: always()
with:
name: integration-test-results
path: test-results/integration-tests.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: integration
name: integration-tests
e2e-tests:
name: E2E Tests
runs-on: ubuntu-latest
needs: integration-tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov pytest-asyncio pytest-bdd
- name: Run E2E tests
run: |
pytest tests/e2e/ -v \
--cov=core \
--cov-report=xml \
--cov-report=term-missing \
--cov-fail-under=0 \
--junit-xml=test-results/e2e-tests.xml
- name: Upload E2E test results
uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-test-results
path: test-results/e2e-tests.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: e2e
name: e2e-tests
coverage-report:
name: Combined Coverage Report
runs-on: ubuntu-latest
needs: [unit-tests, integration-tests, e2e-tests]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov pytest-asyncio pytest-bdd pytest-xdist
- name: Run all tests with coverage
run: |
pytest tests/ -v \
--cov=core \
--cov-report=html \
--cov-report=xml \
--cov-report=term-missing \
--cov-fail-under=0 \
--junit-xml=test-results/all-tests.xml
- name: Upload HTML coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-html-report
path: htmlcov/
- name: Upload combined test results
uses: actions/upload-artifact@v4
if: always()
with:
name: all-test-results
path: test-results/all-tests.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: combined
name: combined-coverage
fail_ci_if_error: false # Don't fail on Codecov rate limits or network issues
- name: Comment coverage on PR
if: github.event_name == 'pull_request'
uses: py-cov-action/python-coverage-comment-action@v3
continue-on-error: true # Don't fail if coverage comment fails
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [unit-tests, integration-tests, e2e-tests]
if: always()
steps:
- name: Download all test results
uses: actions/download-artifact@v4
with:
path: test-results
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: 'test-results/**/*.xml'
check_name: 'Test Results'
comment_title: 'Test Summary'
- name: Test Summary Report
run: |
echo "## Test Execution Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Results by Category" >> $GITHUB_STEP_SUMMARY
echo "- Unit Tests: ${{ needs.unit-tests.result }}" >> $GITHUB_STEP_SUMMARY
echo "- Integration Tests: ${{ needs.integration-tests.result }}" >> $GITHUB_STEP_SUMMARY
echo "- E2E Tests: ${{ needs.e2e-tests.result }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Coverage" >> $GITHUB_STEP_SUMMARY
echo "Combined coverage report available in artifacts" >> $GITHUB_STEP_SUMMARY
quality-gates:
name: Quality Gates
runs-on: ubuntu-latest
needs: coverage-report
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov coverage
- name: Check coverage threshold
run: |
pytest tests/ --cov=core --cov-fail-under=20
echo "Coverage meets minimum threshold"
- name: Check critical module coverage
run: |
pytest tests/unit/test_orchestrator.py tests/integration/test_orchestrator_integration.py \
--cov=core.orchestrator \
--cov-fail-under=70 || echo "Warning: Orchestrator coverage below target"
performance-tests:
name: Performance Tests
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-benchmark
- name: Run performance benchmarks
run: |
pytest tests/ -m benchmark --benchmark-only || echo "No benchmark tests found"
- name: Upload benchmark results
uses: actions/upload-artifact@v4
if: always()
with:
name: benchmark-results
path: .benchmarks/
security-scan:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install safety bandit
- name: Run safety check
run: |
safety check --json || echo "Security vulnerabilities found"
- name: Run bandit security scan
run: |
bandit -r core/ -f json -o bandit-report.json || echo "Security issues found"
- name: Upload security reports
uses: actions/upload-artifact@v4
if: always()
with:
name: security-reports
path: |
bandit-report.json