Skip to main content

Step

Struct Step 

Source
pub struct Step {
Show 21 fields pub name: String, pub dir: PathBuf, pub action: Action, pub deps: Vec<String>, pub reads: Vec<Artefact>, pub params: Vec<String>, pub inputs: Vec<Input>, pub prechecks: Vec<Precheck>, pub services: Vec<Service>, pub outputs: Vec<Output>, pub timeout: Option<Duration>, pub complete_on: ExitCodes, pub pass_patterns: Vec<Pattern>, pub fail_patterns: Vec<Pattern>, pub fail_on_exit: Option<String>, pub judge: Option<Arc<dyn Fn(&Judging<'_>) -> Outcome + Send + Sync>>, pub parse: Option<Parse>, pub run_after_fail: bool, pub volatile: bool, pub holds: BTreeMap<String, u64>, pub shares_dir: bool,
}

Fields§

§name: String§dir: PathBuf

The step’s own working directory. It is emptied before the step runs.

§action: Action§deps: Vec<String>

Steps that must pass first. Their outputs are part of the cache key. Reading another step’s artefact adds the step here, so a flow names a dependency once.

§reads: Vec<Artefact>

The artefacts of other steps that it reads.

§params: Vec<String>

What an in-process function was made from, such as an option it captured. A function can’t be hashed, so what changes its result is said here, and is part of the cache key.

§inputs: Vec<Input>§prechecks: Vec<Precheck>

Conditions checked before any step of the run starts, on top of those its invocations declare.

§services: Vec<Service>§outputs: Vec<Output>§timeout: Option<Duration>§complete_on: ExitCodes§pass_patterns: Vec<Pattern>

Each must match in its output, or the tool did not finish normally: a step error.

§fail_patterns: Vec<Pattern>

A match of any in its output fails the step.

§fail_on_exit: Option<String>

A step that completed with an exit code other than 0 fails, with this message: {code} in it is the code. It is data, so unlike a judge it is part of the cache key, for a tool whose exit code is its verdict.

§judge: Option<Arc<dyn Fn(&Judging<'_>) -> Outcome + Send + Sync>>§parse: Option<Parse>

What reads the step’s results from what it wrote, once it completed: its judge is given them, and the flow reads them from the output.

§run_after_fail: bool

Run even if a step it depends on failed, as a report of failures does. It is still skipped after a step that did not complete.

§volatile: bool

The result can’t be repeated, so it must never be cached.

§holds: BTreeMap<String, u64>

What the step holds from the resource pools on top of what its invocations declare, such as memory. A flow’s config sets it, since how much a step needs depends on the design.

§shares_dir: bool

A child of a cache unit that works in the unit’s own directory, beside its siblings. It is not emptied before it runs, and its command’s logs are named after it. Step::unit sets it.

Implementations§

Source§

impl Step

Source

fn new(name: &str, dir: PathBuf, action: Action) -> Self

Source

pub fn exec(name: &str, dir: PathBuf, inv: Invocation) -> Self

Source

pub fn unit(name: &str, dir: PathBuf, children: Vec<Step>) -> Self

A cache unit: a step with child steps and no command of its own. The children’s directories are in dir, and each runs once those it depends on are done, beside any others that fit in what the unit holds. A child only completes or not: the unit has the verdict, from what it exports. No flow has one yet.

Source

pub fn group(name: &str, dir: PathBuf, children: Vec<Step>) -> Self

A composite step: child steps grouped under one name, each cached by itself. The children’s directories are in dir. No flow has one yet.

Source

pub fn export(self, artefact: &Artefact) -> Self

Export a child’s artefact from a cache unit or a composite step: an output of the parent, named CHILD.OUTPUT, which other steps read. A unit’s exports are what the cache stores of it.

Source

pub fn with_action(name: &str, dir: PathBuf, action: Action) -> Self

A step that does action, for a tool that gives either kind.

Source

pub fn after(self, dep: &str) -> Self

Run after dep without reading anything of it. A step that reads an artefact says so with Step::reads, and no flow needs this.

Source

pub fn parsed( self, name: &str, path: impl Into<PathBuf>, parse: Arc<dyn Fn(&Path) -> Result<Value> + Send + Sync>, ) -> Self

Parse what the step wrote, once it completed, into path, the output name. Its judge is given the results.

Source

pub fn input(self, name: &str, path: impl Into<PathBuf>) -> Self

Source

pub fn output(self, name: &str, path: impl Into<PathBuf>) -> Self

Source

pub fn debug_output(self, name: &str, path: impl Into<PathBuf>) -> Self

Declare an output that is only kept and cached in a run with --debug. See Output::debug.

Source

pub fn artefact(&self, name: &str) -> Artefact

The step’s output name, for another step to read. Panics if the step declares no such output: a flow names its own steps’ outputs.

Source

pub fn reads(self, artefact: &Artefact) -> Self

Read an artefact of another step, which this step then runs after.

Source

pub fn precheck(self, check: Precheck) -> Self

Source

pub fn param(self, what: &str, value: impl Debug) -> Self

Key the step on something its in-process function captured. See Step::params.

Source

pub fn pattern_source(&self, output: &str) -> Option<PathBuf>

The file a pattern’s output names: a declared output, or the command’s stdout or stderr.

Source

pub fn service(self, s: Service) -> Self

Add a service. Its inputs and outputs become the step’s, named SERVICE.NAME: they are keyed, checked and cached as the step’s are, and an output is checked once the service has stopped, with the step’s own.

Source

pub fn hold(self, pool: &str, amount: u64) -> Self

Hold amount of the resource pool pool while the step runs, on top of what its invocations declare, such as memory a flow knows the step needs. A flow’s config can still change it. No flow uses this yet: their memory and disk come from config.

Source

pub fn stdout(&self) -> PathBuf

Where the command’s standard output goes: stdout.log in the step’s directory, or CHILD.stdout.log for a child that shares its unit’s.

Source

pub fn stderr(&self) -> PathBuf

Source

fn log(&self, name: &str) -> PathBuf

Source

pub fn leaves(&self) -> Vec<&Step>

The steps that run a command or a function: the step itself, or the leaves under a cache unit or a composite step.

Source

pub fn parts(&self) -> Vec<(Option<&str>, &Invocation)>

The parts of a step that runs a command, as resources are given and measured: its command, then each service, by name. None for a step that runs no command of its own.

Source

pub fn invocations(&self) -> impl Iterator<Item = &Invocation>

Every invocation the step itself runs: its command, then its services. A cache unit runs none: its children do.

Source

pub fn resources(&self, all_threads: u64) -> BTreeMap<String, u64>

What the step holds from each resource pool while it runs: the sum over its command and services, which all run at once, and what the step itself declares. all_threads is as many threads as a step can have. A step that runs in-process holds one thread.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Step

§

impl !UnwindSafe for Step

§

impl Freeze for Step

§

impl Send for Step

§

impl Sync for Step

§

impl Unpin for Step

§

impl UnsafeUnpin for Step

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.