feat(bench): simplify suites and enrich comparison metadata #21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Performance Regression Check | |
| on: | |
| pull_request: | |
| paths: | |
| - 'src/**' | |
| - 'package.json' | |
| - 'pnpm-lock.yaml' | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| jobs: | |
| regression: | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| issues: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | |
| with: | |
| run_install: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 | |
| with: | |
| node-version: '24' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build project | |
| run: pnpm build | |
| - name: Restore main baseline | |
| run: | | |
| git fetch origin main --depth=1 | |
| git checkout origin/main -- bench/.baseline/performance-baseline.json || true | |
| - name: Check for regressions | |
| id: regression-check | |
| run: | | |
| if node bench/check-regression.js; then | |
| echo "regression_detected=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "regression_detected=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Upload regression report | |
| if: always() | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: regression-report | |
| path: bench/.results/regression-report.md | |
| if-no-files-found: ignore | |
| - name: Comment PR with results | |
| if: always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const reportPath = path.join(process.env.GITHUB_WORKSPACE, 'bench', '.results', 'regression-report.md'); | |
| if (!fs.existsSync(reportPath)) { | |
| return; | |
| } | |
| const report = fs.readFileSync(reportPath, 'utf8'); | |
| const body = `🤖 **Performance Check Results** | |
| ${report}`; | |
| const response = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const comments = response.data; | |
| const botComment = comments.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body.includes('Performance Check Results') | |
| ); | |
| if (botComment) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); | |
| } | |
| - name: Fail if regression detected | |
| if: steps.regression-check.outputs.regression_detected == 'true' | |
| run: | | |
| echo "❌ Performance regression detected! See report above." | |
| exit 1 | |
| update-baseline: | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | |
| with: | |
| run_install: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 | |
| with: | |
| node-version: '24' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build project | |
| run: pnpm build | |
| - name: Capture baseline | |
| run: node bench/capture-baseline.js | |
| - name: Commit baseline updates | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add bench/.baseline/performance-baseline.json | |
| git diff --staged --quiet || git commit -m "chore: update performance baseline [skip ci]" | |
| git push || true |