Files
Profa b5e2a1f485 fix(security): add workflow permissions & implement memory adapters
Security fixes:
- Add explicit permissions to migration-validation.yml (fixes #37, #38, #39)
- analyze-duplicates job: contents:read, issues:write, pull-requests:write
- validate-migration & check-migration-compliance: contents:read

Issue #109 - RuVector & AgentDB v2 Integration:
- Add ReflexionMemoryAdapter for flaky test prediction (410 lines)
- Add SparseVectorSearch for hybrid BM25/vector search (174 lines)
- Add TieredCompression for 85% memory reduction (328 lines)
- Add comprehensive test suites for all memory adapters

Issue #108 - CI Pipeline fixes:
- Configure jest-junit reporter for CI integration
- Fix FleetManager.database.test.ts flaky tests
- Add mcp-tools-test workflow permissions

Also includes:
- Hackathon TV5 issue report and reliability analysis
- Security scan report
- Code complexity analysis script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 19:26:41 +00:00

265 lines
9.3 KiB
YAML

name: Test Suite Migration Validation
on:
push:
branches:
- 'migration/**'
- 'test-migration/**'
pull_request:
branches:
- main
paths:
- 'tests/**'
- 'docs/migration/**'
- '.github/workflows/migration-validation.yml'
jobs:
validate-migration:
name: Validate Migrated Tests
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run Journey Tests
if: hashFiles('tests/journeys/*.test.ts') != ''
run: |
npm run test:journeys || echo "No journey tests yet"
continue-on-error: true
- name: Run Contract Tests
if: hashFiles('tests/contracts/*.test.ts') != ''
run: |
npm run test:contracts || echo "No contract tests yet"
continue-on-error: true
- name: Run Infrastructure Tests
if: hashFiles('tests/infrastructure/*.test.ts') != ''
run: |
npm run test:infrastructure || echo "No infrastructure tests yet"
continue-on-error: true
- name: Check for Large Test Files
run: |
echo "Checking for test files > 600 lines..."
large_files=$(find tests -name "*.test.ts" -exec wc -l {} \; | awk '$1 > 600 {print $2}')
if [ -n "$large_files" ]; then
echo "⚠️ Found large test files (>600 lines):"
echo "$large_files"
echo "Please split these files according to migration plan."
else
echo "✅ All test files are within size limits"
fi
- name: Check for Skipped Tests
run: |
echo "Checking for skipped tests..."
skipped=$(grep -r "describe.skip\|it.skip\|test.skip" tests --include="*.test.ts" | wc -l)
if [ "$skipped" -gt 0 ]; then
echo "⚠️ Found $skipped skipped tests"
grep -r "describe.skip\|it.skip\|test.skip" tests --include="*.test.ts"
echo "Migration goal: 0 skipped tests"
else
echo "✅ No skipped tests found"
fi
- name: Generate Migration Metrics
run: |
echo "# Migration Metrics" > migration-metrics.md
echo "" >> migration-metrics.md
echo "**Date**: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> migration-metrics.md
echo "" >> migration-metrics.md
total_files=$(find tests -name "*.test.ts" | wc -l)
total_lines=$(find tests -name "*.test.ts" -exec wc -l {} + | tail -1 | awk '{print $1}')
large_files=$(find tests -name "*.test.ts" -exec wc -l {} \; | awk '$1 > 600' | wc -l)
echo "## Current State" >> migration-metrics.md
echo "- Total test files: $total_files" >> migration-metrics.md
echo "- Total lines: $total_lines" >> migration-metrics.md
echo "- Files > 600 lines: $large_files" >> migration-metrics.md
echo "" >> migration-metrics.md
echo "## Target State" >> migration-metrics.md
echo "- Total test files: 50" >> migration-metrics.md
echo "- Total lines: 40,000" >> migration-metrics.md
echo "- Files > 600 lines: 0" >> migration-metrics.md
echo "" >> migration-metrics.md
reduction_files=$((402 - total_files))
reduction_lines=$((195527 - total_lines))
echo "## Progress" >> migration-metrics.md
echo "- Files reduced: $reduction_files ($(echo "scale=1; $reduction_files * 100 / 352" | bc)% of target)" >> migration-metrics.md
echo "- Lines reduced: $reduction_lines ($(echo "scale=1; $reduction_lines * 100 / 155527" | bc)% of target)" >> migration-metrics.md
cat migration-metrics.md
- name: Upload Migration Metrics
uses: actions/upload-artifact@v4
with:
name: migration-metrics
path: migration-metrics.md
analyze-duplicates:
name: Analyze Test Duplicates
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run Duplicate Analysis
run: |
npx tsx scripts/analyze-test-duplicates.ts
- name: Upload Analysis Results
uses: actions/upload-artifact@v4
with:
name: duplicate-analysis
path: docs/migration/duplicate-analysis.json
- name: Comment Analysis Summary
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const analysis = JSON.parse(fs.readFileSync('docs/migration/duplicate-analysis.json', 'utf8'));
const body = `
## 🔍 Test Duplicate Analysis
**Total Files**: ${analysis.totalFiles}
**Total Lines**: ${analysis.totalLines.toLocaleString()}
**Large Files (>1000 lines)**: ${analysis.largeFiles.length}
**Duplicate Groups**: ${analysis.duplicates.length}
### 📂 Category Breakdown
| Category | Files | Lines | Percentage |
|----------|-------|-------|------------|
${Object.entries(analysis.categoryBreakdown).map(([cat, stats]) =>
`| ${cat} | ${stats.files} | ${stats.lines.toLocaleString()} | ${((stats.lines / analysis.totalLines) * 100).toFixed(1)}% |`
).join('\n')}
### 💡 Recommendations
- **Files to delete**: ${analysis.recommendations.filesToDelete.length}
- **Groups to consolidate**: ${analysis.recommendations.filesToConsolidate.length}
- **Estimated reduction**: ${analysis.recommendations.estimatedReduction.files} files, ${analysis.recommendations.estimatedReduction.lines.toLocaleString()} lines
### 🔝 Top Duplicate Groups
${analysis.duplicates.slice(0, 5).map(d =>
`- **${d.pattern}**: ${d.files.length} files, ${d.totalLines.toLocaleString()} lines, ${d.overlapPercentage}% overlap → ${d.recommendation}`
).join('\n')}
[View full analysis](../blob/${context.sha}/docs/migration/duplicate-analysis.json)
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
});
check-migration-compliance:
name: Check Migration Compliance
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check Directory Structure
run: |
echo "Checking for new test directory structure..."
if [ -d "tests/journeys" ]; then
echo "✅ tests/journeys/ exists"
else
echo "⚠️ tests/journeys/ not created yet"
fi
if [ -d "tests/contracts" ]; then
echo "✅ tests/contracts/ exists"
else
echo "⚠️ tests/contracts/ not created yet"
fi
if [ -d "tests/infrastructure" ]; then
echo "✅ tests/infrastructure/ exists"
else
echo "⚠️ tests/infrastructure/ not created yet"
fi
if [ -d "tests/regression" ]; then
echo "✅ tests/regression/ exists"
else
echo "⚠️ tests/regression/ not created yet"
fi
- name: Check for Old Structure
run: |
echo "Checking for old test structure that should be removed..."
if [ -d "tests/unit" ] && [ "$(ls -A tests/unit 2>/dev/null)" ]; then
echo "⚠️ tests/unit/ still contains files (should be migrated)"
ls -lh tests/unit | head -20
fi
if [ -d "tests/integration" ] && [ "$(ls -A tests/integration 2>/dev/null)" ]; then
echo "⚠️ tests/integration/ still contains files (should be migrated)"
ls -lh tests/integration | head -20
fi
if [ -d "tests/agents" ] && [ "$(ls -A tests/agents 2>/dev/null)" ]; then
echo "⚠️ tests/agents/ still contains files (should be migrated)"
ls -lh tests/agents | head -20
fi
- name: Validate Migration Plan Exists
run: |
if [ -f "docs/migration/test-suite-restructuring-plan.md" ]; then
echo "✅ Migration plan exists"
else
echo "❌ Migration plan not found"
exit 1
fi
if [ -f "docs/migration/progress-tracking.md" ]; then
echo "✅ Progress tracking exists"
else
echo "❌ Progress tracking not found"
exit 1
fi