Skip to content

Code Analysis Pipeline #255

Code Analysis Pipeline

Code Analysis Pipeline #255

name: Code Analysis Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'
# Required for peaceiris/actions-gh-pages to push to gh-pages branch
permissions:
contents: write
pages: write
jobs:
# Fast unit tests - run first and in parallel
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Setup ast-grep
uses: ./.github/actions/setup-ast-grep
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run unit tests
run: |
python scripts/run_tests.py --unit-only --no-coverage
- name: Generate unit test coverage
run: |
coverage run -m pytest tests/unit/ --tb=short
coverage report --show-missing
coverage xml -o coverage-unit.xml
- name: Upload unit test coverage
uses: actions/upload-artifact@v4
with:
name: coverage-unit-py${{ matrix.python-version }}
path: coverage-unit.xml
# Integration tests - component interaction tests
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: unit-tests
strategy:
matrix:
python-version: ['3.11', '3.12']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Setup ast-grep
uses: ./.github/actions/setup-ast-grep
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run integration tests
run: |
python scripts/run_tests.py --integration-only --no-coverage
- name: Generate integration test coverage
run: |
coverage run -m pytest tests/integration/ --tb=short
coverage report --show-missing
coverage xml -o coverage-integration.xml
- name: Upload integration test coverage
uses: actions/upload-artifact@v4
with:
name: coverage-integration-py${{ matrix.python-version }}
path: coverage-integration.xml
# E2E tests - full pipeline tests (slower, run separately)
e2e-tests:
name: End-to-End Tests
runs-on: ubuntu-latest
needs: integration-tests
strategy:
matrix:
python-version: ['3.11']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Setup ast-grep
uses: ./.github/actions/setup-ast-grep
- name: Install Node.js dependencies
run: npm ci
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Verify dependencies
run: |
echo "=== Verifying dependencies ==="
echo "Node.js: $(node --version)"
echo "Python: $(python --version)"
echo "ast-grep: $(ast-grep --version)"
python -c "import pydantic; print(f'pydantic: {pydantic.__version__}')"
python -c "import coverage; print(f'coverage: {coverage.__version__}')"
python -c "import tqdm; print(f'tqdm: {tqdm.__version__}')"
python -c "import pytest; print(f'pytest: {pytest.__version__}')"
- name: Run environment verification
run: npm run verify
- name: Run e2e tests
run: |
python scripts/run_tests.py --e2e-only --no-coverage
- name: Generate e2e test coverage
run: |
coverage run -m pytest tests/e2e/ --tb=short
coverage report --show-missing
coverage xml -o coverage-e2e.xml
coverage html
- name: Upload e2e test coverage
uses: actions/upload-artifact@v4
with:
name: coverage-e2e-py${{ matrix.python-version }}
path: |
coverage-e2e.xml
htmlcov/
# Browser tests - Chrome runs first, other browsers depend on Chrome passing
browser-tests-chrome:
name: Browser Tests (Chrome)
runs-on: ubuntu-latest
needs: e2e-tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install Node.js dependencies
run: npm ci
- name: Install Playwright browsers (Chromium only)
run: npx playwright install chromium --with-deps
- name: Run Chrome browser tests
run: npm run test:browser:chrome
- name: Upload Chrome test results
uses: actions/upload-artifact@v4
if: always()
with:
name: browser-test-results-chrome
path: |
playwright-report/
test-results/
browser-tests-other:
name: Browser Tests (Firefox & WebKit)
runs-on: ubuntu-latest
needs: browser-tests-chrome # Only runs if Chrome tests pass
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install Node.js dependencies
run: npm ci
- name: Install Playwright browsers (Firefox & WebKit)
run: |
npx playwright install firefox --with-deps
npx playwright install webkit --with-deps
- name: Run Firefox browser tests
run: npm run test:browser:firefox
- name: Run WebKit browser tests
run: npm run test:browser:webkit
- name: Upload other browser test results
uses: actions/upload-artifact@v4
if: always()
with:
name: browser-test-results-other
path: |
playwright-report/
test-results/
benchmark:
name: Performance Benchmarks
runs-on: ubuntu-latest
needs: browser-tests-other # Now waits for all browser tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Setup ast-grep
uses: ./.github/actions/setup-ast-grep
- name: Install Node.js dependencies
run: npm ci
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run performance benchmarks
run: |
python tests/performance/benchmark_suite.py
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: performance-report
path: performance_report.json
analyze:
name: Code Analysis
runs-on: ubuntu-latest
needs: browser-tests-other # Now waits for all browser tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Setup ast-grep
uses: ./.github/actions/setup-ast-grep
- name: Install Node.js dependencies
run: npm ci
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run code quality analysis
run: |
python -m src.analyzers.code_quality src/ \
--json quality_report.json \
--text quality_report.txt
- name: Run test coverage analysis
run: |
python -m src.analyzers.test_coverage src/ \
--test-dir tests/ \
--json coverage_report.json \
--parallel \
--cache
- name: Run dependency analysis
run: |
python -m src.analyzers.dependencies src/ \
--json dependency_report.json \
--detect-circular \
--parallel \
--cache
- name: Upload analysis reports
uses: actions/upload-artifact@v4
with:
name: analysis-reports
path: |
quality_report.json
quality_report.txt
coverage_report.json
dependency_report.json
dashboard:
name: Generate Dashboard
runs-on: ubuntu-latest
needs: analyze
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Setup ast-grep
uses: ./.github/actions/setup-ast-grep
- name: Install Node.js dependencies
run: npm ci
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Download analysis reports
uses: actions/download-artifact@v4
with:
name: analysis-reports
- name: Generate schemas
run: |
python -m src.generators.schema --root src/
- name: Generate dashboard
run: |
python -m src.generators.dashboard \
--schemas schemas_enhanced.json \
--quality quality_report.json \
--coverage coverage_report.json \
--dependency dependency_report.json \
--output dashboard.html
- name: Upload dashboard
uses: actions/upload-artifact@v4
with:
name: dashboard
path: dashboard.html
- name: Deploy to GitHub Pages (optional)
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .
publish_branch: gh-pages
keep_files: false
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: 'Update analysis dashboard'