Skip to content

Merge pull request #343 from cesco69/patch-7 #583

Merge pull request #343 from cesco69/patch-7

Merge pull request #343 from cesco69/patch-7 #583

Workflow file for this run

name: Benchmark Express Performance
on:
push:
branches: [ "main" ]
pull_request:
branches:
- main
permissions: write-all
jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache Node.js dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Install dependencies
run: npm install --include=dev
- name: Install wrk
run: |
sudo apt-get update
sudo apt-get install -y wrk
- name: Run benchmark suite
run: npm run benchmark:compare -- --duration 20 --output benchmark_summary.md
- name: Upload benchmark markdown artifact
uses: actions/upload-artifact@v4
with:
name: benchmark-summary
path: benchmark_summary.md
- name: Comment on commit
if: github.event_name == 'push'
continue-on-error: true
uses: peter-evans/commit-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body-path: benchmark_summary.md
- name: Comment on pull request
if: github.event_name == 'pull_request'
continue-on-error: true
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const marker = '<!-- benchmark-comment -->';
const body = fs.readFileSync('benchmark_summary.md', 'utf8');
const issue_number = context.payload.pull_request.number;
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number
});
const existing = comments.find((comment) =>
comment.user && comment.user.type === 'Bot' && comment.body && comment.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,
body
});
}