Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
140 lines
4.4 KiB
YAML
140 lines
4.4 KiB
YAML
name: Pacquet Micro-Benchmark
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
types: [opened, synchronize]
|
|
paths:
|
|
- 'pnpm/**/*.rs'
|
|
- 'pnpm/**/Cargo.toml'
|
|
- 'Cargo.toml'
|
|
- 'Cargo.lock'
|
|
- 'rust-toolchain.toml'
|
|
- 'pnpm/tasks/micro-benchmark/fixtures/**'
|
|
- '.github/actions/rustup/**'
|
|
- '.github/actions/binstall/**'
|
|
- '.github/actions/install-crates/**'
|
|
- '.github/workflows/pacquet-micro-benchmark.yml'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
benchmark:
|
|
strategy:
|
|
matrix:
|
|
os: [blacksmith-8vcpu-ubuntu-2404] # macOS is too unstable to be useful for benchmark, the variance is always huge.
|
|
name: Run benchmark on ${{ matrix.os }}
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: Checkout Main Branch
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
ref: main # Checkout main first because the cache is warm
|
|
persist-credentials: false
|
|
|
|
- name: Install Rust Toolchain
|
|
uses: $/.github/actions/rustup
|
|
with:
|
|
shared-key: micro-benchmark
|
|
|
|
# Once per checkout: the two revisions can pin different crates, and the
|
|
# second checkout leaves the first one's `.pnpm/crates` in place.
|
|
- name: Install crates
|
|
uses: $/.github/actions/install-crates
|
|
|
|
- name: Compile
|
|
run: cargo build --release --bin=micro-benchmark
|
|
|
|
- name: Sleep for CPU cooldown
|
|
shell: bash
|
|
run: sleep 15s
|
|
|
|
- name: Run Bench on Main Branch
|
|
run: cargo run --bin=micro-benchmark --release -- --save-baseline main
|
|
|
|
- name: Checkout PR Branch
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
clean: false
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
persist-credentials: false
|
|
|
|
- name: Install crates
|
|
uses: $/.github/actions/install-crates
|
|
|
|
- name: Compile
|
|
run: cargo build --release --bin=micro-benchmark
|
|
|
|
- name: Sleep for CPU cooldown
|
|
shell: bash
|
|
run: sleep 15s
|
|
|
|
- name: Run Bench on PR Branch
|
|
run: cargo run --bin=micro-benchmark --release -- --save-baseline pr
|
|
|
|
- name: Upload benchmark results
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
with:
|
|
name: benchmark-results-ubuntu-latest
|
|
path: ./target/criterion
|
|
|
|
benchmark-compare:
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
name: Compare Benchmarks
|
|
needs:
|
|
- benchmark
|
|
permissions:
|
|
contents: read
|
|
issues: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Install critcmp
|
|
uses: taiki-e/install-action@a4d3f3f761dcd95cce1b72cb61cb6d1963438177 # v2.87.30
|
|
with:
|
|
tool: critcmp
|
|
|
|
- name: Linux | Download PR benchmark results
|
|
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
with:
|
|
name: benchmark-results-ubuntu-latest
|
|
path: ./target/criterion
|
|
|
|
- name: Linux | Compare benchmark results
|
|
shell: bash
|
|
run: |
|
|
echo "## Micro-Benchmark Results" >> summary.md
|
|
echo "### Linux" >> summary.md
|
|
echo "\`\`\`" >> summary.md
|
|
critcmp main pr >> summary.md
|
|
echo "\`\`\`" >> summary.md
|
|
echo "" >> summary.md
|
|
|
|
- name: Linux | Cleanup benchmark results
|
|
run: rm -rf ./target/criterion
|
|
|
|
- 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@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0
|
|
id: fc
|
|
with:
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
comment-author: 'github-actions[bot]'
|
|
body-includes: Micro-Benchmark Results
|
|
|
|
- name: Create or update 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@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
|
|
with:
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
edit-mode: replace
|
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
body-file: summary.md
|