chore: fmt
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
3939940c01
commit
80782e70f9
@ -1,14 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use dagger_sdk::Container;
|
use dagger_sdk::Container;
|
||||||
|
|
||||||
|
|
||||||
use crate::{dagger_middleware::DaggerMiddleware, MainAction, PullRequestAction};
|
use crate::{dagger_middleware::DaggerMiddleware, MainAction, PullRequestAction};
|
||||||
|
|
||||||
pub type DynMiddleware = Box<dyn DaggerMiddleware + Send + Sync>;
|
pub type DynMiddleware = Box<dyn DaggerMiddleware + Send + Sync>;
|
||||||
|
|
||||||
pub enum RustServiceStage {
|
pub enum RustServiceStage {
|
||||||
|
BeforeDeps(DynMiddleware),
|
||||||
|
AfterDeps(DynMiddleware),
|
||||||
BeforeBase(DynMiddleware),
|
BeforeBase(DynMiddleware),
|
||||||
AfterBase(DynMiddleware),
|
AfterBase(DynMiddleware),
|
||||||
BeforeRelease(DynMiddleware),
|
BeforeRelease(DynMiddleware),
|
||||||
@ -86,8 +85,6 @@ mod test {
|
|||||||
rust_service::{RustService, RustServiceStage},
|
rust_service::{RustService, RustServiceStage},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn can_build_rust() -> eyre::Result<()> {
|
async fn can_build_rust() -> eyre::Result<()> {
|
||||||
let client = dagger_sdk::connect().await?;
|
let client = dagger_sdk::connect().await?;
|
||||||
@ -95,7 +92,7 @@ mod test {
|
|||||||
RustService::from(client.clone())
|
RustService::from(client.clone())
|
||||||
.with_base_image(client.container().from("rustlang/rust:nightly"))
|
.with_base_image(client.container().from("rustlang/rust:nightly"))
|
||||||
.with_sqlx()
|
.with_sqlx()
|
||||||
.with_stage(RustServiceStage::BeforeBase(middleware(|c| async move { Ok(c) }.boxed())))
|
.with_stage(RustServiceStage::BeforeDeps(middleware(|c| async move { Ok(c) }.boxed())))
|
||||||
.build_release()
|
.build_release()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
@ -97,94 +97,87 @@ impl RustBuild {
|
|||||||
|
|
||||||
let mut containers = Vec::new();
|
let mut containers = Vec::new();
|
||||||
for container_image in images {
|
for container_image in images {
|
||||||
let container = match &container_image {
|
let container =
|
||||||
SlimImage::Debian { image, deps, .. } => {
|
match &container_image {
|
||||||
let target = BuildTarget::from_target(&container_image);
|
SlimImage::Debian { image, deps, .. } => {
|
||||||
|
let target = BuildTarget::from_target(&container_image);
|
||||||
|
|
||||||
let build_container = self
|
let build_container = self
|
||||||
.build(
|
.build(
|
||||||
source_path.clone(),
|
source_path.clone(),
|
||||||
&rust_version,
|
&rust_version,
|
||||||
|
BuildTarget::from_target(&container_image),
|
||||||
|
BuildProfile::Release,
|
||||||
|
crates,
|
||||||
|
extra_deps,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let bin = build_container
|
||||||
|
.with_env_variable("SQLX_OFFLINE", "true")
|
||||||
|
.with_exec(vec!["cargo", "clean"])
|
||||||
|
.with_exec(vec![
|
||||||
|
"cargo",
|
||||||
|
"build",
|
||||||
|
"--target",
|
||||||
|
&target.to_string(),
|
||||||
|
"--release",
|
||||||
|
"-p",
|
||||||
|
bin_name,
|
||||||
|
])
|
||||||
|
.file(format!("target/{}/release/{}", target.to_string(), bin_name));
|
||||||
|
|
||||||
|
self.build_debian_image(
|
||||||
|
bin,
|
||||||
|
image,
|
||||||
BuildTarget::from_target(&container_image),
|
BuildTarget::from_target(&container_image),
|
||||||
BuildProfile::Release,
|
deps.iter()
|
||||||
crates,
|
.map(|d| d.as_str())
|
||||||
extra_deps,
|
.collect::<Vec<&str>>()
|
||||||
)
|
.as_slice(),
|
||||||
.await?;
|
|
||||||
|
|
||||||
let bin = build_container
|
|
||||||
.with_env_variable("SQLX_OFFLINE", "true")
|
|
||||||
.with_exec(vec!["cargo", "clean"])
|
|
||||||
.with_exec(vec![
|
|
||||||
"cargo",
|
|
||||||
"build",
|
|
||||||
"--target",
|
|
||||||
&target.to_string(),
|
|
||||||
"--release",
|
|
||||||
"-p",
|
|
||||||
bin_name,
|
bin_name,
|
||||||
])
|
)
|
||||||
.file(format!(
|
.await?
|
||||||
"target/{}/release/{}",
|
}
|
||||||
target.to_string(),
|
SlimImage::Alpine { image, deps, .. } => {
|
||||||
bin_name
|
let target = BuildTarget::from_target(&container_image);
|
||||||
));
|
|
||||||
|
|
||||||
self.build_debian_image(
|
let build_container = self
|
||||||
bin,
|
.build(
|
||||||
image,
|
source_path.clone(),
|
||||||
BuildTarget::from_target(&container_image),
|
&rust_version,
|
||||||
deps.iter()
|
BuildTarget::from_target(&container_image),
|
||||||
.map(|d| d.as_str())
|
BuildProfile::Release,
|
||||||
.collect::<Vec<&str>>()
|
crates,
|
||||||
.as_slice(),
|
extra_deps,
|
||||||
bin_name,
|
)
|
||||||
)
|
.await?;
|
||||||
.await?
|
|
||||||
}
|
|
||||||
SlimImage::Alpine { image, deps, .. } => {
|
|
||||||
let target = BuildTarget::from_target(&container_image);
|
|
||||||
|
|
||||||
let build_container = self
|
let bin = build_container
|
||||||
.build(
|
.with_exec(vec![
|
||||||
source_path.clone(),
|
"cargo",
|
||||||
&rust_version,
|
"build",
|
||||||
|
"--target",
|
||||||
|
&target.to_string(),
|
||||||
|
"--release",
|
||||||
|
"-p",
|
||||||
|
bin_name,
|
||||||
|
])
|
||||||
|
.file(format!("target/{}/release/{}", target.to_string(), bin_name));
|
||||||
|
|
||||||
|
self.build_alpine_image(
|
||||||
|
bin,
|
||||||
|
image,
|
||||||
BuildTarget::from_target(&container_image),
|
BuildTarget::from_target(&container_image),
|
||||||
BuildProfile::Release,
|
deps.iter()
|
||||||
crates,
|
.map(|d| d.as_str())
|
||||||
extra_deps,
|
.collect::<Vec<&str>>()
|
||||||
)
|
.as_slice(),
|
||||||
.await?;
|
|
||||||
|
|
||||||
let bin = build_container
|
|
||||||
.with_exec(vec![
|
|
||||||
"cargo",
|
|
||||||
"build",
|
|
||||||
"--target",
|
|
||||||
&target.to_string(),
|
|
||||||
"--release",
|
|
||||||
"-p",
|
|
||||||
bin_name,
|
bin_name,
|
||||||
])
|
)
|
||||||
.file(format!(
|
.await?
|
||||||
"target/{}/release/{}",
|
}
|
||||||
target.to_string(),
|
};
|
||||||
bin_name
|
|
||||||
));
|
|
||||||
|
|
||||||
self.build_alpine_image(
|
|
||||||
bin,
|
|
||||||
image,
|
|
||||||
BuildTarget::from_target(&container_image),
|
|
||||||
deps.iter()
|
|
||||||
.map(|d| d.as_str())
|
|
||||||
.collect::<Vec<&str>>()
|
|
||||||
.as_slice(),
|
|
||||||
bin_name,
|
|
||||||
)
|
|
||||||
.await?
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
containers.push(container);
|
containers.push(container);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user