From 83414b085e75b58e3bd0298d7f7c0fcd916206d2 Mon Sep 17 00:00:00 2001 From: not-matthias Date: Fri, 3 Oct 2025 15:50:36 +0200 Subject: [PATCH 1/5] feat(ci): add check to ensure compilation on all platforms --- .github/workflows/ci.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65a4d9fa..3def91da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,18 +19,21 @@ jobs: with: extra_args: --all-files - lint-windows: - runs-on: windows-latest + test-codspeed: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: submodules: true - uses: moonrepo/setup-rust@v1 with: - components: rustfmt, clippy - - uses: pre-commit/action@v3.0.1 - with: - extra_args: --all-files + cache-target: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - run: cargo test -p codspeed msrv-check: runs-on: ubuntu-latest @@ -150,7 +153,7 @@ jobs: if: always() needs: - lint - - lint-windows + - test-codspeed - msrv-check - tests - compat-integration-test-instrumentation From b95dc4ef380420171097dd6842ecaec2d75bc913 Mon Sep 17 00:00:00 2001 From: not-matthias Date: Fri, 3 Oct 2025 16:43:57 +0200 Subject: [PATCH 2/5] fix(ci): use GITHUB_TOKEN to prevent MacOS timeouts See: https://github.com/moonrepo/setup-rust/issues/22 --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3def91da..88d64053 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,8 @@ jobs: - uses: moonrepo/setup-rust@v1 with: components: rustfmt, clippy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: pre-commit/action@v3.0.1 with: extra_args: --all-files @@ -44,6 +46,8 @@ jobs: - uses: moonrepo/setup-rust@v1 with: bins: cargo-msrv + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check cospeed MSRV run: cargo msrv --path crates/codspeed verify -- cargo check --all-features --config codspeed=true - name: Check bencher_compat MSRV @@ -60,6 +64,8 @@ jobs: with: submodules: true - uses: moonrepo/setup-rust@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: cargo test --all compat-integration-test-instrumentation: @@ -79,6 +85,8 @@ jobs: - uses: moonrepo/setup-rust@v1 with: cache-target: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: cargo install --path crates/cargo-codspeed --locked @@ -108,6 +116,8 @@ jobs: - uses: moonrepo/setup-rust@v1 with: cache-target: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: cargo install --path crates/cargo-codspeed --locked @@ -142,6 +152,8 @@ jobs: - uses: moonrepo/setup-rust@v1 with: targets: ${{ matrix.target }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install musl tools run: sudo apt-get update && sudo apt-get install -y musl-tools From eb5bf4720306594ab46328fb4d177901cc28e2e3 Mon Sep 17 00:00:00 2001 From: not-matthias Date: Fri, 3 Oct 2025 16:53:59 +0200 Subject: [PATCH 3/5] chore(codspeed): add test to force build --- crates/codspeed/src/instrument_hooks/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/codspeed/src/instrument_hooks/mod.rs b/crates/codspeed/src/instrument_hooks/mod.rs index 12ae6164..16e24801 100644 --- a/crates/codspeed/src/instrument_hooks/mod.rs +++ b/crates/codspeed/src/instrument_hooks/mod.rs @@ -174,3 +174,20 @@ pub use unix_impl::InstrumentHooks; #[cfg(not(unix))] pub use other_impl::InstrumentHooks; + +#[cfg(test)] +mod tests { + use super::InstrumentHooks; + + #[test] + fn test_instrument_hooks() { + let hooks = InstrumentHooks::instance(); + assert!(!hooks.is_instrumented() || hooks.start_benchmark().is_ok()); + assert!(hooks.set_executed_benchmark("test_uri").is_ok()); + assert!(hooks.set_integration("test_integration", "1.0.0").is_ok()); + let start = InstrumentHooks::current_timestamp(); + let end = start + 1_000_000; // Simulate 1ms later + hooks.add_benchmark_timestamps(start, end); + assert!(!hooks.is_instrumented() || hooks.stop_benchmark().is_ok()); + } +} From 9a49543bdb67377cf49e1346338e3f8579f676ed Mon Sep 17 00:00:00 2001 From: not-matthias Date: Fri, 3 Oct 2025 16:01:01 +0200 Subject: [PATCH 4/5] fix: use latest instrument-hooks --- crates/codspeed/instrument-hooks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/codspeed/instrument-hooks b/crates/codspeed/instrument-hooks index 0d3de57f..b3d4b78e 160000 --- a/crates/codspeed/instrument-hooks +++ b/crates/codspeed/instrument-hooks @@ -1 +1 @@ -Subproject commit 0d3de57fe46ef97714a41ed028096f6f84fdbd2a +Subproject commit b3d4b78ef68498d59afd45a9c8b2ef096652f034 From 9ace864cb12357412f59dba26c268764d3fac5c8 Mon Sep 17 00:00:00 2001 From: not-matthias Date: Fri, 3 Oct 2025 16:06:57 +0200 Subject: [PATCH 5/5] fix(codspeed): use target_os cfg --- crates/codspeed/build.rs | 5 +++++ crates/codspeed/src/instrument_hooks/mod.rs | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/codspeed/build.rs b/crates/codspeed/build.rs index 3eef6527..22f58401 100644 --- a/crates/codspeed/build.rs +++ b/crates/codspeed/build.rs @@ -1,6 +1,11 @@ use std::{env, path::PathBuf}; fn main() { + if cfg!(not(target_os = "linux")) { + // The instrument-hooks library is only supported on Linux. + return; + } + // Compile the C library cc::Build::new() .file("instrument-hooks/dist/core.c") diff --git a/crates/codspeed/src/instrument_hooks/mod.rs b/crates/codspeed/src/instrument_hooks/mod.rs index 16e24801..ef4e08c1 100644 --- a/crates/codspeed/src/instrument_hooks/mod.rs +++ b/crates/codspeed/src/instrument_hooks/mod.rs @@ -1,8 +1,8 @@ -#[cfg(unix)] +#[cfg(target_os = "linux")] mod ffi; -#[cfg(unix)] -mod unix_impl { +#[cfg(target_os = "linux")] +mod linux_impl { use nix::sys::time::TimeValLike; use super::ffi; @@ -131,7 +131,7 @@ mod unix_impl { } } -#[cfg(not(unix))] +#[cfg(not(target_os = "linux"))] mod other_impl { pub struct InstrumentHooks; @@ -169,10 +169,10 @@ mod other_impl { } } -#[cfg(unix)] -pub use unix_impl::InstrumentHooks; +#[cfg(target_os = "linux")] +pub use linux_impl::InstrumentHooks; -#[cfg(not(unix))] +#[cfg(not(target_os = "linux"))] pub use other_impl::InstrumentHooks; #[cfg(test)]