2022-10-03 20:11:20 +00:00
|
|
|
name: Benchmark
|
|
|
|
|
|
|
|
on:
|
|
|
|
issue_comment:
|
|
|
|
types: [created]
|
2023-03-01 14:02:35 +00:00
|
|
|
workflow_dispatch:
|
2022-10-03 20:11:20 +00:00
|
|
|
|
2022-10-03 20:29:56 +00:00
|
|
|
env:
|
|
|
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
|
|
|
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
|
|
|
FORCE_COLOR: true
|
|
|
|
|
2022-10-03 20:11:20 +00:00
|
|
|
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:
|
2023-03-01 08:46:06 +00:00
|
|
|
PR-BENCH: ${{ steps.benchmark-pr.outputs.BENCH_RESULT }}
|
|
|
|
MAIN-BENCH: ${{ steps.benchmark-main.outputs.BENCH_RESULT }}
|
2022-10-03 20:11:20 +00:00
|
|
|
steps:
|
2023-03-01 08:46:06 +00:00
|
|
|
# https://github.com/actions/checkout/issues/331#issuecomment-1438220926
|
2022-10-03 20:11:20 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
persist-credentials: false
|
2023-03-01 08:46:06 +00:00
|
|
|
ref: refs/pull/${{ github.event.issue.number }}/head
|
2022-10-03 20:11:20 +00:00
|
|
|
|
2022-10-28 18:36:50 +00:00
|
|
|
- name: Setup PNPM
|
2023-02-24 15:52:43 +00:00
|
|
|
uses: pnpm/action-setup@v2
|
2022-10-28 18:36:50 +00:00
|
|
|
|
|
|
|
- name: Setup Node
|
|
|
|
uses: actions/setup-node@v3
|
2022-10-03 20:11:20 +00:00
|
|
|
with:
|
2022-10-28 18:36:50 +00:00
|
|
|
node-version: ${{ matrix.node-version }}
|
2023-02-24 15:52:43 +00:00
|
|
|
cache: "pnpm"
|
2022-10-28 18:36:50 +00:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: pnpm install
|
2022-10-03 20:11:20 +00:00
|
|
|
|
2022-10-03 20:29:56 +00:00
|
|
|
- name: Build Packages
|
|
|
|
run: pnpm run build
|
|
|
|
|
2023-03-01 08:46:06 +00:00
|
|
|
- name: Get bench command
|
|
|
|
id: bench-command
|
|
|
|
run: |
|
|
|
|
benchcmd=$(echo "${{ github.event.comment.body }}" | grep '!bench' | awk -F ' ' '{print $2}')
|
|
|
|
echo "bench=$benchcmd" >> $GITHUB_OUTPUT
|
|
|
|
shell: bash
|
|
|
|
|
2022-10-03 20:11:20 +00:00
|
|
|
- name: Run benchmark
|
|
|
|
id: benchmark-pr
|
|
|
|
run: |
|
2023-03-01 08:46:06 +00:00
|
|
|
result=$(pnpm run --silent benchmark ${{ steps.bench-command.outputs.bench }})
|
|
|
|
processed=$(node ./benchmark/ci-helper.js "$result")
|
|
|
|
echo "BENCH_RESULT<<BENCHEOF" >> $GITHUB_OUTPUT
|
|
|
|
echo "### PR Benchmark" >> $GITHUB_OUTPUT
|
|
|
|
echo "$processed" >> $GITHUB_OUTPUT
|
|
|
|
echo "BENCHEOF" >> $GITHUB_OUTPUT
|
2022-12-06 15:19:51 +00:00
|
|
|
shell: bash
|
2022-10-03 20:11:20 +00:00
|
|
|
|
|
|
|
# main benchmark
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
persist-credentials: false
|
2023-02-24 15:52:43 +00:00
|
|
|
ref: "main"
|
2022-10-03 20:11:20 +00:00
|
|
|
|
|
|
|
- name: Install
|
|
|
|
run: |
|
|
|
|
pnpm install
|
|
|
|
|
2022-10-03 20:29:56 +00:00
|
|
|
- name: Build Packages
|
|
|
|
run: pnpm run build
|
|
|
|
|
2022-10-03 20:11:20 +00:00
|
|
|
- name: Run benchmark
|
|
|
|
id: benchmark-main
|
|
|
|
run: |
|
2023-03-01 08:46:06 +00:00
|
|
|
result=$(pnpm run --silent benchmark ${{ steps.bench-command.outputs.bench }})
|
|
|
|
processed=$(node ./benchmark/ci-helper.js "$result")
|
|
|
|
echo "BENCH_RESULT<<BENCHEOF" >> $GITHUB_OUTPUT
|
|
|
|
echo "### Main Benchmark" >> $GITHUB_OUTPUT
|
|
|
|
echo "$processed" >> $GITHUB_OUTPUT
|
|
|
|
echo "BENCHEOF" >> $GITHUB_OUTPUT
|
2022-12-06 15:19:51 +00:00
|
|
|
shell: bash
|
2022-10-03 20:11:20 +00:00
|
|
|
|
|
|
|
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
|
2023-03-02 16:10:56 +00:00
|
|
|
uses: peter-evans/create-or-update-comment@v2
|
|
|
|
continue-on-error: true
|
2022-10-03 20:11:20 +00:00
|
|
|
with:
|
2023-03-02 16:10:56 +00:00
|
|
|
issue-number: ${{ github.event.issue.number }}
|
2023-03-06 14:55:44 +00:00
|
|
|
body: |
|
2023-03-01 08:46:06 +00:00
|
|
|
${{ needs.benchmark.outputs.PR-BENCH }}
|
2023-01-06 17:01:54 +00:00
|
|
|
|
2023-03-01 08:46:06 +00:00
|
|
|
${{ needs.benchmark.outputs.MAIN-BENCH }}
|
2023-03-02 16:10:56 +00:00
|
|
|
edit-mode: replace
|