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
21 changes: 21 additions & 0 deletions src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ fn log_execution_context(safe_output_dir: &Path, ctx: &ExecutionContext) {
debug!("ADO project: {}", ctx.ado_project.as_deref().unwrap_or("<not set>"));
debug!("Repository ID: {}", ctx.repository_id.as_deref().unwrap_or("<not set>"));
debug!("Repository name: {}", ctx.repository_name.as_deref().unwrap_or("<not set>"));
debug!(
"Build ID: {}",
ctx.build_id
.map(|id| id.to_string())
.unwrap_or_else(|| "<not set>".to_string())
);
debug!("Build reason: {}", ctx.build_reason.as_deref().unwrap_or("<not set>"));
debug!(
"Triggered by definition: {}",
ctx.triggered_by_definition_name.as_deref().unwrap_or("<not set>")
);
if !ctx.allowed_repositories.is_empty() {
debug!(
"Allowed repositories: {}",
Expand Down Expand Up @@ -376,6 +387,7 @@ mod tests {
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

let result = execute_safe_output(&entry, &ctx).await;
Expand Down Expand Up @@ -410,6 +422,7 @@ mod tests {
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

let result = execute_safe_output(&entry, &ctx).await;
Expand Down Expand Up @@ -560,6 +573,7 @@ mod tests {
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

let result = execute_safe_output(&entry, &ctx).await;
Expand Down Expand Up @@ -604,6 +618,7 @@ mod tests {
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

let result = execute_safe_output(&entry, &ctx).await;
Expand Down Expand Up @@ -648,6 +663,7 @@ mod tests {
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

let result = execute_safe_output(&entry, &ctx).await;
Expand Down Expand Up @@ -697,6 +713,7 @@ mod tests {
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

let results = execute_safe_outputs(temp_dir.path(), &ctx).await;
Expand Down Expand Up @@ -907,6 +924,7 @@ mod tests {
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

let results = execute_safe_outputs(temp_dir.path(), &ctx).await;
Expand Down Expand Up @@ -952,6 +970,7 @@ mod tests {
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

let results = execute_safe_outputs(temp_dir.path(), &ctx).await.unwrap();
Expand Down Expand Up @@ -1055,6 +1074,7 @@ mod tests {
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

let result = execute_safe_output(&entry, &ctx).await;
Expand Down Expand Up @@ -1084,6 +1104,7 @@ mod tests {
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: true,
..Default::default()
};

let result = execute_safe_output(&entry, &ctx).await;
Expand Down
10 changes: 6 additions & 4 deletions src/safeoutputs/add_build_tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ impl Executor for AddBuildTagResult {

// 2b. Scope check: by default only the current build can be tagged
if !config.allow_any_build {
let current_build_id: Option<i32> = std::env::var("BUILD_BUILDID")
.ok()
.and_then(|s| s.parse().ok());
// Pulled from ctx (sourced from BUILD_BUILDID); narrowed to i32 to
// match the agent-supplied build_id type.
let current_build_id: Option<i32> = ctx
.build_id
.and_then(|id| i32::try_from(id).ok());
if let Some(current_id) = current_build_id {
if self.build_id != current_id {
return Ok(ExecutionResult::failure(format!(
Expand All @@ -147,7 +149,7 @@ impl Executor for AddBuildTagResult {
)));
}
}
// If BUILD_BUILDID is not set (e.g. local execution), allow any build
// If build_id is not set (e.g. local execution), allow any build
}

// 3. Apply tag prefix if configured
Expand Down
4 changes: 4 additions & 0 deletions src/safeoutputs/create_wiki_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ wiki-name: "MyProject.wiki"
allowed_repositories: std::collections::HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

// wiki-name not in config → should return Err
Expand Down Expand Up @@ -766,6 +767,7 @@ wiki-name: "MyProject.wiki"
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

let outcome = result.execute_impl(&ctx).await.unwrap();
Expand Down Expand Up @@ -806,6 +808,7 @@ wiki-name: "MyProject.wiki"
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

let outcome = result.execute_impl(&ctx).await.unwrap();
Expand Down Expand Up @@ -846,6 +849,7 @@ wiki-name: "MyProject.wiki"
allowed_repositories: HashMap::new(),
agent_stats: None,
dry_run: false,
..Default::default()
};

// The GET will fail (network unreachable with a fake host), so the
Expand Down
Loading