biome/.github/workflows/bench_cli.yml
renovate[bot] 99c9888e7e
chore(deps): update github-actions (#7431)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-08 10:54:05 +09:00

103 lines
3.8 KiB
YAML

# CLI benchmark, compares main and PR branch with Hyperfine.
# Comment with text containing `!bench_cli`, a new result will be commented at the bottom of this PR.
name: CLI Benchmark
on:
issue_comment:
types: [ created ]
env:
RUST_LOG: info
jobs:
bench:
permissions:
pull-requests: write
name: Bench
if: github.event.issue.pull_request && contains(github.event.comment.body, '!bench_cli')
runs-on: depot-ubuntu-24.04-arm-16
steps:
- name: Get PR SHA
id: sha
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
with:
result-encoding: string
script: |
const response = await github.request(context.payload.issue.pull_request.url);
return response.data.head.sha;
- name: Checkout PR Branch
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
ref: ${{ steps.sha.outputs.result }}
- name: Install toolchain
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
with:
channel: stable
bins: hyperfine
cache-target: release
cache-base: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Compile on PR Branch
run: |
cargo build --release --bin biome
mkdir -p benchmark/target
cp target/release/biome benchmark/target/biome_pr
- name: Checkout Main Branch
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
clean: false
ref: main
- name: Compile on Main Branch
run: |
cargo build --release --bin biome
cp target/release/biome benchmark/target/biome_main
- name: Checkout webpack
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
repository: webpack/webpack
path: benchmark/target/webpack
- name: Checkout prettier
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
repository: prettier/prettier
path: benchmark/target/prettier
- name: Checkout eslint
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
repository: eslint/eslint
path: benchmark/target/eslint
- name: Run Benchmarks
id: benchmarks
working-directory: benchmark/target
env:
FORMAT_BENCH_COMMAND: "format webpack/lib webpack/examples webpack/declarations webpack/benchmark prettier/src prettier/scripts --write"
CHECK_BENCH_COMMAND: "--max-diagnostics=0 eslint/lib eslint/messages eslint/tests/lib eslint/tests/performance eslint/tools webpack/lib --no-errors-on-unmatched"
run: |
hyperfine -w 2 --export-markdown benchmark_format.md \
-n "biome format (main)" "./biome_main $FORMAT_BENCH_COMMAND" \
-n "biome format (pr)" "./biome_pr $FORMAT_BENCH_COMMAND"
hyperfine -w 2 --export-markdown --ignore-failure benchmark_check.md \
-n "biome check (main)" "./biome_main check $CHECK_BENCH_COMMAND" \
-n "biome check (pr)" "./biome_pr check $CHECK_BENCH_COMMAND"
cat benchmark_format.md >> benchmark.md
echo $'\n' >> benchmark.md
cat benchmark_check.md >> benchmark.md
- 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@71345be0265236311c031f5c7866368bd1eff043 # v4
continue-on-error: true
with:
issue-number: ${{ github.event.issue.number }}
body-file: benchmark/target/benchmark.md