Skip to content

Advanced Testing & Accessibility Suite #39

Advanced Testing & Accessibility Suite

Advanced Testing & Accessibility Suite #39

name: Advanced Testing & Accessibility Suite
on:
push:
branches: [ main, develop ]
paths:
- 'packages/liaison/**'
- 'scripts/test-*.ts'
- '.github/workflows/advanced-testing.yml'
pull_request:
branches: [ main, develop ]
paths:
- 'packages/liaison/**'
- 'scripts/test-*.ts'
schedule:
# Run comprehensive tests weekly on Sundays at 3 AM UTC
- cron: '0 3 * * 0'
workflow_dispatch:
inputs:
run_performance_tests:
description: 'Run performance benchmarks'
required: false
default: true
type: boolean
run_accessibility_tests:
description: 'Run accessibility tests'
required: false
default: true
type: boolean
run_full_suite:
description: 'Run full test suite (all tests)'
required: false
default: false
type: boolean
concurrency:
group: advanced-testing-${{ github.ref }}
cancel-in-progress: true
env:
NODE_OPTIONS: '--max-old-space-size=4096'
jobs:
# Core Testing
core-tests:
name: Core Tests (Latest Node)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 'latest'
- name: Setup Node.js 24.11.1
uses: actions/setup-node@v4
with:
node-version: '24.11.1'
- name: Install dependencies
run: |
cd packages/liaison
bun install --frozen-lockfile
- name: Run standard tests
run: |
cd packages/liaison
bun run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./packages/liaison/coverage/lcov.info
flags: core-tests
name: codecov-umbrella
# Performance Benchmarks
performance-tests:
name: Performance Benchmarks
runs-on: ubuntu-latest
needs: core-tests
if: |
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' && github.event.inputs.run_performance_tests == 'true' ||
github.event_name == 'push' && contains(github.event.head_commit.message, '[perf]')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 'latest'
- name: Install dependencies
run: |
cd packages/liaison
bun install --frozen-lockfile
- name: Run performance benchmarks
run: |
retention-days: 30
- name: Performance regression check
run: |
cd packages/liaison
# Check if performance degraded significantly
if [ -f "test-reports/performance-benchmark-$(ls -t test-reports/performance-benchmark-*.json | head -1 | cut -d- -f2-3)" ]; then
echo "📊 Performance baseline found, checking for regressions..."
# Add regression detection logic here
fi
- name: Comment PR with performance results
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
// Find latest performance report
const reportsDir = 'packages/liaison/test-reports';
const reports = fs.readdirSync(reportsDir)
.filter(f => f.startsWith('performance-benchmark-'))
.sort()
.reverse();
if (reports.length > 0) {
const reportPath = path.join(reportsDir, reports[0]);
const report = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
const comment = `## 📊 Performance Benchmarks
${report.results.map(result =>
`**${result.name}**: ${result.duration.toFixed(2)}ms${result.opsPerSecond ? ` (${result.opsPerSecond.toFixed(2)} ops/s)` : ''}`
).join('\n')}
**Platform**: ${report.platform} (${report.arch})
**Node.js**: ${report.nodeVersion}
**Generated**: ${report.timestamp}
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}
# Accessibility Tests
accessibility-tests:
name: Accessibility Tests
runs-on: ubuntu-latest
needs: core-tests
if: |
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' && github.event.inputs.run_accessibility_tests == 'true' ||
github.event_name == 'push' && contains(github.event.head_commit.message, '[a11y]')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 'latest'
- name: Install dependencies
run: |
cd packages/liaison
bun install --frozen-lockfile
- name: Run accessibility tests
run: |
cd packages/liaison
bun run test:accessibility
- name: Upload accessibility reports
uses: actions/upload-artifact@v4
with:
name: accessibility-reports
path: |
packages/liaison/test-reports/accessibility-test-*.json
packages/liaison/test-reports/accessibility-summary-*.md
retention-days: 30
- name: Check accessibility compliance
run: |
cd packages/liaison
# Check if accessibility tests meet minimum thresholds
if [ -f "test-reports/accessibility-test-$(ls -t test-reports/accessibility-test-*.json | head -1 | cut -d- -f2-3)" ]; then
report_file=$(ls -t test-reports/accessibility-test-*.json | head -1)
success_rate=$(cat "$report_file" | jq -r '.summary.successRate')
echo "📈 Accessibility success rate: ${success_rate}%"
if (( $(echo "$success_rate < 80" | bc -l) )); then
echo "⚠️ Accessibility compliance below 80% threshold"
exit 1
else
echo "✅ Accessibility compliance met: ${success_rate}%"
fi
fi
- name: Generate accessibility badge
run: |
cd packages/liaison
# Generate accessibility badge data
if [ -f "test-reports/accessibility-test-$(ls -t test-reports/accessibility-test-*.json | head -1 | cut -d- -f2-3)" ]; then
report_file=$(ls -t test-reports/accessibility-test-*.json | head -1)
success_rate=$(cat "$report_file" | jq -r '.summary.successRate')
# Create badge data (this would typically use a badge service)
echo "{\"schemaVersion\":1,\"label\":\"Accessibility\",\"message\":\"${success_rate}%\",\"color\":\"${success_rate >= 80 ? 'brightgreen' : success_rate >= 60 ? 'yellow' : 'red'}\"}" > test-reports/accessibility-badge.json
fi
# Full Test Suite Integration
full-test-suite:
name: Comprehensive Test Suite
runs-on: ubuntu-latest
needs: [core-tests, performance-tests, accessibility-tests]
if: |
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' && github.event.inputs.run_full_suite == 'true' ||
github.event_name == 'push' && (contains(github.event.head_commit.message, '[full-test]') || github.ref == 'refs/heads/main')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 'latest'
- name: Install dependencies
run: |
cd packages/liaison
bun install --frozen-lockfile
- name: Run complete test suite
run: |
cd packages/liaison
bun run test:full
- name: Aggregate all test reports
run: |
cd packages/liaison
mkdir -p test-reports/aggregate
# Create comprehensive test summary
cat > test-reports/aggregate/comprehensive-test-report.md << 'EOF'
# Comprehensive Test Suite Report
Generated: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
Commit: ${{ github.sha }}
Branch: ${{ github.ref_name }}
## Test Coverage
EOF
if [ -f "coverage/coverage-summary.json" ]; then
coverage=$(cat coverage/coverage-summary.json | jq -r '.total.statements.pct')
echo "- Coverage: ${coverage}%" >> test-reports/aggregate/comprehensive-test-report.md
fi
echo "" >> test-reports/aggregate/comprehensive-test-report.md
## Performance Summary
EOF
# Add performance summary
for perf_file in test-reports/performance-benchmark-*.json; do
if [ -f "$perf_file" ]; then
echo "### $(basename "$perf_file" .json)" >> test-reports/aggregate/comprehensive-test-report.md
cat "$perf_file" | jq -r '.results[] | "- **\(.name)**: \(.duration.toFixed(2))ms"' >> test-reports/aggregate/comprehensive-test-report.md
echo "" >> test-reports/aggregate/comprehensive-test-report.md
fi
done
echo "" >> test-reports/aggregate/comprehensive-test-report.md
## Accessibility Summary
EOF
# Add accessibility summary
for a11y_file in test-reports/accessibility-test-*.json; do
if [ -f "$a11y_file" ]; then
success_rate=$(cat "$a11y_file" | jq -r '.summary.successRate')
echo "- Accessibility Compliance: ${success_rate}%" >> test-reports/aggregate/comprehensive-test-report.md
fi
done
- name: Upload comprehensive test reports
uses: actions/upload-artifact@v4
with:
name: comprehensive-test-reports
path: |
packages/liaison/test-reports/
retention-days: 90
- name: Update test summary in PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
const reportPath = 'packages/liaison/test-reports/aggregate/comprehensive-test-report.md';
if (fs.existsSync(reportPath)) {
const report = fs.readFileSync(reportPath, 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## 📋 Comprehensive Test Results\n\n${report}`
});
}
# Security & Dependency Scanning
security-scan:
name: Security & Dependency Scan
runs-on: ubuntu-latest
needs: core-tests
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 'latest'
- name: Install dependencies
run: |
cd packages/liaison
bun install --frozen-lockfile
- name: Run security audit
run: |
cd packages/liaison
bun audit || echo "⚠️ Security audit completed with warnings"
# Generate security report
bun audit --json > test-reports/security-audit.json 2>&1 || true
- name: Run dependency check
run: |
cd packages/liaison
bunx depcheck || echo "⚠️ Dependency check completed"
- name: Upload security reports
uses: actions/upload-artifact@v4
with:
name: security-reports
path: |
packages/liaison/test-reports/security-audit.json
retention-days: 30
# Test Results Notification
notify-results:
name: Notify Test Results
runs-on: ubuntu-latest
needs: [core-tests, performance-tests, accessibility-tests, full-test-suite, security-scan]
if: always() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
steps:
- name: Notify on success
if: ${{ needs.core-tests.result == 'success' }}
run: |
echo "✅ Advanced testing completed successfully"
# Add notification logic (Slack, Discord, etc.) if needed
- name: Notify on failure
if: ${{ needs.core-tests.result == 'failure' || needs.performance-tests.result == 'failure' || needs.accessibility-tests.result == 'failure' }}
run: |
echo "❌ Advanced testing failed"
# Add failure notification logic
exit 1