2023-02-19 15:24:37 +01:00
|
|
|
use dagger_sdk::HostDirectoryOpts;
|
2023-02-17 15:34:18 +01:00
|
|
|
|
|
|
|
fn main() -> eyre::Result<()> {
|
2023-02-19 15:24:37 +01:00
|
|
|
let client = dagger_sdk::connect()?;
|
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-17 15:34:18 +01:00
|
|
|
Some(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,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
|
|
|
|
let source = client
|
2023-02-19 17:43:12 +01:00
|
|
|
.container()
|
2023-02-19 17:21:40 +01:00
|
|
|
.from("node:16")
|
|
|
|
.with_mounted_directory("/src", host_source_dir.id()?);
|
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-19 15:18:25 +01:00
|
|
|
.stderr()?;
|
2023-02-17 15:34:18 +01:00
|
|
|
|
|
|
|
println!("{}", out);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|