0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00
astro/.github/workflows/benchmark.yml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

113 lines
3.3 KiB
YAML
Raw Permalink Normal View History

name: Benchmark
on:
issue_comment:
types: [created]
2023-03-01 09:02:35 -05:00
workflow_dispatch:
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
FORCE_COLOR: true
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: ${{ steps.benchmark-pr.outputs.BENCH_RESULT }}
MAIN-BENCH: ${{ steps.benchmark-main.outputs.BENCH_RESULT }}
steps:
- name: Check if user has write access
uses: lannonbr/repo-permission-check-action@2.0.2
with:
permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/actions/checkout/issues/331#issuecomment-1438220926
2024-02-09 01:35:00 -05:00
- uses: actions/checkout@v4
with:
persist-credentials: false
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Setup PNPM
uses: pnpm/action-setup@v3
- name: Setup Node
2024-02-09 01:35:00 -05:00
uses: actions/setup-node@v4
with:
2024-11-27 10:59:58 -05:00
node-version: 22
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Build Packages
run: pnpm run build
- name: Get bench command
id: bench-command
2023-07-05 23:37:28 -05:00
env:
# protects from untrusted user input and command injection
COMMENT: ${{ github.event.comment.body }}
run: |
2023-07-05 23:37:28 -05:00
benchcmd=$(echo "$COMMENT" | grep '!bench' | awk -F ' ' '{print $2}')
echo "bench=$benchcmd" >> $GITHUB_OUTPUT
shell: bash
- name: Run benchmark
id: benchmark-pr
run: |
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
shell: bash
# main benchmark
2024-02-09 01:35:00 -05:00
- uses: actions/checkout@v4
with:
persist-credentials: false
ref: "main"
- name: Install
run: |
pnpm install
- name: Build Packages
run: pnpm run build
- name: Run benchmark
id: benchmark-main
run: |
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
shell: bash
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
2024-02-09 01:35:00 -05:00
uses: peter-evans/create-or-update-comment@v4
continue-on-error: true
with:
issue-number: ${{ github.event.issue.number }}
2023-03-06 09:55:44 -05:00
body: |
${{ needs.benchmark.outputs.PR-BENCH }}
${{ needs.benchmark.outputs.MAIN-BENCH }}
edit-mode: replace