Skip to content

Commit 369f3c0

Browse files
Inline workflow watch loop
1 parent 57440f0 commit 369f3c0

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • tools/ci/commands/workflow-watch/src

tools/ci/commands/workflow-watch/src/main.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,30 @@ fn response_body(response: &str) -> &str {
6060
.map_or(response, |(_, body)| body)
6161
}
6262

63-
fn watch_workflow_run(repo: &str, run_id: u64, interval_seconds: u64, max_attempts: Option<u64>) -> Result<()> {
64-
println!("Waiting for workflow result... https://github.com/{repo}/actions/runs/{run_id}");
63+
fn main() -> Result<()> {
64+
let args = Args::parse();
65+
66+
println!(
67+
"Waiting for workflow result... https://github.com/{}/actions/runs/{}",
68+
args.repo, args.run_id
69+
);
6570

6671
let mut attempts = 0;
6772
loop {
6873
attempts += 1;
69-
let run = get_workflow_run(repo, run_id)?;
74+
let run = get_workflow_run(&args.repo, args.run_id)?;
7075
if run.status == "completed" {
7176
let conclusion = run.conclusion.as_deref().unwrap_or("success");
7277
if conclusion == "success" {
7378
return Ok(());
7479
}
75-
bail!("workflow run {run_id} completed with conclusion: {conclusion}");
80+
bail!("workflow run {} completed with conclusion: {conclusion}", args.run_id);
7681
}
7782

78-
if max_attempts.is_some_and(|max| attempts >= max) {
79-
bail!("timed out waiting for workflow run {run_id} to complete")
83+
if args.max_attempts.is_some_and(|max| attempts >= max) {
84+
bail!("timed out waiting for workflow run {} to complete", args.run_id)
8085
}
8186

82-
std::thread::sleep(std::time::Duration::from_secs(interval_seconds));
87+
std::thread::sleep(std::time::Duration::from_secs(args.interval_seconds));
8388
}
8489
}
85-
86-
fn main() -> Result<()> {
87-
let args = Args::parse();
88-
watch_workflow_run(&args.repo, args.run_id, args.interval_seconds, args.max_attempts)
89-
}

0 commit comments

Comments
 (0)