oxc/.github/workflows/benchmark.yaml
2023-03-05 04:51:00 -08:00

97 lines
2.7 KiB
YAML

name: Benchmark
on:
pull_request:
paths:
- 'crates/oxc_parser/**'
- 'crates/oxc_ast/**'
- 'crates/oxc_semantic/**'
- 'tasks/benchmark/**'
- 'rust-toolchain.toml'
- '!**/*.md'
# cancel previous job runs for the same workflow + pr
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_QUIET: true
jobs:
benchmark:
name: Run benchmark
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install toolchain
run: rustup show
- name: Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: benchmark
- name: Install critcmp
run: cargo install critcmp
- name: Compile
run: cargo build --release -p oxc_benchmark
- name: Run Bench on PR Branch
run: cargo benchmark --save-baseline pr
- name: Checkout Main Branch
uses: actions/checkout@v3
with:
clean: false
ref: main
- name: Compile
run: cargo build --release -p oxc_benchmark
- name: Run Bench on Main Branch
run: cargo benchmark --save-baseline main
- name: Compare Bench Results
id: bench_comparison
shell: bash
run: |
echo "### Parser Benchmark Results - ${{ matrix.os }}" > output.md
echo "\`\`\`" >> output.md
critcmp main pr >> output.md
echo "\`\`\`" >> output.md
cat output.md
cat output.md > $GITHUB_STEP_SUMMARY
- name: Find Comment
# Check if the event is not triggered by a fork
if: github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Parser Benchmark Results - ${{ matrix.os }}
- name: Write a new comment
# Check if the event is not triggered by a fork
if: github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
comment-id: ${{ steps.fc.outputs.comment-id }}
body-file: 'output.md'
- name: Remove Criterion Artifact
uses: JesseTG/rm@v1.0.3
with:
path: ./target/criterion