Skip to content

Refactor Tests

Refactor Tests #1

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.8', '3.9', '3.10', '3.11', '3.12']
vim-version: ['8.2', '9.0', '9.1']
test-suite: ['unit', 'integration', 'performance']
fail-fast: false
max-parallel: 6
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 }}-${{ matrix.vim-version }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.python-version }}-${{ matrix.vim-version }}-
${{ runner.os }}-buildx-
- name: Build test environment
run: |
docker buildx build \
--cache-from type=local,src=/tmp/.buildx-cache \
--cache-to type=local,dest=/tmp/.buildx-cache-new,mode=max \
--build-arg PYTHON_VERSION=${{ matrix.python-version }} \
--build-arg VIM_VERSION=${{ matrix.vim-version }} \
-t python-mode-test:${{ matrix.python-version }}-${{ matrix.vim-version }} \
-f Dockerfile.test-runner \
--load \
.
- name: Run dual test suite
run: |
# Build the test images first
docker compose -f docker-compose.test.yml build
# Run dual testing (both legacy and Vader tests)
python scripts/dual_test_runner.py
# Also run the advanced orchestrator for performance metrics
docker run --rm \
-v ${{ github.workspace }}:/workspace:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
-e TEST_SUITE=${{ matrix.test-suite }} \
-e GITHUB_ACTIONS=true \
-e GITHUB_SHA=${{ github.sha }} \
python-mode-test:${{ matrix.python-version }}-${{ matrix.vim-version }} \
python /opt/test_orchestrator.py --parallel 2 --timeout 120
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.python-version }}-${{ matrix.vim-version }}-${{ matrix.test-suite }}
path: |
test-results.json
test-logs/
results/
results/*.md
results/*.json
- name: Upload coverage reports
uses: codecov/codecov-action@v3
if: matrix.test-suite == 'unit'
with:
file: ./coverage.xml
flags: python-${{ matrix.python-version }}-vim-${{ matrix.vim-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
});