# TEMPORARILY DISABLED - Test Validation Workflow
# Comprehensive validation for develop branch before promotion
name: DISABLED - Test Branch Validation
on:
# TEMPORARILY DISABLED FOR REPOSITORY RECOVERY
# push:
# branches: [ test ]
# pull_request:
# branches: [ test ]
# Manual trigger for validation
# workflow_dispatch:
permissions:
contents: read
pull-requests: read
checks: write
env:
NODE_ENV: test
jobs:
# Quick validation first
quick-validation:
name: Quick Validation
runs-on: ubuntu-latest
timeout-minutes: 8
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Generate version files
run: npm run prebuild
- name: Type checking
run: npm run type-check
- name: Linting
run: npm run lint:all
- name: Unit tests
run: npm run test:unit
# Build validation
build-validation:
name: Build Validation
runs-on: ubuntu-latest
needs: quick-validation
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Clean build
run: npm run clean
- name: Generate version files
run: npm run prebuild
- name: Production build
run: npm run build
- name: Validate build artifacts
run: |
echo "Validating build artifacts..."
# Check main files exist
test -f dist/index.js || { echo "❌ Missing dist/index.js"; exit 1; }
test -f dist/core/TaskContextManager.js || { echo "❌ Missing TaskContextManager"; exit 1; }
# Check generated version file
test -f src/generated/version.ts || { echo "❌ Missing generated version.ts"; exit 1; }
# Validate package.json exports
node -e "const pkg = require('./package.json'); console.log('Main entry:', pkg.main);"
# Test binary execution
node dist/index.js --help > /dev/null 2>&1 || { echo "❌ Binary execution failed"; exit 1; }
echo "✅ Build validation passed"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ github.sha }}
path: |
dist/
src/generated/
retention-days: 7
# Comprehensive testing
comprehensive-testing:
name: Comprehensive Testing
runs-on: ubuntu-latest
needs: quick-validation
timeout-minutes: 25
strategy:
matrix:
node-version: ['18', '20', '22']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Generate version files
run: npm run prebuild
- name: Run all test suites
run: npm run test:all
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-node-${{ matrix.node-version }}-${{ github.sha }}
path: |
coverage/
test-results/
retention-days: 7
# Security validation
security-validation:
name: Security Validation
runs-on: ubuntu-latest
needs: quick-validation
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Audit dependencies
run: |
echo "Running security audit..."
npm audit --audit-level high --production
- name: Check for secrets
run: |
echo "Checking for potential secrets..."
# Simple regex checks for common secrets
if grep -r "password\|secret\|token\|key" src/ --include="*.ts" --include="*.js" | grep -v "// allow-secret"; then
echo "⚠️ Potential secrets found (use '// allow-secret' comment if intentional)"
else
echo "✅ No obvious secrets detected"
fi
- name: Validate permissions
run: |
echo "Checking file permissions..."
# Check no executable files except bin
find src/ -type f -executable | grep -v ".git" && {
echo "❌ Unexpected executable files found"
exit 1
} || echo "✅ File permissions OK"
# Performance validation
performance-validation:
name: Performance Validation
runs-on: ubuntu-latest
needs: build-validation
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts-${{ github.sha }}
- name: Binary execution test
run: |
echo "Testing binary execution..."
# Test binary execution with --help (doesn't require MCP connection)
if node dist/index.js --help > /dev/null 2>&1; then
echo "✅ Binary executes successfully"
else
echo "❌ Binary execution failed"
exit 1
fi
- name: Startup time test
run: |
echo "Testing startup performance..."
START_TIME=$(date +%s%N)
timeout 10s node dist/index.js --help > /dev/null 2>&1
END_TIME=$(date +%s%N)
DURATION_MS=$(( (END_TIME - START_TIME) / 1000000 ))
echo "Startup time: ${DURATION_MS}ms"
# Set reasonable startup time limit (2 seconds)
if [ $DURATION_MS -gt 2000 ]; then
echo "⚠️ Slow startup: ${DURATION_MS}ms"
else
echo "✅ Startup time acceptable: ${DURATION_MS}ms"
fi
# Coverage validation
coverage-validation:
name: Coverage Validation
runs-on: ubuntu-latest
needs: comprehensive-testing
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Generate version files
run: npm run prebuild
- name: Generate coverage report
run: |
echo "Running tests with coverage generation..."
npm run test:coverage
# Verify coverage files were generated
if [ ! -f coverage/coverage-summary.json ]; then
echo "⚠️ Coverage summary not generated, running with explicit options"
npx jest --coverage --coverageReporters=json-summary --coverageReporters=text
fi
echo "Coverage files:"
ls -la coverage/ || echo "No coverage directory found"
- name: Validate coverage thresholds
run: |
echo "Validating coverage requirements..."
# Extract coverage percentages from jest output
if [ -f coverage/coverage-summary.json ]; then
LINES=$(node -p "JSON.parse(require('fs').readFileSync('coverage/coverage-summary.json')).total.lines.pct")
BRANCHES=$(node -p "JSON.parse(require('fs').readFileSync('coverage/coverage-summary.json')).total.branches.pct")
FUNCTIONS=$(node -p "JSON.parse(require('fs').readFileSync('coverage/coverage-summary.json')).total.functions.pct")
echo "Coverage: Lines: ${LINES}%, Branches: ${BRANCHES}%, Functions: ${FUNCTIONS}%"
# Check thresholds using awk instead of bc for portability
if awk "BEGIN {exit !($LINES >= 95)}"; then
echo "✅ Lines coverage: ${LINES}% (≥95%)"
else
echo "❌ Lines coverage: ${LINES}% (<95%)"
exit 1
fi
if awk "BEGIN {exit !($BRANCHES >= 85)}"; then
echo "✅ Branches coverage: ${BRANCHES}% (≥85%)"
else
echo "❌ Branches coverage: ${BRANCHES}% (<85%)"
exit 1
fi
if awk "BEGIN {exit !($FUNCTIONS >= 96)}"; then
echo "✅ Functions coverage: ${FUNCTIONS}% (≥96%)"
else
echo "❌ Functions coverage: ${FUNCTIONS}% (<96%)"
exit 1
fi
else
echo "❌ Coverage summary not found"
exit 1
fi
- name: Upload coverage report
uses: codecov/codecov-action@v4
with:
file: ./coverage/lcov.info
flags: validation-tests
name: test-validation-coverage
# Final validation summary
validation-summary:
name: Validation Summary
runs-on: ubuntu-latest
needs:
- quick-validation
- build-validation
- comprehensive-testing
- security-validation
- performance-validation
- coverage-validation
if: always()
timeout-minutes: 5
steps:
- name: Validation Results
run: |
echo "🔍 Test Branch Validation Results"
echo "================================"
# Check all job results
QUICK_RESULT="${{ needs.quick-validation.result }}"
BUILD_RESULT="${{ needs.build-validation.result }}"
TESTING_RESULT="${{ needs.comprehensive-testing.result }}"
SECURITY_RESULT="${{ needs.security-validation.result }}"
PERFORMANCE_RESULT="${{ needs.performance-validation.result }}"
COVERAGE_RESULT="${{ needs.coverage-validation.result }}"
echo "Quick Validation: $QUICK_RESULT"
echo "Build Validation: $BUILD_RESULT"
echo "Comprehensive Testing: $TESTING_RESULT"
echo "Security Validation: $SECURITY_RESULT"
echo "Performance Validation: $PERFORMANCE_RESULT"
echo "Coverage Validation: $COVERAGE_RESULT"
echo ""
# Determine overall status
if [ "$QUICK_RESULT" = "success" ] && \
[ "$BUILD_RESULT" = "success" ] && \
[ "$TESTING_RESULT" = "success" ] && \
[ "$SECURITY_RESULT" = "success" ] && \
[ "$PERFORMANCE_RESULT" = "success" ] && \
[ "$COVERAGE_RESULT" = "success" ]; then
echo "🎉 ALL VALIDATIONS PASSED"
echo "✅ Ready for promotion to main branch"
else
echo "❌ SOME VALIDATIONS FAILED"
echo "Please fix the issues before promotion"
exit 1
fi