-
Notifications
You must be signed in to change notification settings - Fork 6
Manage installation and release of the exec harness and codspeed-memtrack #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GuillaumeLagrange
merged 8 commits into
main
from
cod-1737-manage-installation-of-the-exec-harness
Dec 18, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1b63390
ci: switch to pr run mode plan only for pr
GuillaumeLagrange 617053c
chore: reset exec-harness and memtrack crate versions to 1.0.0 ahead …
GuillaumeLagrange 2c3cd61
chore: add cargo-dist arguments for release
GuillaumeLagrange 4dda2b7
feat: auto install codspeed-memtrack during executor setup
GuillaumeLagrange 3158496
feat: automatically install exec-harness for exec subcommand
GuillaumeLagrange e3d5c34
chore: add CONTRIBUTING.md
GuillaumeLagrange 83e94af
fix: remove the password prompt from the run_with_sudo dialog
GuillaumeLagrange 8be2914
fix: stop hanging indefinitely if process fails to start in memory ex…
GuillaumeLagrange File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Contributing to CodSpeed Runner | ||
|
|
||
| ## Release Process | ||
|
|
||
| This repository is a Cargo workspace containing multiple crates. The release process differs depending on which crate you're releasing. | ||
|
|
||
| ### Workspace Structure | ||
|
|
||
| - **`codspeed-runner`**: The main CLI binary (`codspeed`) | ||
| - **`memtrack`**: Memory tracking binary (`codspeed-memtrack`) | ||
| - **`exec-harness`**: Execution harness binary | ||
| - **`runner-shared`**: Shared library used by other crates | ||
|
|
||
| ### Releasing Support Crates (memtrack, exec-harness, runner-shared) | ||
|
|
||
| For any crate other than the main runner: | ||
|
|
||
| ```bash | ||
| cargo release -p <PACKAGE_NAME> --execute <VERSION_BUMP> | ||
| ``` | ||
|
|
||
| Where `<VERSION_BUMP>` is one of: `alpha`, `beta`, `patch`, `minor`, or `major`. | ||
|
|
||
| **Examples:** | ||
|
|
||
| ```bash | ||
| # Release a new patch version of memtrack | ||
| cargo release -p memtrack --execute patch | ||
|
|
||
| # Release a beta version of exec-harness | ||
| cargo release -p exec-harness --execute beta | ||
| ``` | ||
|
|
||
| #### Post-Release: Update Version References | ||
|
|
||
| After releasing `memtrack` or `exec-harness`, you **must** update the version references in the runner code: | ||
|
|
||
| 1. **For memtrack**: Update `MEMTRACK_CODSPEED_VERSION` in `src/executor/memory/executor.rs`: | ||
|
|
||
| ```rust | ||
| const MEMTRACK_CODSPEED_VERSION: &str = "X.Y.Z"; // Update to new version | ||
| ``` | ||
|
|
||
| 2. **For exec-harness**: Update `EXEC_HARNESS_VERSION` in `src/exec/mod.rs`: | ||
| ```rust | ||
| const EXEC_HARNESS_VERSION: &str = "X.Y.Z"; // Update to new version | ||
| ``` | ||
|
|
||
| These constants are used by the runner to download and install the correct versions of the binaries from GitHub releases. | ||
|
|
||
| ### Releasing the Main Runner | ||
|
|
||
| The main runner (`codspeed-runner`) should be released after ensuring all dependency versions are correct. | ||
|
|
||
| #### Pre-Release Check | ||
|
|
||
| **Verify binary version references**: Check that version constants in the runner code match the released versions: | ||
|
|
||
| - `MEMTRACK_CODSPEED_VERSION` in `src/executor/memory/executor.rs` | ||
| - `EXEC_HARNESS_VERSION` in `src/exec/mod.rs` | ||
|
|
||
| #### Release Command | ||
|
|
||
| ```bash | ||
| cargo release --execute <VERSION_BUMP> | ||
| ``` | ||
|
|
||
| Where `<VERSION_BUMP>` is one of: `alpha`, `beta`, `patch`, `minor`, or `major`. | ||
|
|
||
| **Examples:** | ||
|
|
||
| ```bash | ||
| # Release a new minor version | ||
| cargo release --execute minor | ||
|
|
||
| # Release a patch version | ||
| cargo release --execute patch | ||
|
|
||
| # Release a beta version | ||
| cargo release --execute beta | ||
| ``` | ||
|
|
||
| ## Known issue | ||
|
|
||
| If one of the crates is currenlty in beta version, for example the runner is in beta version 4.4.2-beta.1, any alpha release will fail for the any crate, saying that only minor, major or patch releases is supported. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,16 @@ | ||
| [package] | ||
| name = "exec-harness" | ||
| version = "4.4.2-beta.1" | ||
| version = "1.0.0" | ||
| edition = "2024" | ||
| repository = "https://github.com/CodSpeedHQ/runner" | ||
| publish = false | ||
|
|
||
| [dependencies] | ||
| anyhow = { workspace = true } | ||
| codspeed = "4.1.0" | ||
| clap = { workspace = true } | ||
| serde_json = { workspace = true } | ||
| serde = { workspace = true } | ||
|
|
||
| [package.metadata.dist] | ||
| targets = ["aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| use crate::prelude::*; | ||
| use crate::run::helpers::download_file; | ||
| use semver::Version; | ||
| use std::process::Command; | ||
| use tempfile::NamedTempFile; | ||
| use url::Url; | ||
|
|
||
| mod versions; | ||
|
|
||
| /// Ensure a binary is installed, or install it from a runner's GitHub release using the installer script. | ||
| /// | ||
| /// This function checks if the binary is already installed with the correct version. | ||
| /// If not, it downloads and executes an installer script from the CodSpeed runner repository. | ||
| /// | ||
| /// # Arguments | ||
| /// * `binary_name` - The binary command name (e.g., "codspeed-memtrack", "codspeed-exec-harness") | ||
| /// * `version` - The version to install (e.g., "4.4.2-alpha.2") | ||
| /// * `get_installer_url` - A closure that returns the URL to download the installer script. | ||
| pub async fn ensure_binary_installed<F>( | ||
| binary_name: &str, | ||
| version: &str, | ||
| get_installer_url: F, | ||
| ) -> Result<()> | ||
| where | ||
| F: FnOnce() -> String, | ||
| { | ||
| if is_command_installed( | ||
| binary_name, | ||
| Version::parse(version).context("Invalid version format")?, | ||
| ) { | ||
| debug!("{binary_name} version {version} is already installed"); | ||
| return Ok(()); | ||
| } | ||
|
|
||
| let installer_url = Url::parse(&get_installer_url()).context("Invalid installer URL")?; | ||
|
|
||
| debug!("Downloading installer from: {installer_url}"); | ||
|
|
||
| // Download the installer script to a temporary file | ||
| let temp_file = NamedTempFile::new().context("Failed to create temporary file")?; | ||
| download_file(&installer_url, temp_file.path()).await?; | ||
|
|
||
| // Execute the installer script | ||
| let output = Command::new("sh") | ||
| .arg(temp_file.path()) | ||
| .output() | ||
| .context("Failed to execute installer command")?; | ||
|
|
||
| if !output.status.success() { | ||
| bail!( | ||
| "Failed to install {binary_name} version {version}. Installer exited with output: {output:?}", | ||
| ); | ||
| } | ||
|
|
||
| if !is_command_installed( | ||
| binary_name, | ||
| Version::parse(version).context("Invalid version format")?, | ||
| ) { | ||
| bail!( | ||
| "Could not veryfy installation of {binary_name} version {version} after running installer" | ||
| ); | ||
| } | ||
|
|
||
| info!("Successfully installed {binary_name} version {version}"); | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Check if the given command is installed and its version matches the expected version. | ||
| /// | ||
| /// Expects the command to support the `--version` flag and return a version string. | ||
| fn is_command_installed(command: &str, expected_version: Version) -> bool { | ||
| let is_command_installed = Command::new("which") | ||
| .arg(command) | ||
| .output() | ||
| .is_ok_and(|output| output.status.success()); | ||
|
|
||
| if !is_command_installed { | ||
| debug!("{command} is not installed"); | ||
| return false; | ||
| } | ||
|
|
||
| let Ok(version_output) = Command::new(command).arg("--version").output() else { | ||
| return false; | ||
| }; | ||
|
|
||
| if !version_output.status.success() { | ||
| debug!( | ||
| "Failed to get command version. stderr: {}", | ||
| String::from_utf8_lossy(&version_output.stderr) | ||
| ); | ||
| return false; | ||
| } | ||
|
|
||
| let version_string = String::from_utf8_lossy(&version_output.stdout); | ||
| let Ok(version) = versions::parse_from_output(&version_string) else { | ||
| return false; | ||
| }; | ||
|
|
||
| debug!("Found {command} version: {version}"); | ||
|
|
||
| versions::is_compatible(command, &version, &expected_version) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.