refactor: move issues to actual tests and refactor

This commit is contained in:
Kasper Juul Hermansen 2023-03-13 20:44:56 +01:00
parent 471caf276b
commit 1f26415759
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
6 changed files with 66 additions and 86 deletions

View File

@ -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(())
}

View File

@ -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

Binary file not shown.

View 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(())
}

View File

@ -0,0 +1 @@
mod iss_30;

View File

@ -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;