Run benchmarks on comment (#4960)
* Run benchmarks on !bench command * Re-enable main
This commit is contained in:
parent
bb022f5230
commit
f93625eafe
2 changed files with 85 additions and 1 deletions
84
.github/workflows/benchmark.yml
vendored
Normal file
84
.github/workflows/benchmark.yml
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
name: Benchmark
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
benchmark:
|
||||
if: ${{ github.repository_owner == 'withastro' && github.event.issue.pull_request && startsWith(github.event.comment.body, '!bench') }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
outputs:
|
||||
PR-BENCH-14: ${{ steps.benchmark-pr.outputs.BENCH_RESULT14 }}
|
||||
PR-BENCH-16: ${{ steps.benchmark-pr.outputs.BENCH_RESULT16 }}
|
||||
MAIN-BENCH-14: ${{ steps.benchmark-main.outputs.BENCH_RESULT14 }}
|
||||
MAIN-BENCH-16: ${{ steps.benchmark-main.outputs.BENCH_RESULT16 }}
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [14, 16]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
ref: ${{github.event.pull_request.head.sha}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
|
||||
- name: Setup PNPM
|
||||
uses: pnpm/action-setup@v2.2.1
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Run benchmark
|
||||
id: benchmark-pr
|
||||
run: |
|
||||
pnpm run --silent benchmark > ./bench-result.md
|
||||
result=$(awk '/requests in/' ./bench-result.md)
|
||||
echo "::set-output name=BENCH_RESULT${{matrix.node-version}}::$result"
|
||||
|
||||
# main benchmark
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
ref: 'main'
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
pnpm install
|
||||
|
||||
- name: Run benchmark
|
||||
id: benchmark-main
|
||||
run: |
|
||||
pnpm run --silent benchmark > ./bench-result.md
|
||||
result=$(awk '/requests in/' ./bench-result.md)
|
||||
echo "::set-output name=BENCH_RESULT${{matrix.node-version}}::$result"
|
||||
|
||||
output-benchmark:
|
||||
if: ${{ github.repository_owner == 'withastro' && github.event.issue.pull_request && startsWith(github.event.comment.body, '!bench') }}
|
||||
needs: [benchmark]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Comment PR
|
||||
uses: thollander/actions-comment-pull-request@v1
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
message: |
|
||||
**Node**: 14
|
||||
**PR**: ${{ needs.benchmark.outputs.PR-BENCH-14 }}
|
||||
**MAIN**: ${{ needs.benchmark.outputs.MAIN-BENCH-14 }}
|
||||
|
||||
---
|
||||
|
||||
**Node**: 16
|
||||
**PR**: ${{ needs.benchmark.outputs.PR-BENCH-16 }}
|
||||
**MAIN**: ${{ needs.benchmark.outputs.MAIN-BENCH-16 }}
|
|
@ -22,7 +22,7 @@
|
|||
"test:vite-ci": "turbo run test --filter=astro --output-logs=new-only --no-deps --concurrency=1",
|
||||
"test:e2e": "cd packages/astro && pnpm playwright install && pnpm run test:e2e",
|
||||
"test:e2e:match": "cd packages/astro && pnpm playwright install && pnpm run test:e2e:match",
|
||||
"benchmark": "turbo run benchmark --filter=astro",
|
||||
"benchmark": "pnpm --filter @benchmark/simple run build && pnpm dlx concurrently -k -s first \"node packages/astro/test/benchmark/simple/server.mjs\" \"pnpm dlx autocannon -c 100 -d 30 -p 10 localhost:3002/\"",
|
||||
"lint": "eslint .",
|
||||
"version": "changeset version && pnpm install --no-frozen-lockfile && pnpm run format"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue