Public release release-09ca780bd67a
Source commit: 09ca780bd67a00467e78139cf38466b8201b66ca Public tree identity: sha256:2f744c260b5fc2cf074ad9129f97f87f03714902e5b9fe174128afdc342ec2d0
This commit is contained in:
commit
eb1077f380
221 changed files with 81144 additions and 0 deletions
45
examples/recovery-build/src/lib.rs
Normal file
45
examples/recovery-build/src/lib.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
use clusterflux::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, clusterflux::TaskArg)]
|
||||
pub struct BuildInput {
|
||||
lane: String,
|
||||
source: SourceSnapshot,
|
||||
}
|
||||
|
||||
#[clusterflux::task(capabilities = "command")]
|
||||
pub async fn build_lane(input: BuildInput) -> Result<Artifact> {
|
||||
let source_root = input.source.mount()?;
|
||||
let output = fs::output(format!("{}.txt", input.lane))?;
|
||||
let command = if input.lane == "recovering" {
|
||||
"exit 23".to_owned()
|
||||
} else {
|
||||
format!("sleep 3; printf 'stable\n' > {}", output.as_str())
|
||||
};
|
||||
Command::new("sh")
|
||||
.args(["-c", command.as_str()])
|
||||
.cwd(source_root)
|
||||
.network_disabled()
|
||||
.run()
|
||||
.await?;
|
||||
fs::publish(&output).await
|
||||
}
|
||||
|
||||
#[clusterflux::main]
|
||||
pub async fn build() -> Result<Vec<Artifact>> {
|
||||
let source = source::current_project().snapshot().await?;
|
||||
let stable = clusterflux::spawn!(build_lane(BuildInput {
|
||||
lane: "stable".to_owned(),
|
||||
source: source.clone(),
|
||||
}))
|
||||
.on(clusterflux::env!("linux"))
|
||||
.await?;
|
||||
let recovering = clusterflux::spawn!(build_lane(BuildInput {
|
||||
lane: "recovering".to_owned(),
|
||||
source,
|
||||
}))
|
||||
.on(clusterflux::env!("linux"))
|
||||
.failure_policy(clusterflux::TaskFailurePolicy::AwaitOperator)
|
||||
.await?;
|
||||
Ok(vec![stable.join().await?, recovering.join().await?])
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue