Skip to content

feat: initial release of htmltomd - fast HTML to Markdown converter #1

feat: initial release of htmltomd - fast HTML to Markdown converter

feat: initial release of htmltomd - fast HTML to Markdown converter #1

name: Performance Regression Check
on:
pull_request:
paths:
- 'src/**'
- 'package.json'
- 'pnpm-lock.yaml'
push:
branches:
- main
jobs:
performance-check:
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: pnpm build
- name: Checkout main branch baseline
if: github.event_name == 'pull_request'
run: |
git fetch origin main
git checkout origin/main -- bench/.baseline/performance-baseline.json || true
git checkout -
- name: Capture baseline (main branch only)
if: github.ref == 'refs/heads/main'
run: node bench/capture-baseline.js
- name: Check for regressions
if: github.event_name == 'pull_request'
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: github.event_name == 'pull_request' && always()
uses: actions/upload-artifact@v3
with:
name: regression-report
path: bench/.results/regression-report.md
- name: Comment PR with results
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
try {
const reportPath = path.join(process.env.GITHUB_WORKSPACE, 'bench', '.results', 'regression-report.md');
if (fs.existsSync(reportPath)) {
const report = fs.readFileSync(reportPath, 'utf8');
// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Performance Regression Report')
);
const body = `🤖 **Performance Check Results**\n\n${report}`;
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});
}
}
} catch (error) {
console.error('Failed to comment on PR:', error);
}
- name: Fail if regression detected
if: steps.regression-check.outputs.regression_detected == 'true'
run: |
echo "❌ Performance regression detected! See report above."
exit 1
- name: Commit baseline updates (main branch only)
if: github.ref == 'refs/heads/main'
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