Merge pull request #103 from benbernard/feature/comparison-gap-fixes #54
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: CI | |
| on: | |
| push: | |
| branches: [master, ts-port] | |
| pull_request: | |
| branches: [master] | |
| jobs: | |
| ci: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Lint | |
| run: bun run lint | |
| - name: Type check | |
| run: bun run typecheck | |
| - name: Test | |
| run: bun test | |
| - name: Check documentation | |
| run: bun run check-docs | |
| benchmarks: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Restore baseline from master | |
| id: restore-baseline | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: perf-baseline.json | |
| key: perf-baseline- | |
| - name: Run benchmarks | |
| id: bench | |
| continue-on-error: true | |
| run: | | |
| BENCH_ARGS="--ci --markdown-file benchmark-report.md --json-file benchmark-results.json" | |
| if [ -f perf-baseline.json ]; then | |
| BENCH_ARGS="$BENCH_ARGS --baseline-file perf-baseline.json --fail-threshold 25" | |
| fi | |
| bun run bench -- $BENCH_ARGS | |
| - name: Post PR comment | |
| if: always() && github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const reportPath = 'benchmark-report.md'; | |
| if (!fs.existsSync(reportPath)) { | |
| console.log('No benchmark report found, skipping comment.'); | |
| return; | |
| } | |
| const body = fs.readFileSync(reportPath, 'utf-8').trim(); | |
| if (!body) return; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const marker = '## Performance Benchmark Results'; | |
| const existing = comments.find(c => | |
| c.user?.type === 'Bot' && c.body?.includes(marker) | |
| ); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); | |
| } | |
| - name: Upload benchmark results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results | |
| path: | | |
| benchmark-results.json | |
| benchmark-report.md | |
| retention-days: 30 | |
| update-baseline: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Run benchmarks and save baseline | |
| run: bun run bench -- --save-baseline --baseline-file perf-baseline.json | |
| - name: Save baseline to cache | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: perf-baseline.json | |
| key: perf-baseline-${{ github.sha }} |