Public dry run dryrun-1714a9eedd5b
Source commit: 1714a9eedd5b1e30c6c9aceb7a999f2f695ba83c Public tree identity: sha256:e5daffad23fa7c7f1822adccd3c3b4ee0bc7f1a45e0d321eb9a6fb8282b269db
This commit is contained in:
commit
20c72e6066
102 changed files with 32054 additions and 0 deletions
97
examples/launch-build-demo/src/build.rs
Normal file
97
examples/launch-build-demo/src/build.rs
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
use disasmer::{Artifact, EnvRef, SourceSnapshot};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct BuildReport {
|
||||
pub linux_thread: u64,
|
||||
pub package_thread: u64,
|
||||
pub linux_artifact: Artifact,
|
||||
pub package_artifact: Artifact,
|
||||
pub source: SourceSnapshot,
|
||||
}
|
||||
|
||||
pub fn linux_env() -> EnvRef {
|
||||
disasmer::env!("linux")
|
||||
}
|
||||
|
||||
pub fn windows_env() -> EnvRef {
|
||||
disasmer::env!("windows")
|
||||
}
|
||||
|
||||
#[disasmer::task]
|
||||
pub fn compile_linux() -> Artifact {
|
||||
Artifact {
|
||||
id: "artifact://linux/app.tar.zst".to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
#[disasmer::task]
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn task_add_one(input: i32) -> i32 {
|
||||
input + 1
|
||||
}
|
||||
|
||||
#[disasmer::task]
|
||||
pub fn package_release() -> Artifact {
|
||||
Artifact {
|
||||
id: "artifact://package/release.tar.zst".to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
#[disasmer::main]
|
||||
pub fn build_main() -> &'static str {
|
||||
"launch-build-demo"
|
||||
}
|
||||
|
||||
pub async fn run_build_workflow() -> BuildReport {
|
||||
let linux = disasmer::spawn::task(compile_linux)
|
||||
.name("compile linux")
|
||||
.env(linux_env())
|
||||
.start()
|
||||
.await;
|
||||
let package = disasmer::spawn::task(package_release)
|
||||
.name("package artifacts")
|
||||
.env(linux_env())
|
||||
.start()
|
||||
.await;
|
||||
|
||||
let linux_thread = linux.virtual_thread_id();
|
||||
let package_thread = package.virtual_thread_id();
|
||||
let linux_artifact = linux.join().await;
|
||||
let package_artifact = package.join().await;
|
||||
|
||||
BuildReport {
|
||||
linux_thread,
|
||||
package_thread,
|
||||
linux_artifact,
|
||||
package_artifact,
|
||||
source: SourceSnapshot {
|
||||
digest: "source://local-checkout".to_owned(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use futures_executor::block_on;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn flagship_workflow_is_rust_source_with_spawned_virtual_tasks() {
|
||||
assert_eq!(build_main(), "launch-build-demo");
|
||||
assert_eq!(task_add_one(41), 42);
|
||||
assert_eq!(linux_env().name, "linux");
|
||||
assert_eq!(windows_env().name, "windows");
|
||||
|
||||
let report = block_on(run_build_workflow());
|
||||
|
||||
assert_ne!(report.linux_thread, report.package_thread);
|
||||
assert_eq!(report.linux_artifact.id, "artifact://linux/app.tar.zst");
|
||||
assert_eq!(
|
||||
report.package_artifact.id,
|
||||
"artifact://package/release.tar.zst"
|
||||
);
|
||||
assert_eq!(report.source.digest, "source://local-checkout");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue