Skip to content

Commit

Permalink
ci: fix codespeed benchmark again
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf0 committed Mar 10, 2024
1 parent 37badb5 commit ab733b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
run: cargo codspeed build -p bench

- name: Run the benchmarks
uses: CodSpeedHQ/action@v1
uses: CodSpeedHQ/action@v2
with:
run: cargo codspeed run -p bench
token: ${{ secrets.CODSPEED_TOKEN }}
16 changes: 14 additions & 2 deletions crates/bench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@ use std::path::PathBuf;
use rolldown::{Bundler, InputItem, InputOptions, OutputOptions};

pub fn repo_root() -> PathBuf {
let project_root = PathBuf::from(&std::env::var("CARGO_MANIFEST_DIR").unwrap());
project_root.parent().unwrap().parent().unwrap().to_path_buf()
let cargo_manifest_dir = std::env::var("CARGO_MANIFEST_DIR").map(PathBuf::from);
let project_root = if let Ok(cargo_manifest_dir) = cargo_manifest_dir {
cargo_manifest_dir.parent().unwrap().parent().unwrap().to_path_buf()
} else {
std::env::current_dir().expect("failed to get current dir")
};

assert_eq!(
project_root.file_name().unwrap(),
"rolldown",
"Benchmark must be run from the root of the repo, got wrong `project_root` {}",
project_root.display()
);
project_root
}

pub async fn run_fixture(fixture_path: PathBuf) {
Expand Down

0 comments on commit ab733b7

Please sign in to comment.