use std::path::Path;
use argonauts_core::TaskId;
use argonauts_runner::{Check, Checked};
use crate::engine::host::Host;
use crate::error::EngineResult;
use crate::goal::until::{self, Asked};
use crate::workflow::StepCall;
pub async fn check(
host: &Host,
call: &StepCall,
check: &Check,
task: Option<&TaskId>,
max_rounds: Option<u32>,
workdir: &Path,
) -> EngineResult<Checked> {
let asked = Asked {
condition: &check.condition,
commands: &[],
step: check.step.as_deref(),
task,
kept_by: check.kept_by.as_deref(),
try_number: check.try_number,
round: check.round,
max_rounds,
};
let held = until::held(host, &call.at, &asked, workdir).await?;
Ok(Checked {
holds: held.holds,
failed: held.failed,
stop: held.stop,
})
}
pub fn work_as(
host: &Host,
until: &str,
step: Option<&str>,
task: &TaskId,
kept_by: Option<&str>,
max_rounds: Option<u32>,
) -> EngineResult<()> {
let asked = Asked {
condition: until,
commands: &[],
step,
task: Some(task),
kept_by,
try_number: None,
round: None,
max_rounds,
};
until::work_as(host, &asked)
}