mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2024-11-25 16:32:42 +01:00
refactor: move issues to actual tests and refactor
This commit is contained in:
parent
c025d17424
commit
9ba01396cb
@ -1,42 +0,0 @@
|
|||||||
#![feature(async_closure)]
|
|
||||||
|
|
||||||
use dagger_sdk::{ContainerBuildOptsBuilder, HostDirectoryOpts, QueryContainerOpts};
|
|
||||||
|
|
||||||
static DOCKER_FILES: [&str; 3] = ["Dockerfile", "Dockerfile.alpine", "Dockerfile.distroless"];
|
|
||||||
static PLATFORMS: [&str; 2] = ["linux/arm64", "linux/x86_64"];
|
|
||||||
|
|
||||||
#[tokio::main]
|
|
||||||
async fn main() -> eyre::Result<()> {
|
|
||||||
let client = dagger_sdk::connect().await?;
|
|
||||||
|
|
||||||
let context = client.host().directory_opts(
|
|
||||||
".",
|
|
||||||
HostDirectoryOpts {
|
|
||||||
exclude: Some(vec!["target", "client/node_modules", "client/build"]),
|
|
||||||
include: None,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
for file in DOCKER_FILES {
|
|
||||||
for platform in PLATFORMS {
|
|
||||||
let ref_ = client
|
|
||||||
.container_opts(QueryContainerOpts {
|
|
||||||
id: None,
|
|
||||||
platform: Some(platform.to_string().into()),
|
|
||||||
})
|
|
||||||
.build_opts(
|
|
||||||
context.id().await?,
|
|
||||||
ContainerBuildOptsBuilder::default()
|
|
||||||
.dockerfile(file)
|
|
||||||
.build()
|
|
||||||
.unwrap(),
|
|
||||||
)
|
|
||||||
.export("./test")
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
println!("published image to: {:#?}", ref_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
#![feature(async_closure)]
|
|
||||||
|
|
||||||
use dagger_sdk::{ContainerBuildOptsBuilder, HostDirectoryOpts, QueryContainerOptsBuilder};
|
|
||||||
|
|
||||||
static DOCKER_FILES: [&str; 3] = ["Dockerfile", "Dockerfile.alpine", "Dockerfile.distroless"];
|
|
||||||
static PLATFORMS: [&str; 2] = ["linux/arm64", "linux/x86_64"];
|
|
||||||
|
|
||||||
#[tokio::main]
|
|
||||||
async fn main() -> eyre::Result<()> {
|
|
||||||
let client = dagger_sdk::connect().await?;
|
|
||||||
|
|
||||||
let context = client.host().directory_opts(
|
|
||||||
".",
|
|
||||||
HostDirectoryOpts {
|
|
||||||
exclude: Some(vec!["target", "client/node_modules", "client/build"]),
|
|
||||||
include: None,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
for file in DOCKER_FILES {
|
|
||||||
for platform in PLATFORMS {
|
|
||||||
let ref_ = client
|
|
||||||
.container_opts(
|
|
||||||
QueryContainerOptsBuilder::default()
|
|
||||||
.platform(platform)
|
|
||||||
.build()
|
|
||||||
.unwrap(),
|
|
||||||
)
|
|
||||||
.build_opts(
|
|
||||||
context.id().await?,
|
|
||||||
ContainerBuildOptsBuilder::default()
|
|
||||||
.dockerfile(file)
|
|
||||||
.build()
|
|
||||||
.unwrap(),
|
|
||||||
)
|
|
||||||
.export("./test")
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
println!("published image to: {:#?}", ref_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
BIN
crates/dagger-sdk/test
Normal file
BIN
crates/dagger-sdk/test
Normal file
Binary file not shown.
63
crates/dagger-sdk/tests/issues/iss_30.rs
Normal file
63
crates/dagger-sdk/tests/issues/iss_30.rs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
use dagger_sdk::{
|
||||||
|
ContainerBuildOptsBuilder, HostDirectoryOpts, QueryContainerOpts, QueryContainerOptsBuilder,
|
||||||
|
};
|
||||||
|
|
||||||
|
static PLATFORMS: [&str; 2] = ["linux/arm64", "linux/x86_64"];
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_issue_30_alt() -> eyre::Result<()> {
|
||||||
|
let client = dagger_sdk::connect().await?;
|
||||||
|
|
||||||
|
let context = client.host().directory_opts(
|
||||||
|
".",
|
||||||
|
HostDirectoryOpts {
|
||||||
|
exclude: Some(vec!["target", "client/node_modules", "client/build"]),
|
||||||
|
include: None,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
for platform in PLATFORMS {
|
||||||
|
let ref_ = client
|
||||||
|
.container_opts(QueryContainerOpts {
|
||||||
|
id: None,
|
||||||
|
platform: Some(platform.to_string().into()),
|
||||||
|
})
|
||||||
|
.from("alpine")
|
||||||
|
.export("./test")
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
println!("published image to: {:#?}", ref_);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_issue_30() -> eyre::Result<()> {
|
||||||
|
let client = dagger_sdk::connect().await?;
|
||||||
|
|
||||||
|
let context = client.host().directory_opts(
|
||||||
|
".",
|
||||||
|
HostDirectoryOpts {
|
||||||
|
exclude: Some(vec!["target", "client/node_modules", "client/build"]),
|
||||||
|
include: None,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
for platform in PLATFORMS {
|
||||||
|
let ref_ = client
|
||||||
|
.container_opts(
|
||||||
|
QueryContainerOptsBuilder::default()
|
||||||
|
.platform(platform)
|
||||||
|
.build()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.from("alpine")
|
||||||
|
.export("./test")
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
println!("published image to: {:#?}", ref_);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
1
crates/dagger-sdk/tests/issues/mod.rs
Normal file
1
crates/dagger-sdk/tests/issues/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
mod iss_30;
|
@ -1,3 +1,5 @@
|
|||||||
|
mod issues;
|
||||||
|
|
||||||
use dagger_sdk::{connect, ContainerExecOptsBuilder};
|
use dagger_sdk::{connect, ContainerExecOptsBuilder};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user