Do not inherit environment variables in citool tests

So that we can make sure that they are reproducible locally.
This commit is contained in:
Jakub Beránek 2025-06-09 08:06:05 +02:00
parent 334ba81275
commit 7614592107
No known key found for this signature in database
GPG key ID: 909CD0D26483516B

View file

@ -46,16 +46,21 @@ fn pr_jobs() {
}
fn get_matrix(event_name: &str, commit_msg: &str, branch_ref: &str) -> String {
let output = Command::new("cargo")
.args(["run", "-q", "calculate-job-matrix", "--jobs-file", TEST_JOBS_YML_PATH])
let path = std::env::var("PATH");
let mut cmd = Command::new("cargo");
cmd.args(["run", "-q", "calculate-job-matrix", "--jobs-file", TEST_JOBS_YML_PATH])
.env_clear()
.env("GITHUB_EVENT_NAME", event_name)
.env("COMMIT_MESSAGE", commit_msg)
.env("GITHUB_REF", branch_ref)
.env("GITHUB_RUN_ID", "123")
.env("GITHUB_RUN_ATTEMPT", "1")
.stdout(Stdio::piped())
.output()
.expect("Failed to execute command");
.stdout(Stdio::piped());
if let Ok(path) = path {
cmd.env("PATH", path);
}
let output = cmd.output().expect("Failed to execute command");
let stdout = String::from_utf8(output.stdout).unwrap();
let stderr = String::from_utf8(output.stderr).unwrap();