feat: include pipeline
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-03-30 02:26:08 +01:00
parent 365b840fe9
commit b9417747a8
3 changed files with 66 additions and 67 deletions

View File

@@ -43,7 +43,7 @@ pub struct RustService {
impl From<dagger_sdk::Query> for RustService {
fn from(value: dagger_sdk::Query) -> Self {
Self {
client: value,
client: value.pipeline("rust-service"),
base_image: None,
final_image: None,
stages: Vec::new(),
@@ -168,7 +168,8 @@ impl RustService {
}
pub async fn build_base(&self) -> eyre::Result<Container> {
let rust_src = RustSource::new(self.client.clone());
let client = self.client.pipeline("build-base");
let rust_src = RustSource::new(client.pipeline("load-source"));
let (src, dep_src) = rust_src
.get_rust_src(Some(&self.get_src()), self.crates.clone())
@@ -177,7 +178,7 @@ impl RustService {
let base_image = self
.base_image
.clone()
.unwrap_or(self.client.container().from("rustlang/rust:nightly"));
.unwrap_or(client.container().from("rustlang/rust:nightly"));
let before_deps = self
.stages
@@ -209,7 +210,7 @@ impl RustService {
.collect::<Vec<_>>();
let image = self.run_stage(before_base, image).await?;
let cache = self.client.cache_volume("rust_target_cache");
let cache = client.cache_volume("rust_target_cache");
let rust_prebuild = image
.with_workdir("/mnt/src")
@@ -244,7 +245,8 @@ impl RustService {
}
pub async fn build_release(&self) -> eyre::Result<Container> {
let base = self.build_base().await?;
let base = self.build_base().await?.pipeline("build-release");
let client = self.client.pipeline("build-release");
let before_build = self
.stages
@@ -256,8 +258,6 @@ impl RustService {
.collect::<Vec<_>>();
let base = self.run_stage(before_build, base).await?;
//base.export("export.tar").await?;
let binary_build =
base.with_exec(vec!["cargo", "build", "--release", "--bin", &self.bin_name]);
@@ -274,7 +274,7 @@ impl RustService {
let dest = self
.final_image
.clone()
.unwrap_or(self.client.container().from("debian:bookworm"));
.unwrap_or(client.container().from("debian:bookworm"));
let before_package = self
.stages
@@ -305,7 +305,7 @@ impl RustService {
}
pub async fn build_test(&self) -> eyre::Result<()> {
let base = self.build_base().await?;
let base = self.build_base().await?.pipeline("build-test");
let before_build = self
.stages
@@ -358,7 +358,7 @@ impl RustServiceContext for Context {
#[async_trait]
impl MainAction for RustService {
async fn execute_main(&self, ctx: &mut Context) -> eyre::Result<()> {
let container = self.build_release().await?;
let container = self.build_release().await?.pipeline("main");
let timestamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()