Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ concurrency:
# Cancel in progress runs if a new one is queued everywhere but on pushes and workflow dispatch events
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}

env:
# Fail instead of building valgrind from source on systems we publish no package for
CODSPEED_VALGRIND_BUILD_FROM_SOURCE: "false"

jobs:
lint:
runs-on: ${{ matrix.os }}
Expand All @@ -32,7 +36,7 @@ jobs:
run: cargo run --bin generate_config_schema && git diff --exit-code schemas/codspeed.schema.json

tests:
runs-on: ubuntu-latest
runs-on: ubuntu-26.04
Comment thread
greptile-apps[bot] marked this conversation as resolved.
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
Expand All @@ -46,7 +50,17 @@ jobs:
- run: cargo test --all --exclude memtrack --exclude exec-harness

executor-tests:
runs-on: ubuntu-latest
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
arch: [x86_64, arm64]
base-image: ["ubuntu:24.04", "ubuntu:26.04"]
include:
- arch: x86_64
runner: ubuntu-26.04
- arch: arm64
runner: ubuntu-26.04-arm
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
Expand All @@ -56,9 +70,10 @@ jobs:
tool: just
# No cache for now here, but we could cache either docker volumes or mounted host directories to cache build artifacts
- run: just test-integ
# Runs against an unreleased valgrind-codspeed branch, tag or full commit SHA
# env:
# CODSPEED_VALGRIND_REF: my-valgrind-branch
env:
CODSPEED_TEST_BASE_IMAGE: ${{ matrix.base-image }}
# Runs against an unreleased valgrind-codspeed branch, tag or full commit SHA
# CODSPEED_VALGRIND_REF: my-valgrind-branch

exec-harness-tests:
runs-on: ubuntu-latest
Expand All @@ -71,14 +86,24 @@ jobs:
run: cargo test -p exec-harness

basic-run-test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
extra-args: --skip-upload
- os: ubuntu-26.04
extra-args: ""
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
cache-key: ${{ matrix.os }}
- name: Run tests
run: cargo run -- exec -m simulation,walltime,memory --warmup-time 0s --max-rounds 5 -- sleep 1
run: cargo run -- exec ${{ matrix.extra-args }} -m simulation,walltime,memory --warmup-time 0s --max-rounds 5 -- sleep 1

macos-basic-run-test:
runs-on: macos-latest
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ This ensures only stable runner releases are marked as "latest" in GitHub.
## Testing

