feat: with updated dagger-sdk
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
@@ -4,12 +4,12 @@ use crate::source::RustSource;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct RustBuild {
|
||||
client: Arc<dagger_sdk::Query>,
|
||||
client: dagger_sdk::Query,
|
||||
registry: Option<String>,
|
||||
}
|
||||
|
||||
impl RustBuild {
|
||||
pub fn new(client: Arc<dagger_sdk::Query>) -> Self {
|
||||
pub fn new(client: dagger_sdk::Query) -> Self {
|
||||
Self {
|
||||
client,
|
||||
registry: None,
|
||||
@@ -60,9 +60,9 @@ impl RustBuild {
|
||||
}
|
||||
let rust_prebuild = rust_build_image
|
||||
.with_workdir("/mnt/src")
|
||||
.with_directory("/mnt/src", dep_src.id().await?)
|
||||
.with_directory("/mnt/src", dep_src)
|
||||
.with_exec(build_options)
|
||||
.with_mounted_cache("/mnt/src/target/", target_cache.id().await?);
|
||||
.with_mounted_cache("/mnt/src/target/", target_cache);
|
||||
|
||||
let incremental_dir = rust_source
|
||||
.get_rust_target_src(&source, rust_prebuild.clone(), crates.to_vec())
|
||||
@@ -72,10 +72,10 @@ impl RustBuild {
|
||||
.with_workdir("/mnt/src")
|
||||
.with_directory(
|
||||
"/usr/local/cargo",
|
||||
rust_prebuild.directory("/usr/local/cargo").id().await?,
|
||||
rust_prebuild.directory("/usr/local/cargo"),
|
||||
)
|
||||
.with_directory("/mnt/src/target", incremental_dir.id().await?)
|
||||
.with_directory("/mnt/src/", src.id().await?);
|
||||
.with_directory("/mnt/src/target", incremental_dir)
|
||||
.with_directory("/mnt/src/", src);
|
||||
|
||||
Ok(rust_with_src)
|
||||
}
|
||||
@@ -210,10 +210,10 @@ impl RustBuild {
|
||||
.with_exec(packages);
|
||||
|
||||
let final_image = base_debian
|
||||
.with_file(format!("/usr/local/bin/{}", bin_name), bin.id().await?)
|
||||
.with_file(format!("/usr/local/bin/{}", bin_name), bin)
|
||||
.with_exec(vec![bin_name, "--help"]);
|
||||
|
||||
final_image.exit_code().await?;
|
||||
final_image.sync().await?;
|
||||
|
||||
Ok(final_image)
|
||||
}
|
||||
@@ -238,8 +238,7 @@ impl RustBuild {
|
||||
packages.extend_from_slice(production_deps);
|
||||
let base_debian = base_debian.with_exec(packages);
|
||||
|
||||
let final_image =
|
||||
base_debian.with_file(format!("/usr/local/bin/{}", bin_name), bin.id().await?);
|
||||
let final_image = base_debian.with_file(format!("/usr/local/bin/{}", bin_name), bin);
|
||||
|
||||
Ok(final_image)
|
||||
}
|
||||
|
@@ -28,6 +28,8 @@ impl RustPublish {
|
||||
format!("{}:{}", image.into(), tag.into()),
|
||||
dagger_sdk::ContainerPublishOpts {
|
||||
platform_variants: Some(ids),
|
||||
forced_compression: None,
|
||||
media_types: None,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
@@ -6,13 +6,13 @@ use std::{
|
||||
use eyre::Context;
|
||||
|
||||
pub struct RustSource {
|
||||
client: Arc<dagger_sdk::Query>,
|
||||
client: dagger_sdk::Query,
|
||||
|
||||
exclude: Vec<String>,
|
||||
}
|
||||
|
||||
impl RustSource {
|
||||
pub fn new(client: Arc<dagger_sdk::Query>) -> Self {
|
||||
pub fn new(client: dagger_sdk::Query) -> Self {
|
||||
Self {
|
||||
client,
|
||||
exclude: vec!["node_modules/", ".git/", "target/", ".cuddle/"]
|
||||
@@ -63,7 +63,7 @@ impl RustSource {
|
||||
|
||||
let src = self.get_src(source.clone()).await?;
|
||||
let rust_src = self.get_rust_dep_src(source).await?;
|
||||
let rust_src = rust_src.with_directory(".", skeleton_files.id().await?);
|
||||
let rust_src = rust_src.with_directory(".", skeleton_files);
|
||||
|
||||
Ok((src, rust_src))
|
||||
}
|
||||
@@ -119,7 +119,7 @@ impl RustSource {
|
||||
|
||||
let incremental_dir = self.client.directory().with_directory_opts(
|
||||
".",
|
||||
container.directory("target").id().await?,
|
||||
container.directory("target"),
|
||||
dagger_sdk::DirectoryWithDirectoryOpts {
|
||||
exclude: Some(exclude),
|
||||
include: None,
|
||||
|
@@ -3,12 +3,12 @@ use std::{path::PathBuf, sync::Arc};
|
||||
use crate::{build::RustVersion, source::RustSource};
|
||||
|
||||
pub struct RustTest {
|
||||
client: Arc<dagger_sdk::Query>,
|
||||
client: dagger_sdk::Query,
|
||||
registry: Option<String>,
|
||||
}
|
||||
|
||||
impl RustTest {
|
||||
pub fn new(client: Arc<dagger_sdk::Query>) -> Self {
|
||||
pub fn new(client: dagger_sdk::Query) -> Self {
|
||||
Self {
|
||||
client,
|
||||
registry: None,
|
||||
@@ -45,9 +45,9 @@ impl RustTest {
|
||||
let build_options = vec!["cargo", "build", "--workspace"];
|
||||
let rust_prebuild = rust_build_image
|
||||
.with_workdir("/mnt/src")
|
||||
.with_directory("/mnt/src", dep_src.id().await?)
|
||||
.with_directory("/mnt/src", dep_src)
|
||||
.with_exec(build_options)
|
||||
.with_mounted_cache("/mnt/src/target/", target_cache.id().await?);
|
||||
.with_mounted_cache("/mnt/src/target/", target_cache);
|
||||
|
||||
let incremental_dir = rust_source
|
||||
.get_rust_target_src(&source, rust_prebuild.clone(), crates.to_vec())
|
||||
@@ -57,10 +57,10 @@ impl RustTest {
|
||||
.with_workdir("/mnt/src")
|
||||
.with_directory(
|
||||
"/usr/local/cargo",
|
||||
rust_prebuild.directory("/usr/local/cargo").id().await?,
|
||||
rust_prebuild.directory("/usr/local/cargo"),
|
||||
)
|
||||
.with_directory("/mnt/src/target", incremental_dir.id().await?)
|
||||
.with_directory("/mnt/src/", src.id().await?);
|
||||
.with_directory("/mnt/src/target", incremental_dir)
|
||||
.with_directory("/mnt/src/", src);
|
||||
|
||||
let test = rust_with_src.with_exec(vec!["cargo", "test"]);
|
||||
|
||||
@@ -68,9 +68,7 @@ impl RustTest {
|
||||
let stderr = test.stderr().await?;
|
||||
println!("stdout: {}, stderr: {}", stdout, stderr);
|
||||
|
||||
if 0 != test.exit_code().await? {
|
||||
eyre::bail!("failed rust:test");
|
||||
}
|
||||
test.sync().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user