Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
66efb97120
commit
c8f56874d0
@ -10,9 +10,7 @@ pub struct CuddlePlease {
|
|||||||
|
|
||||||
impl CuddlePlease {
|
impl CuddlePlease {
|
||||||
pub fn new(client: dagger_sdk::Query) -> Self {
|
pub fn new(client: dagger_sdk::Query) -> Self {
|
||||||
Self {
|
Self { client }
|
||||||
client: client.pipeline("cuddle-please"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ pub struct DroneTemplater {
|
|||||||
impl DroneTemplater {
|
impl DroneTemplater {
|
||||||
pub fn new(client: dagger_sdk::Query, template: impl Into<PathBuf>) -> Self {
|
pub fn new(client: dagger_sdk::Query, template: impl Into<PathBuf>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
client: client.pipeline("drone-templater"),
|
client,
|
||||||
template: template.into(),
|
template: template.into(),
|
||||||
variables: BTreeMap::default(),
|
variables: BTreeMap::default(),
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ impl MainAction for DroneTemplater {
|
|||||||
|
|
||||||
let template_name = self.template.display().to_string();
|
let template_name = self.template.display().to_string();
|
||||||
|
|
||||||
let mut cmd = vec!["drone-templater", "upload", "--template", &template_name]
|
let cmd = vec!["drone-templater", "upload", "--template", &template_name]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|v| v.to_string())
|
.map(|v| v.to_string())
|
||||||
.chain(
|
.chain(
|
||||||
|
@ -23,7 +23,7 @@ pub struct RustLib {
|
|||||||
impl RustLib {
|
impl RustLib {
|
||||||
pub fn new(value: dagger_sdk::Query) -> Self {
|
pub fn new(value: dagger_sdk::Query) -> Self {
|
||||||
Self {
|
Self {
|
||||||
client: value.pipeline("rust-lib"),
|
client: value,
|
||||||
source: None,
|
source: None,
|
||||||
crates: Vec::new(),
|
crates: Vec::new(),
|
||||||
arch: None,
|
arch: None,
|
||||||
|
@ -43,7 +43,7 @@ pub struct RustService {
|
|||||||
impl From<dagger_sdk::Query> for RustService {
|
impl From<dagger_sdk::Query> for RustService {
|
||||||
fn from(value: dagger_sdk::Query) -> Self {
|
fn from(value: dagger_sdk::Query) -> Self {
|
||||||
Self {
|
Self {
|
||||||
client: value.pipeline("rust-service"),
|
client: value,
|
||||||
base_image: None,
|
base_image: None,
|
||||||
final_image: None,
|
final_image: None,
|
||||||
stages: Vec::new(),
|
stages: Vec::new(),
|
||||||
@ -168,8 +168,8 @@ impl RustService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn build_base(&self) -> eyre::Result<Container> {
|
pub async fn build_base(&self) -> eyre::Result<Container> {
|
||||||
let client = self.client.pipeline("build-base");
|
let client = self.client.clone();
|
||||||
let rust_src = RustSource::new(client.pipeline("load-source"));
|
let rust_src = RustSource::new(client.clone());
|
||||||
|
|
||||||
let (src, dep_src) = rust_src
|
let (src, dep_src) = rust_src
|
||||||
.get_rust_src(Some(&self.get_src()), self.crates.clone())
|
.get_rust_src(Some(&self.get_src()), self.crates.clone())
|
||||||
@ -245,8 +245,8 @@ impl RustService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn build_release(&self) -> eyre::Result<Container> {
|
pub async fn build_release(&self) -> eyre::Result<Container> {
|
||||||
let base = self.build_base().await?.pipeline("build-release");
|
let base = self.build_base().await?;
|
||||||
let client = self.client.pipeline("build-release");
|
let client = self.client.clone();
|
||||||
|
|
||||||
let before_build = self
|
let before_build = self
|
||||||
.stages
|
.stages
|
||||||
@ -305,7 +305,7 @@ impl RustService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn build_test(&self) -> eyre::Result<()> {
|
pub async fn build_test(&self) -> eyre::Result<()> {
|
||||||
let base = self.build_base().await?.pipeline("build-test");
|
let base = self.build_base().await?;
|
||||||
|
|
||||||
let before_build = self
|
let before_build = self
|
||||||
.stages
|
.stages
|
||||||
@ -330,7 +330,7 @@ impl PullRequestAction for RustService {
|
|||||||
async fn execute_pull_request(&self, ctx: &mut Context) -> eyre::Result<()> {
|
async fn execute_pull_request(&self, ctx: &mut Context) -> eyre::Result<()> {
|
||||||
self.build_test().await?;
|
self.build_test().await?;
|
||||||
|
|
||||||
let container = self.build_release().await?.pipeline("pr");
|
let container = self.build_release().await?;
|
||||||
let timestamp = std::time::SystemTime::now()
|
let timestamp = std::time::SystemTime::now()
|
||||||
.duration_since(std::time::UNIX_EPOCH)
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -372,7 +372,7 @@ impl RustServiceContext for Context {
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl MainAction for RustService {
|
impl MainAction for RustService {
|
||||||
async fn execute_main(&self, ctx: &mut Context) -> eyre::Result<()> {
|
async fn execute_main(&self, ctx: &mut Context) -> eyre::Result<()> {
|
||||||
let container = self.build_release().await?.pipeline("main");
|
let container = self.build_release().await?;
|
||||||
let timestamp = std::time::SystemTime::now()
|
let timestamp = std::time::SystemTime::now()
|
||||||
.duration_since(std::time::UNIX_EPOCH)
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -488,14 +488,7 @@ pub mod extensions {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
||||||
use crate::rust_service::{
|
|
||||||
apt::AptExt,
|
|
||||||
architecture::{Architecture, Os},
|
|
||||||
cargo_binstall::CargoBInstallExt,
|
|
||||||
clap_sanity_test::ClapSanityTestExt,
|
|
||||||
mold::MoldActionExt,
|
|
||||||
RustService,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[cfg(any(feature = "dagger", feature = "integration"))]
|
#[cfg(any(feature = "dagger", feature = "integration"))]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use dagger_sdk::{Container, ImageMediaTypes};
|
use dagger_sdk::Container;
|
||||||
|
|
||||||
use crate::dagger_middleware::DaggerMiddleware;
|
use crate::dagger_middleware::DaggerMiddleware;
|
||||||
|
|
||||||
@ -35,7 +35,8 @@ impl DaggerMiddleware for DaggerBin {
|
|||||||
install_script,
|
install_script,
|
||||||
dagger_sdk::ContainerWithFileOpts {
|
dagger_sdk::ContainerWithFileOpts {
|
||||||
owner: None,
|
owner: None,
|
||||||
permissions: Some(0755),
|
permissions: Some(0o755),
|
||||||
|
expand: None,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_env_variable("DAGGER_VERSION", &self.version)
|
.with_env_variable("DAGGER_VERSION", &self.version)
|
||||||
@ -48,7 +49,8 @@ impl DaggerMiddleware for DaggerBin {
|
|||||||
dagger_bin,
|
dagger_bin,
|
||||||
dagger_sdk::ContainerWithFileOpts {
|
dagger_sdk::ContainerWithFileOpts {
|
||||||
owner: None,
|
owner: None,
|
||||||
permissions: Some(0755),
|
permissions: Some(0o755),
|
||||||
|
expand: None,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_exec(vec!["/usr/local/bin/dagger", "version"]))
|
.with_exec(vec!["/usr/local/bin/dagger", "version"]))
|
||||||
|
@ -26,21 +26,17 @@ impl DaggerMiddleware for SshAgent {
|
|||||||
|
|
||||||
let socket = self.client.host().unix_socket(&sock_var);
|
let socket = self.client.host().unix_socket(&sock_var);
|
||||||
|
|
||||||
let home = container.env_variable("HOME").await.unwrap_or("".into());
|
|
||||||
|
|
||||||
let c = container
|
let c = container
|
||||||
.with_new_file_opts(
|
.with_new_file_opts(
|
||||||
".ssh/config".to_string(),
|
".ssh/config".to_string(),
|
||||||
ContainerWithNewFileOptsBuilder::default()
|
|
||||||
.contents(
|
|
||||||
r#"
|
r#"
|
||||||
Host *
|
Host *
|
||||||
UserKnownHostsFile=/dev/null
|
UserKnownHostsFile=/dev/null
|
||||||
StrictHostKeyChecking no
|
StrictHostKeyChecking no
|
||||||
|
|
||||||
"#,
|
"#,
|
||||||
)
|
ContainerWithNewFileOptsBuilder::default()
|
||||||
.permissions(0700_isize)
|
.permissions(0o700_isize)
|
||||||
.build()?,
|
.build()?,
|
||||||
)
|
)
|
||||||
.with_unix_socket(&sock_var, socket)
|
.with_unix_socket(&sock_var, socket)
|
||||||
|
@ -194,10 +194,7 @@ impl DaggerCuddlePlease {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.branch("main")
|
.branch("main")
|
||||||
.tree_opts(dagger_sdk::GitRefTreeOpts {
|
.tree()
|
||||||
ssh_auth_socket: Some(socket.id().await?),
|
|
||||||
ssh_known_hosts: None,
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
self.client
|
self.client
|
||||||
.git_opts(
|
.git_opts(
|
||||||
@ -288,17 +285,16 @@ impl DaggerCuddlePlease {
|
|||||||
.with_env_variable("SSH_AUTH_SOCK", "/tmp/ssh.sock")
|
.with_env_variable("SSH_AUTH_SOCK", "/tmp/ssh.sock")
|
||||||
.with_new_file_opts(
|
.with_new_file_opts(
|
||||||
"/root/.ssh/config",
|
"/root/.ssh/config",
|
||||||
dagger_sdk::ContainerWithNewFileOpts {
|
|
||||||
contents: Some(
|
|
||||||
"
|
"
|
||||||
Host *
|
Host *
|
||||||
User git
|
User git
|
||||||
StrictHostKeyChecking no
|
StrictHostKeyChecking no
|
||||||
UserKnownHostsFile /dev/null
|
UserKnownHostsFile /dev/null
|
||||||
",
|
",
|
||||||
),
|
dagger_sdk::ContainerWithNewFileOpts {
|
||||||
owner: Some("root"),
|
owner: Some("root"),
|
||||||
permissions: Some(700),
|
permissions: Some(700),
|
||||||
|
expand: None,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -203,7 +203,6 @@ impl RustBuild {
|
|||||||
let base_debian = self
|
let base_debian = self
|
||||||
.client
|
.client
|
||||||
.container_opts(dagger_sdk::QueryContainerOpts {
|
.container_opts(dagger_sdk::QueryContainerOpts {
|
||||||
id: None,
|
|
||||||
platform: Some(target.into_platform()),
|
platform: Some(target.into_platform()),
|
||||||
})
|
})
|
||||||
.from(image);
|
.from(image);
|
||||||
@ -234,7 +233,6 @@ impl RustBuild {
|
|||||||
let base_debian = self
|
let base_debian = self
|
||||||
.client
|
.client
|
||||||
.container_opts(dagger_sdk::QueryContainerOpts {
|
.container_opts(dagger_sdk::QueryContainerOpts {
|
||||||
id: None,
|
|
||||||
platform: Some(target.into_platform()),
|
platform: Some(target.into_platform()),
|
||||||
})
|
})
|
||||||
.from(image);
|
.from(image);
|
||||||
|
@ -200,7 +200,6 @@ impl HtmxBuild {
|
|||||||
let base_debian = self
|
let base_debian = self
|
||||||
.client
|
.client
|
||||||
.container_opts(dagger_sdk::QueryContainerOpts {
|
.container_opts(dagger_sdk::QueryContainerOpts {
|
||||||
id: None,
|
|
||||||
platform: Some(target.into_platform()),
|
platform: Some(target.into_platform()),
|
||||||
})
|
})
|
||||||
.from(image);
|
.from(image);
|
||||||
@ -250,7 +249,6 @@ impl HtmxBuild {
|
|||||||
let base_debian = self
|
let base_debian = self
|
||||||
.client
|
.client
|
||||||
.container_opts(dagger_sdk::QueryContainerOpts {
|
.container_opts(dagger_sdk::QueryContainerOpts {
|
||||||
id: None,
|
|
||||||
platform: Some(target.into_platform()),
|
platform: Some(target.into_platform()),
|
||||||
})
|
})
|
||||||
.from(image);
|
.from(image);
|
||||||
|
@ -187,7 +187,6 @@ impl LeptosBuild {
|
|||||||
let base_debian = self
|
let base_debian = self
|
||||||
.client
|
.client
|
||||||
.container_opts(dagger_sdk::QueryContainerOpts {
|
.container_opts(dagger_sdk::QueryContainerOpts {
|
||||||
id: None,
|
|
||||||
platform: Some(target.into_platform()),
|
platform: Some(target.into_platform()),
|
||||||
})
|
})
|
||||||
.from(image);
|
.from(image);
|
||||||
@ -237,7 +236,6 @@ impl LeptosBuild {
|
|||||||
let base_debian = self
|
let base_debian = self
|
||||||
.client
|
.client
|
||||||
.container_opts(dagger_sdk::QueryContainerOpts {
|
.container_opts(dagger_sdk::QueryContainerOpts {
|
||||||
id: None,
|
|
||||||
platform: Some(target.into_platform()),
|
platform: Some(target.into_platform()),
|
||||||
})
|
})
|
||||||
.from(image);
|
.from(image);
|
||||||
|
Loading…
Reference in New Issue
Block a user