- Some tests require `sudo` access. They are skipped by default unless the `GITHUB_ACTIONS` env var is set.
- The executor tests in `tests/executors.rs` install tools, `setcap` memtrack and load eBPF/perf, so they only build with the `executor-tests` feature. Run them in containers with `just test-integ [filter]` (needs Docker and [just](https://github.com/casey/just)), or on a host with passwordless sudo with `cargo test --features executor-tests --test executors`. To run them against an unreleased valgrind-codspeed, set `CODSPEED_VALGRIND_REF` to one of its branches, tags or full commit SHAs: `CODSPEED_VALGRIND_REF=<ref> just test-integ`.
- The executor tests in `tests/executors.rs` install tools, `setcap` memtrack and load eBPF/perf, so they only build with the `executor-tests` feature. Run them in containers with `just test-integ [filter]` (needs Docker and [just](https://github.com/casey/just)), or on a host with passwordless sudo with `cargo test --features executor-tests --test executors`. To run them against an unreleased valgrind-codspeed, set `CODSPEED_VALGRIND_REF` to one of its branches, tags or full commit SHAs: `CODSPEED_VALGRIND_REF=<ref> just test-integ`. To run them against a valgrind-codspeed package, e.g. one built with `just docker-deb <ubuntu version>` in valgrind-codspeed, set `CODSPEED_VALGRIND_DEB` to its path. They run on Ubuntu 24.04 by default; set `CODSPEED_TEST_BASE_IMAGE` to run them on another base image: `CODSPEED_TEST_BASE_IMAGE=ubuntu:26.04 just test-integ`.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ curl -fsSL https://codspeed.io/install.sh | bash
```

> [!NOTE]
> The CodSpeed CLI officially supports Ubuntu 20.04, 22.04, 24.04 and Debian 11, 12.
> The CodSpeed CLI officially supports Ubuntu 22.04, 24.04, 26.04 and Debian 12.
> Other Linux distributions may work, but are not officially supported.

## Quick Start
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ test-integ *args:

# Remove the executor tests' Docker images, containers and cache volumes
clean-integ:
docker rm -f codspeed-executor-tests-setup 2>/dev/null || true
docker ps -aq --filter name=codspeed-executor-tests-setup | xargs -r docker rm -f
docker images --filter reference=codspeed-executor-tests --filter reference='codspeed-executor-tests:*' -q | sort -u | xargs -r docker rmi -f
docker volume rm -f codspeed-tests-target codspeed-tests-cargo codspeed-tests-cargo-git
docker volume ls -q --filter name=codspeed-tests- | xargs -r docker volume rm -f
34 changes: 25 additions & 9 deletions src/binary_pins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub const VALGRIND_CODSPEED_VERSION: Version = Version::new(3, 26, 0);
/// the .deb is repackaged without a new upstream valgrind release. Appears in
/// the .deb package version (`3.26.0-0codspeed3`) and in `valgrind --version`
/// output (`valgrind-3.26.0.codspeed3`).
pub const VALGRIND_CODSPEED_ITERATION: u32 = 7;
pub const VALGRIND_CODSPEED_ITERATION: u32 = 9;
/// Suffix appended to `VALGRIND_CODSPEED_VERSION` to form the .deb package version.
static VALGRIND_DEB_REV: LazyLock<String> =
LazyLock::new(|| format!("0codspeed{VALGRIND_CODSPEED_ITERATION}"));
Expand Down Expand Up @@ -43,13 +43,15 @@ impl BinaryPin {
pub enum DistroVersion {
Ubuntu2204,
Ubuntu2404,
Ubuntu2604,
}

impl DistroVersion {
fn as_str(self) -> &'static str {
match self {
DistroVersion::Ubuntu2204 => "22.04",
DistroVersion::Ubuntu2404 => "24.04",
DistroVersion::Ubuntu2604 => "26.04",
}
}
}
Expand Down Expand Up @@ -93,16 +95,22 @@ impl ValgrindTarget {
fn sha256(self) -> &'static str {
match (self.distro_version, self.arch) {
(DistroVersion::Ubuntu2204, Arch::Amd64) => {
"658a64049b6a1f5bec9c038b8036f9a61fee83011a909b649e32a82edab4ba99"
}
(DistroVersion::Ubuntu2404, Arch::Amd64) => {
"ea1788e43cfd75b8af84dd496eb265307c6ab6d048cb7bc8ba4bc564dbbd5aba"
"5fcd79e4dc86a71e1a86690373234f8a478814b3500491d39f6086bb8b022046"
}
(DistroVersion::Ubuntu2204, Arch::Arm64) => {
"6db07f15ce23e3cfda00bda85aac0ea3b8a2261c00d529ed856ceb7f3ba207f6"
"57acba3eae6b433da0e8a6b7307b573980c87382856981ae271a7c532fdd2afb"
}
(DistroVersion::Ubuntu2404, Arch::Amd64) => {
"d53f3fc29e8b107057fb28e484917d36b57ba50948a8ef07fae633a584ae387f"
}
(DistroVersion::Ubuntu2404, Arch::Arm64) => {
"0bccdaf2da7202ff4fe15e8301641c3a0abd46879c03713150cb5f21d6c9baaf"
"dfe4c6443c03d166705acad711136c321f9ab4f56baa7f0a878ce59b1050c779"
}
(DistroVersion::Ubuntu2604, Arch::Amd64) => {
"119af13cc0ad39250b9a91df7cf66bbc0c2a8875b2c5df8cc0f7c7361cf5a3d3"
}
(DistroVersion::Ubuntu2604, Arch::Arm64) => {
"6c835ad09a73c753c130425a0912c82e19fc4258a62866a6116d08dbde446e48"
Comment thread
greptile-apps[bot] marked this conversation as resolved.
}
}
}
Expand Down Expand Up @@ -179,16 +187,24 @@ mod tests {
distro_version: DistroVersion::Ubuntu2204,
arch: Arch::Amd64,
},
ValgrindTarget {
distro_version: DistroVersion::Ubuntu2204,
arch: Arch::Arm64,
},
ValgrindTarget {
distro_version: DistroVersion::Ubuntu2404,
arch: Arch::Amd64,
},
ValgrindTarget {
distro_version: DistroVersion::Ubuntu2204,
distro_version: DistroVersion::Ubuntu2404,
arch: Arch::Arm64,
},
ValgrindTarget {
distro_version: DistroVersion::Ubuntu2404,
distro_version: DistroVersion::Ubuntu2604,
arch: Arch::Amd64,
},
ValgrindTarget {
distro_version: DistroVersion::Ubuntu2604,
arch: Arch::Arm64,
},
];
Expand Down
4 changes: 4 additions & 0 deletions src/executor/helpers/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ impl CommandBuilder {
self.cwd.as_deref()
}

pub fn env_names(&self) -> impl Iterator<Item = &OsStr> {
self.envs.keys().map(OsString::as_os_str)
}

pub fn wrap<S, I, T>(&mut self, wrapper: S, wrapper_args: I) -> &mut Self
where
S: AsRef<OsStr>,
Expand Down
47 changes: 43 additions & 4 deletions src/executor/helpers/run_with_sudo.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::executor::helpers::command::CommandBuilder;
use crate::{local_logger::suspend_progress_bar, prelude::*};
use std::{
ffi::OsStr,
ffi::{OsStr, OsString},
io::IsTerminal,
process::{Command, Stdio},
};
Expand Down Expand Up @@ -81,20 +81,37 @@ fn validate_sudo_access() -> Result<()> {
Ok(())
}

/// Build a `--preserve-env=<names>` argument forwarding both this process's environment
/// and the variables set on `cmd_builder`. The names are listed explicitly because
/// sudo-rs ignores a bare `--preserve-env`.
fn preserve_env_arg(cmd_builder: &CommandBuilder) -> OsString {
let process_env_names = std::env::vars_os().map(|(name, _value)| name);
let builder_env_names = cmd_builder.env_names().map(OsStr::to_owned);

let mut arg = OsString::from("--preserve-env=");
for (index, name) in process_env_names.chain(builder_env_names).enumerate() {
if index > 0 {
arg.push(",");
}
arg.push(name);
}
arg
}

/// Wrap with sudo if not running as root
pub fn wrap_with_sudo(mut cmd_builder: CommandBuilder) -> Result<CommandBuilder> {
if is_root_user() {
Ok(cmd_builder)
} else if is_sudo_available() {
debug!("Wrapping with sudo: {}", cmd_builder.as_command_line());
validate_sudo_access()?;

cmd_builder.wrap(
"sudo",
[
// Password prompt should not appear here since it has already been validated
"--non-interactive",
// Forward all environment variables to the command
"--preserve-env",
OsStr::new("--non-interactive"),
&preserve_env_arg(&cmd_builder),
],
);
Ok(cmd_builder)
Expand Down Expand Up @@ -130,3 +147,25 @@ where

Ok(())
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn preserve_env_arg_lists_process_and_builder_env_names() {
let mut cmd_builder = CommandBuilder::new("true");
cmd_builder.env("CODSPEED_TEST_BUILDER_ONLY_VAR", "1");

let arg = preserve_env_arg(&cmd_builder);
let arg = arg.to_str().unwrap();
let names = arg
.strip_prefix("--preserve-env=")
.unwrap()
.split(',')
.collect::<Vec<_>>();

assert!(names.contains(&"PATH"));
assert!(names.contains(&"CODSPEED_TEST_BUILDER_ONLY_VAR"));
}
}
63 changes: 57 additions & 6 deletions src/executor/valgrind/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ fn get_codspeed_valgrind_target(system_info: &SystemInfo) -> Result<ValgrindTarg
(LinuxDistribution::Ubuntu { version }, "x86_64") if version == "24.04" => {
(DistroVersion::Ubuntu2404, Arch::Amd64)
}
(LinuxDistribution::Ubuntu { version }, "x86_64") if version == "26.04" => {
(DistroVersion::Ubuntu2604, Arch::Amd64)
}
(LinuxDistribution::Ubuntu { version }, "aarch64")
| (LinuxDistribution::Debian { version }, "aarch64")
if version == "22.04" || version == "12" =>
Expand All @@ -40,6 +43,9 @@ fn get_codspeed_valgrind_target(system_info: &SystemInfo) -> Result<ValgrindTarg
(LinuxDistribution::Ubuntu { version }, "aarch64") if version == "24.04" => {
(DistroVersion::Ubuntu2404, Arch::Arm64)
}
(LinuxDistribution::Ubuntu { version }, "aarch64") if version == "26.04" => {
(DistroVersion::Ubuntu2604, Arch::Arm64)
}
_ => bail!("Unsupported system"),
};

Expand Down Expand Up @@ -334,7 +340,7 @@ mod tests {
use super::*;

#[test]
fn test_system_info_to_codspeed_valgrind_url_ubuntu() {
fn test_system_info_to_codspeed_valgrind_url_ubuntu_22() {
let system_info = SystemInfo {
os: SupportedOs::Linux(LinuxDistribution::Ubuntu {
version: "22.04".into(),
Expand All @@ -344,7 +350,7 @@ mod tests {
};
assert_snapshot!(
get_codspeed_valgrind_binary(&system_info).unwrap().url(),
@"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/3.26.0-0codspeed7/valgrind_3.26.0-0codspeed7_ubuntu-22.04_amd64.deb"
@"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/3.26.0-0codspeed9/valgrind_3.26.0-0codspeed9_ubuntu-22.04_amd64.deb"
);
}

Expand All @@ -359,7 +365,22 @@ mod tests {
};
assert_snapshot!(
get_codspeed_valgrind_binary(&system_info).unwrap().url(),
@"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/3.26.0-0codspeed7/valgrind_3.26.0-0codspeed7_ubuntu-24.04_amd64.deb"
@"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/3.26.0-0codspeed9/valgrind_3.26.0-0codspeed9_ubuntu-24.04_amd64.deb"
);
}

#[test]
fn test_system_info_to_codspeed_valgrind_url_ubuntu_26() {
let system_info = SystemInfo {
os: SupportedOs::Linux(LinuxDistribution::Ubuntu {
version: "26.04".into(),
}),
arch: "x86_64".to_string(),
..SystemInfo::test()
};
assert_snapshot!(
get_codspeed_valgrind_binary(&system_info).unwrap().url(),
@"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/3.26.0-0codspeed9/valgrind_3.26.0-0codspeed9_ubuntu-26.04_amd64.deb"
);
}

Expand All @@ -374,12 +395,12 @@ mod tests {
};
assert_snapshot!(
get_codspeed_valgrind_binary(&system_info).unwrap().url(),
@"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/3.26.0-0codspeed7/valgrind_3.26.0-0codspeed7_ubuntu-22.04_amd64.deb"
@"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/3.26.0-0codspeed9/valgrind_3.26.0-0codspeed9_ubuntu-22.04_amd64.deb"
);
}

#[test]
fn test_system_info_to_codspeed_valgrind_url_ubuntu_arm() {
fn test_system_info_to_codspeed_valgrind_url_ubuntu_22_arm() {
let system_info = SystemInfo {
os: SupportedOs::Linux(LinuxDistribution::Ubuntu {
version: "22.04".into(),
Expand All @@ -389,7 +410,37 @@ mod tests {
};
assert_snapshot!(
get_codspeed_valgrind_binary(&system_info).unwrap().url(),
@"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/3.26.0-0codspeed7/valgrind_3.26.0-0codspeed7_ubuntu-22.04_arm64.deb"
@"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/3.26.0-0codspeed9/valgrind_3.26.0-0codspeed9_ubuntu-22.04_arm64.deb"
);
}

#[test]
fn test_system_info_to_codspeed_valgrind_url_ubuntu_24_arm() {
let system_info = SystemInfo {
os: SupportedOs::Linux(LinuxDistribution::Ubuntu {
version: "24.04".into(),
}),
arch: "aarch64".to_string(),
..SystemInfo::test()
};
assert_snapshot!(
get_codspeed_valgrind_binary(&system_info).unwrap().url(),
@"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/3.26.0-0codspeed9/valgrind_3.26.0-0codspeed9_ubuntu-24.04_arm64.deb"
);
}

#[test]
fn test_system_info_to_codspeed_valgrind_url_ubuntu_26_arm() {
let system_info = SystemInfo {
os: SupportedOs::Linux(LinuxDistribution::Ubuntu {
version: "26.04".into(),
}),
arch: "aarch64".to_string(),
..SystemInfo::test()
};
assert_snapshot!(
get_codspeed_valgrind_binary(&system_info).unwrap().url(),
@"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/3.26.0-0codspeed9/valgrind_3.26.0-0codspeed9_ubuntu-26.04_arm64.deb"
);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ubuntu:24.04
ARG BASE_IMAGE=ubuntu:24.04
FROM ${BASE_IMAGE}

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
Expand Down
Loading
Loading