diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49945a9fc..cb96a81da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} @@ -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 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -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: @@ -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 @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b524b95f8..1eb1419d2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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= 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= just test-integ`. To run them against a valgrind-codspeed package, e.g. one built with `just docker-deb ` 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`. diff --git a/README.md b/README.md index 87bad8ad7..5a4b23512 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/justfile b/justfile index fb51047b7..04fafd805 100644 --- a/justfile +++ b/justfile @@ -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 diff --git a/src/binary_pins.rs b/src/binary_pins.rs index c83e4d7b7..5a97140eb 100644 --- a/src/binary_pins.rs +++ b/src/binary_pins.rs @@ -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 = LazyLock::new(|| format!("0codspeed{VALGRIND_CODSPEED_ITERATION}")); @@ -43,6 +43,7 @@ impl BinaryPin { pub enum DistroVersion { Ubuntu2204, Ubuntu2404, + Ubuntu2604, } impl DistroVersion { @@ -50,6 +51,7 @@ impl DistroVersion { match self { DistroVersion::Ubuntu2204 => "22.04", DistroVersion::Ubuntu2404 => "24.04", + DistroVersion::Ubuntu2604 => "26.04", } } } @@ -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" } } } @@ -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, }, ]; diff --git a/src/executor/helpers/command.rs b/src/executor/helpers/command.rs index 345f96975..442334efe 100644 --- a/src/executor/helpers/command.rs +++ b/src/executor/helpers/command.rs @@ -81,6 +81,10 @@ impl CommandBuilder { self.cwd.as_deref() } + pub fn env_names(&self) -> impl Iterator { + self.envs.keys().map(OsString::as_os_str) + } + pub fn wrap(&mut self, wrapper: S, wrapper_args: I) -> &mut Self where S: AsRef, diff --git a/src/executor/helpers/run_with_sudo.rs b/src/executor/helpers/run_with_sudo.rs index bc9c84628..6b9632225 100644 --- a/src/executor/helpers/run_with_sudo.rs +++ b/src/executor/helpers/run_with_sudo.rs @@ -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}, }; @@ -81,6 +81,23 @@ fn validate_sudo_access() -> Result<()> { Ok(()) } +/// Build a `--preserve-env=` 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 { if is_root_user() { @@ -88,13 +105,13 @@ pub fn wrap_with_sudo(mut cmd_builder: CommandBuilder) -> Result } 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) @@ -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::>(); + + assert!(names.contains(&"PATH")); + assert!(names.contains(&"CODSPEED_TEST_BUILDER_ONLY_VAR")); + } +} diff --git a/src/executor/valgrind/setup.rs b/src/executor/valgrind/setup.rs index 0f6b82306..bf44da2f9 100644 --- a/src/executor/valgrind/setup.rs +++ b/src/executor/valgrind/setup.rs @@ -31,6 +31,9 @@ fn get_codspeed_valgrind_target(system_info: &SystemInfo) -> Result { (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" => @@ -40,6 +43,9 @@ fn get_codspeed_valgrind_target(system_info: &SystemInfo) -> Result { (DistroVersion::Ubuntu2404, Arch::Arm64) } + (LinuxDistribution::Ubuntu { version }, "aarch64") if version == "26.04" => { + (DistroVersion::Ubuntu2604, Arch::Arm64) + } _ => bail!("Unsupported system"), }; @@ -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(), @@ -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" ); } @@ -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" ); } @@ -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(), @@ -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" ); } diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index 9ceae6260..86d02bdb5 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -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 \ diff --git a/tests/docker/run.sh b/tests/docker/run.sh index 6203694ce..a5021d69d 100755 --- a/tests/docker/run.sh +++ b/tests/docker/run.sh @@ -8,9 +8,20 @@ # # CODSPEED_VALGRIND_REF= runs the suite against that # valgrind-codspeed instead of the pinned release. +# +# CODSPEED_VALGRIND_DEB= runs the suite against that +# package instead of the pinned release. +# +# CODSPEED_TEST_BASE_IMAGE= (default ubuntu:24.04) runs the suite on that base image. +# Each base image gets its own images and target volume: binaries built against one glibc +# don't run on an older one. +# +# CODSPEED_VALGRIND_BUILD_FROM_SOURCE is forwarded to the containers when set. set -euo pipefail repo=$(git -C "$(dirname "$0")" rev-parse --show-toplevel) +base_image=${CODSPEED_TEST_BASE_IMAGE:-ubuntu:24.04} +flavor=${base_image//[^A-Za-z0-9_.-]/-} image=codspeed-executor-tests rust_version=$(sed -n 's/.*channel = "\(.*\)".*/\1/p' "$repo/rust-toolchain.toml") rust_components=$(sed -n 's/.*components = \[\(.*\)\].*/\1/p' "$repo/rust-toolchain.toml" | tr -d '" ') @@ -34,12 +45,25 @@ resolve_valgrind_ref() { exit 1 } -valgrind_commit= +if [ -n "${CODSPEED_VALGRIND_REF:-}" ] && [ -n "${CODSPEED_VALGRIND_DEB:-}" ]; then + echo "Set CODSPEED_VALGRIND_REF or CODSPEED_VALGRIND_DEB, not both" >&2 + exit 1 +fi + +# Arguments of setup.sh selecting the valgrind-codspeed to install, and the docker flags +# that setup needs for it. +valgrind_source=() +setup_flags=() if [ -n "${CODSPEED_VALGRIND_REF:-}" ]; then - valgrind_commit=$(resolve_valgrind_ref "$CODSPEED_VALGRIND_REF") + valgrind_source=(commit "$(resolve_valgrind_ref "$CODSPEED_VALGRIND_REF")") +elif [ -n "${CODSPEED_VALGRIND_DEB:-}" ]; then + deb=$(realpath -e "$CODSPEED_VALGRIND_DEB") + valgrind_source=(deb /tmp/valgrind-codspeed.deb) + setup_flags=(-v "$deb":/tmp/valgrind-codspeed.deb:ro) fi -docker build -q -t "$image" --build-arg RUST_VERSION="$rust_version" \ +docker build -q -t "$image:$flavor" --build-arg BASE_IMAGE="$base_image" \ + --build-arg RUST_VERSION="$rust_version" \ --build-arg RUST_COMPONENTS="$rust_components" \ -f "$repo/tests/docker/Dockerfile" "$repo/tests/docker" >/dev/null @@ -53,9 +77,10 @@ docker_flags=( --cap-add DAC_READ_SEARCH --cap-add SYS_PTRACE --ulimit memlock=-1:-1 --security-opt seccomp=unconfined --security-opt apparmor=unconfined -v "$repo":/workspace - -v codspeed-tests-target:/home/tester/target + -v "codspeed-tests-target-$flavor":/home/tester/target -v codspeed-tests-cargo:/home/tester/.cargo/registry -v codspeed-tests-cargo-git:/home/tester/.cargo/git + -e CODSPEED_VALGRIND_BUILD_FROM_SOURCE ) in_container() { docker run --rm "${tty[@]}" "${docker_flags[@]}" "$run_image" "$@" @@ -63,7 +88,7 @@ in_container() { cargo_test=(cargo test -p codspeed-runner --features executor-tests --test executors) tty=() -run_image=$image +run_image=$image:$flavor in_container "${cargo_test[@]}" --no-run # Bakes what `codspeed setup` installs (Valgrind, memtrack) into an image, so test containers @@ -72,17 +97,20 @@ in_container "${cargo_test[@]}" --no-run inputs_hash=$({ cat "$repo/tests/docker/Dockerfile" "$repo/tests/docker/setup.sh" "$repo/rust-toolchain.toml" \ "$repo/src/binary_pins.rs" - printf %s "$valgrind_commit" + printf %s "$base_image ${valgrind_source[*]}" + if [ -n "${deb:-}" ]; then + cat "$deb" + fi } | sha256sum | cut -c1-12) -run_image=$image:setup-$inputs_hash +run_image=$image:$flavor-setup-$inputs_hash if ! docker image inspect "$run_image" >/dev/null 2>&1; then - setup_container=$image-setup + setup_container=$image-setup-$flavor docker rm -f "$setup_container" >/dev/null 2>&1 || true - docker run --name "$setup_container" "${docker_flags[@]}" "$image" \ - tests/docker/setup.sh /home/tester/target/debug/codspeed $valgrind_commit + docker run --name "$setup_container" "${docker_flags[@]}" "${setup_flags[@]}" "$image:$flavor" \ + tests/docker/setup.sh /home/tester/target/debug/codspeed "${valgrind_source[@]}" docker commit "$setup_container" "$run_image" >/dev/null docker rm "$setup_container" >/dev/null - docker images --filter "reference=$image:setup-*" --format '{{.Repository}}:{{.Tag}}' \ + docker images --filter "reference=$image:$flavor-setup-*" --format '{{.Repository}}:{{.Tag}}' \ | { grep -vxF "$run_image" || true; } | xargs -r docker rmi >/dev/null fi diff --git a/tests/docker/setup.sh b/tests/docker/setup.sh index 5b6fc0002..b2364abc3 100755 --- a/tests/docker/setup.sh +++ b/tests/docker/setup.sh @@ -1,33 +1,49 @@ #!/usr/bin/env bash -# Runs `codspeed setup` in the setup container, after building and installing the -# valgrind-codspeed when one is given. -# Usage: tests/docker/setup.sh [valgrind-codspeed valgrind_commit] +# Runs `codspeed setup` in the setup container, after installing a valgrind-codspeed +# other than the pinned release when one is given: +# - `commit ` builds and installs that valgrind-codspeed commit; +# - `deb ` installs that valgrind-codspeed package. +# Usage: tests/docker/setup.sh [commit | deb ] set -euo pipefail codspeed=$1 -valgrind_commit=${2:-} +source=${2:-} +value=${3:-} -if [ -z "$valgrind_commit" ]; then - exec "$codspeed" setup -fi - -echo "Setting up valgrind-codspeed $valgrind_commit" -src=$(mktemp -d) -trap 'rm -rf "$src"' EXIT -git -C "$src" init -q -git -C "$src" fetch -q --depth 1 https://github.com/CodSpeedHQ/valgrind-codspeed.git "$valgrind_commit" -git -C "$src" checkout -q FETCH_HEAD -(cd "$src" && ./autogen.sh && ./configure --prefix=/usr && make -j"$(nproc)") >"$src/build.log" 2>&1 || - { tail -n 50 "$src/build.log"; exit 1; } -sudo make -C "$src" install >/dev/null -# Setup reinstalls valgrind from its package when the libc debug symbols are missing. -sudo apt-get update -q >/dev/null && sudo apt-get install -y -q libc6-dbg >/dev/null +case $source in + "") + exec "$codspeed" setup + ;; + commit) + echo "Setting up valgrind-codspeed $value" + src=$(mktemp -d) + trap 'rm -rf "$src"' EXIT + git -C "$src" init -q + git -C "$src" fetch -q --depth 1 https://github.com/CodSpeedHQ/valgrind-codspeed.git "$value" + git -C "$src" checkout -q FETCH_HEAD + (cd "$src" && ./autogen.sh && ./configure --prefix=/usr && make -j"$(nproc)") >"$src/build.log" 2>&1 || + { tail -n 50 "$src/build.log"; exit 1; } + sudo make -C "$src" install >/dev/null + # Setup reinstalls valgrind from its package when the libc debug symbols are missing. + sudo apt-get update -q >/dev/null && sudo apt-get install -y -q libc6-dbg >/dev/null + ;; + deb) + echo "Setting up valgrind-codspeed from $value" + # The same packages `codspeed setup` installs along with the pinned package. + sudo apt-get update -q >/dev/null + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -q "$value" libc6-dbg >/dev/null + ;; + *) + echo "Unknown valgrind-codspeed source '$source', expected 'commit' or 'deb'" >&2 + exit 1 + ;; +esac built=$(valgrind --version) -echo "Installed $built from valgrind-codspeed $valgrind_commit" +echo "Installed $built" "$codspeed" setup # Setup keeps the installed valgrind only when it is at least the pinned version. if [ "$(valgrind --version)" != "$built" ]; then - echo "codspeed setup replaced $built with $(valgrind --version): valgrind-codspeed $valgrind_commit is older than the pinned release" >&2 + echo "codspeed setup replaced $built with $(valgrind --version): the installed valgrind-codspeed is older than the pinned release" >&2 exit 1 fi