Skip to content

fix(x-markdown): enhance custom in-tag line break protection and hand… #132

fix(x-markdown): enhance custom in-tag line break protection and hand…

fix(x-markdown): enhance custom in-tag line break protection and hand… #132

name: Markdown Performance
on:
pull_request:
paths:
- 'packages/x-markdown/**'
push:
paths:
- 'packages/x-markdown/**'
workflow_dispatch:
permissions:
contents: read
pull-requests: write
checks: write
jobs:
benchmark:
name: Performance BenchMark
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Setup Playwright
run: |
cd packages/x-markdown
npx playwright install --with-deps chromium
- name: Run x-markdown benchmark
id: benchmark
run: |
cd packages/x-markdown
npm run benchmark
- name: Check performance against thresholds
id: check
run: |
cd packages/x-markdown
node src/XMarkdown/__benchmark__/scripts/check-performance.js \
test-results/benchmark-results.json \
benchmark-check-report.txt
- name: Comment PR with results
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = 'packages/x-markdown/src/XMarkdown/__benchmark__/benchmark-check-report.txt';
let report = '⚠️ Performance benchmark report not found.';
if (fs.existsSync(path)) {
report = fs.readFileSync(path, 'utf8');
}
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('📊 x-markdown Performance Report')
);
const commentBody = report + '\n\n---\n*This comment is automatically generated by the x-markdown performance CI.*';
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
}