Skip to content

Commit

Permalink
chore(ci): Speed up benchmark action by sharding (#10152)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #10148
  • Loading branch information
kdy1 authored Mar 6, 2025
1 parent b993f86 commit b76410d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 45 deletions.
47 changes: 3 additions & 44 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
id: list-crates
run: echo "crates=$(./scripts/bench/list-crates-with-bench.sh)" >> $GITHUB_OUTPUT

build-crate:
name: Build benchmark for ${{ matrix.crate }}
benchmark-crate:
name: Benchmark ${{ matrix.crate }}
runs-on: ubuntu-22.04
needs: list-crates
strategy:
Expand All @@ -64,52 +64,11 @@ jobs:
- name: Install cargo-codspeed
uses: taiki-e/install-action@v2
with:
tool: cargo-codspeed@2.7.2
tool: cargo-codspeed@2.8.1

- name: Build the benchmark target(s)
run: ./scripts/bench/build-crate.sh ${{ matrix.crate }}

- name: Upload built artifacts
uses: actions/upload-artifact@v4
with:
name: bench-${{ matrix.crate }}
path: target/codspeed

bench-all:
name: Run benchmarks
needs: build-crate
runs-on:
- self-hosted
- linux
- x64
if: >-
${{ !contains(github.event.head_commit.message, 'chore: ') }}
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal

- name: Install cargo-codspeed
uses: taiki-e/install-action@v2
with:
tool: cargo-codspeed@2.7.2

- run: mkdir -p target/codspeed

- name: Download built artifacts
uses: actions/download-artifact@v4
with:
pattern: bench-*
path: target/codspeed
merge-multiple: true

- run: ls -alR target/codspeed

- run: chmod -R +x target/codspeed/*

- name: Run the benchmarks
uses: CodSpeedHQ/action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion scripts/bench/list-crates-with-bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -eu

WS_CRATES=$(./scripts/cargo/get-workspace-crates-json.sh)
echo "$WS_CRATES" | jq -r -c '[.[] | select(.targets[] | .kind | contains(["bench"])) | .name] | sort | unique' | jq -r -c '[.[] | select(. != "swc_plugin_runner" and . != "swc_allocator")]'
echo "$WS_CRATES" | jq -r -c '[.[] | select(.targets[] | .kind | contains(["bench"])) | .name] | sort | unique' | jq -r -c '[.[] | select(. != "swc_plugin_runner" and . != "swc_allocator" and . != "swc")]'

0 comments on commit b76410d

Please sign in to comment.