name: Performance Benchmarks on: push: branches: [main, develop] pull_request: branches: [main, develop] schedule: # Run daily at 2 AM UTC - cron: '0 2 * * *' workflow_dispatch: jobs: benchmark: runs-on: ubuntu-latest timeout-minutes: 30 strategy: matrix: node-version: [18.x, 20.x] 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 working-directory: packages/agentic-synth - name: Build project run: npm run build working-directory: packages/agentic-synth - name: Run benchmarks run: npm run benchmark:ci working-directory: packages/agentic-synth env: GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} NODE_OPTIONS: '--max-old-space-size=4096' continue-on-error: true - name: Upload performance report uses: actions/upload-artifact@v4 if: always() with: name: performance-report-node-${{ matrix.node-version }} path: packages/agentic-synth/benchmarks/performance-report.md retention-days: 30 - name: Upload performance data uses: actions/upload-artifact@v4 if: always() with: name: performance-data-node-${{ matrix.node-version }} path: packages/agentic-synth/benchmarks/performance-data.json retention-days: 90 - name: Comment PR with results if: github.event_name == 'pull_request' uses: actions/github-script@v7 with: script: | const fs = require('fs'); const reportPath = 'packages/agentic-synth/benchmarks/performance-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: `## Performance Benchmark Results (Node ${{ matrix.node-version }})\n\n${report}` }); } - name: Check for regressions run: | if [ -f "benchmarks/performance-data.json" ]; then node scripts/check-regressions.js fi working-directory: packages/agentic-synth compare: runs-on: ubuntu-latest needs: benchmark if: github.event_name == 'pull_request' steps: - name: Checkout code uses: actions/checkout@v4 - name: Download artifacts uses: actions/download-artifact@v4 with: pattern: performance-data-* path: benchmarks/ - name: Compare performance run: | echo "Comparing performance across Node versions..." # Add comparison script here ls -la benchmarks/ notify: runs-on: ubuntu-latest needs: benchmark if: failure() && github.ref == 'refs/heads/main' steps: - name: Notify on regression uses: actions/github-script@v7 with: script: | github.rest.issues.create({ owner: context.repo.owner, repo: context.repo.repo, title: '⚠️ Performance Regression Detected', body: `Performance benchmarks failed on main branch.\n\nWorkflow: ${context.workflow}\nRun: ${context.runId}`, labels: ['performance', 'regression'] });