Skip to content

chore: CR for #1103 #886

chore: CR for #1103

chore: CR for #1103 #886

Workflow file for this run

name: Benchmarks Rust
on:
push:
branches:
- 'main' # or "master"
paths:
- '**/*.rs'
- '**/*.toml'
- '.github/workflows/**'
- 'Cargo.lock'
- 'rust-toolchain.toml'
pull_request:
types: [opened, synchronize]
paths:
- '**/*.rs'
- '**/*.toml'
- '.github/workflows/**'
- 'Cargo.lock'
- 'rust-toolchain.toml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
codspeed-benchmark:
name: Codspeed Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout Branch
uses: actions/checkout@v4
with:
# Whether Pull submodules for additional files
submodules: false
- name: Install Rust
uses: moonrepo/setup-rust@v1
with:
bins: just, cargo-codspeed
cache-base: main
cache-target: release
- name: Install pnpm
uses: pnpm/action-setup@v3
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Setup benchmark
run: just setup-bench
- name: Build the benchmark target(s)
run: cargo codspeed build -p bench --features codspeed
- name: Run the benchmarks
uses: CodSpeedHQ/action@v2
with:
run: cargo codspeed run -p bench
token: ${{ secrets.CODSPEED_TOKEN }}
env:
# ensure that `root_dir()` from `crates/rolldown_testing/src/workspace.rs` works during the benchmark
# see https://github.com/adriencaccia/rolldown/pull/1 for explanation
CARGO_MANIFEST_DIR: ${{ github.workspace }}/target/codspeed
benchmark-rust:
name: Benchmark Rust
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout PR Branch
uses: actions/checkout@v4
with:
# Whether Pull submodules for additional files
submodules: false
- name: Install Rust
uses: moonrepo/setup-rust@v1
with:
bins: just, critcmp
cache-base: main
cache-target: release
- name: Install pnpm
uses: pnpm/action-setup@v3
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Setup benchmark
run: just setup-bench
- name: Run Bench on PR Branch
run: cargo bench -p bench -- --save-baseline pr
- name: Checkout Target Branch
uses: actions/checkout@v4
with:
clean: false
ref: ${{ github.event.pull_request.base.ref }}
- name: Run Bench on Target Branch
run: cargo bench -p bench -- --save-baseline target
- name: Compare Bench Results
id: bench_comparison
shell: bash
run: |
echo "### Benchmarks Rust" > output
echo "- target: \`${{ github.event.pull_request.base.ref }}\`(${{ github.event.pull_request.base.sha }})" >> output
echo "- pr: \`${{ github.event.pull_request.head.ref }}\`(${{ github.event.pull_request.head.sha }})" >> output
echo "\`\`\`" >> output
critcmp target pr >> output
echo "\`\`\`" >> output
cat output
comment="$(cat output)"
comment="${comment//'%'/%25}"
comment="${comment//$'\n'/%0A}"
comment="${comment//$'\r'/%0D}"
echo "::set-output name=comment::$comment"
- name: Find Comment
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Benchmarks Rust
- name: Write a new comment
uses: peter-evans/create-or-update-comment@v4.0.0
continue-on-error: true
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.bench_comparison.outputs.comment }}
reactions-edit-mode: 'replace'