Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: benchmark #153

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Benchmark
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
benchmark:
name: Performance regression check
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Download previous benchmark data
uses: actions/cache@v4
with:
path: ./cache
key: benchmark
- name: Build
run: |
pnpm install
cd packages/node
pnpm build
- name: Benchmark result
id: benchmark-result
run: |
if [ -f ./cache/benchmark-main.json ]; then
pnpm run bench --run --outputJson benchmark.json --compare ./cache/benchmark-main.json > benchmark.txt
else
pnpm run bench --run --outputJson benchmark.json > benchmark-tmp.txt
fi
iconv -f "windows-1252" -t "UTF-8" benchmark-tmp.txt -o benchmark.txt
echo 'BENCHMARK_RESULT<<EOF' >> $GITHUB_OUTPUT
sed -i -e '$a\' benchmark.txt
cat benchmark.txt >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
cat benchmark.txt >> $GITHUB_STEP_SUMMARY
- uses: actions/github-script@v6
env:
BENCHMARK_RESULT: ${{ steps.benchmark-result.outputs.BENCHMARK_RESULT }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.BENCHMARK_RESULT
})
- run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: branch
- name: Store benchmark dataq
if: steps.branch.outputs.branch == 'main'
run: cp benchmark.json ./cache/benchmark-main.json
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"docs": "typedoc",
"proto-gen": "buf generate",
"release": "release-it",
"test": "vitest",
"test": "vitest run",
"bench": "vitest bench"
},
"devDependencies": {
Expand Down
Loading