2023-02-19 15:24:37 +01:00
|
|
|
use dagger_sdk::HostDirectoryOpts;
|
2023-02-17 15:34:18 +01:00
|
|
|
|
2023-02-19 21:37:54 +01:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> eyre::Result<()> {
|
2023-02-20 10:10:42 +01:00
|
|
|
let client = dagger_sdk::connect().await?;
|
2023-02-17 15:34:18 +01:00
|
|
|
|
2023-02-19 17:43:12 +01:00
|
|
|
let host_source_dir = client.host().directory_opts(
|
2023-02-19 17:21:40 +01:00
|
|
|
"examples/test-the-application/app",
|
2023-02-19 17:49:22 +01:00
|
|
|
HostDirectoryOpts {
|
2023-02-19 17:21:40 +01:00
|
|
|
exclude: Some(vec!["node_modules", "ci/"]),
|
2023-02-17 15:34:18 +01:00
|
|
|
include: None,
|
2023-02-19 17:49:22 +01:00
|
|
|
},
|
2023-02-17 15:34:18 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
let source = client
|
2023-02-19 17:43:12 +01:00
|
|
|
.container()
|
2023-02-19 17:21:40 +01:00
|
|
|
.from("node:16")
|
2023-02-19 21:37:54 +01:00
|
|
|
.with_mounted_directory("/src", host_source_dir.id().await?);
|
2023-02-17 15:34:18 +01:00
|
|
|
|
|
|
|
let runner = source
|
2023-02-19 17:21:40 +01:00
|
|
|
.with_workdir("/src")
|
2023-02-19 17:43:12 +01:00
|
|
|
.with_exec(vec!["npm", "install"]);
|
2023-02-17 15:34:18 +01:00
|
|
|
|
|
|
|
let out = runner
|
2023-02-19 17:43:12 +01:00
|
|
|
.with_exec(vec!["npm", "test", "--", "--watchAll=false"])
|
2023-02-25 00:01:18 +01:00
|
|
|
.stderr()
|
|
|
|
.await?;
|
2023-02-17 15:34:18 +01:00
|
|
|
|
|
|
|
println!("{}", out);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|