Skip to content

feat(build)!: migrate to Bun and add standalone binary compilation #35

feat(build)!: migrate to Bun and add standalone binary compilation

feat(build)!: migrate to Bun and add standalone binary compilation #35

name: Performance Regression Check
concurrency:
group: performance-regression-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
pull_request:
paths:
- 'src/**'
- 'package.json'
- 'bun.lock'
push:
branches:
- main
permissions:
contents: read
jobs:
regression:
if: github.event_name == 'pull_request' && contains(join(github.event.pull_request.labels.*.name, ','), 'test-regression')
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
lfs: true
- name: Setup Bun
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build project
run: bun 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
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
lfs: true
- name: Setup Bun
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build project
run: bun 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