Skip to content

Refactor Tests

Refactor Tests #2

Workflow file for this run

name: Python-mode Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
schedule:
- cron: '0 0 * * 0' # Weekly run
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
test-suite: ['unit', 'integration']
fail-fast: false
max-parallel: 4
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.python-version }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.python-version }}-
${{ runner.os }}-buildx-
- name: Build test environment
run: |
# Build the docker compose services
docker compose build \
--build-arg PYTHON_VERSION=${{ matrix.python-version }} \
--build-arg PYTHON_VERSION_SHORT=${{ matrix.python-version }}
- name: Run test suite
run: |
# Set Python version environment variables
export PYTHON_VERSION="${{ matrix.python-version }}"
export PYTHON_VERSION_SHORT="${{ matrix.python-version }}"
export TEST_SUITE="${{ matrix.test-suite }}"
export GITHUB_ACTIONS=true
# Run dual test suite (both legacy and Vader tests)
python scripts/dual_test_runner.py
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.python-version }}-${{ matrix.test-suite }}
path: |
test-results.json
test-logs/
results/
- name: Upload coverage reports
uses: codecov/codecov-action@v3
if: matrix.test-suite == 'unit'
with:
file: ./coverage.xml
flags: python-${{ matrix.python-version }}
- name: Basic test validation
run: |
echo "Tests completed successfully"
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
aggregate-results:
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Generate test report
run: |
python scripts/generate_test_report.py \
--input-dir . \
--output-file test-report.html
- name: Upload test report
uses: actions/upload-artifact@v4
with:
name: test-report
path: test-report.html
- name: Comment PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const report = fs.readFileSync('test-summary.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: report
});