Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
@@ -7,7 +7,7 @@ use futures::{stream, StreamExt};
|
||||
|
||||
use crate::{
|
||||
dagger_middleware::{DaggerMiddleware, DynMiddleware},
|
||||
MainAction, PullRequestAction,
|
||||
Context, MainAction, PullRequestAction,
|
||||
};
|
||||
|
||||
use self::architecture::{Architecture, Os};
|
||||
@@ -325,29 +325,52 @@ impl RustService {
|
||||
|
||||
#[async_trait]
|
||||
impl PullRequestAction for RustService {
|
||||
async fn execute_pull_request(&self) -> eyre::Result<()> {
|
||||
async fn execute_pull_request(&self, _ctx: &mut Context) -> eyre::Result<()> {
|
||||
self.build_test().await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
const IMAGE_TAG: &str = "RUST_SERVICE_IMAGE_TAG";
|
||||
|
||||
pub trait RustServiceContext {
|
||||
fn set_image_tag(&mut self, tag: impl Into<String>) -> eyre::Result<()>;
|
||||
fn get_image_tag(&self) -> eyre::Result<Option<String>>;
|
||||
}
|
||||
|
||||
impl RustServiceContext for Context {
|
||||
fn get_image_tag(&self) -> eyre::Result<Option<String>> {
|
||||
Ok(self.get(IMAGE_TAG).cloned())
|
||||
}
|
||||
|
||||
fn set_image_tag(&mut self, tag: impl Into<String>) -> eyre::Result<()> {
|
||||
let tag = tag.into();
|
||||
|
||||
self.insert(IMAGE_TAG.to_string(), tag);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl MainAction for RustService {
|
||||
async fn execute_main(&self) -> eyre::Result<()> {
|
||||
async fn execute_main(&self, ctx: &mut Context) -> eyre::Result<()> {
|
||||
let container = self.build_release().await?;
|
||||
let timestamp = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs();
|
||||
|
||||
container
|
||||
let image_tag = container
|
||||
.publish(format!(
|
||||
"docker.io/kasperhermansen/{}:main-{}",
|
||||
self.bin_name, timestamp,
|
||||
))
|
||||
.await?;
|
||||
|
||||
ctx.set_image_tag(image_tag)?;
|
||||
|
||||
if self.deployment {
|
||||
let update_deployments_docker_image =
|
||||
"docker.io/kasperhermansen/update-deployment:1701123940";
|
||||
@@ -443,18 +466,14 @@ pub mod extensions {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use futures::FutureExt;
|
||||
|
||||
use crate::{
|
||||
dagger_middleware::middleware,
|
||||
rust_service::{
|
||||
apt::AptExt,
|
||||
architecture::{Architecture, Os},
|
||||
cargo_binstall::CargoBInstallExt,
|
||||
clap_sanity_test::ClapSanityTestExt,
|
||||
mold::MoldActionExt,
|
||||
RustService, RustServiceStage,
|
||||
},
|
||||
use crate::rust_service::{
|
||||
apt::AptExt,
|
||||
architecture::{Architecture, Os},
|
||||
cargo_binstall::CargoBInstallExt,
|
||||
clap_sanity_test::ClapSanityTestExt,
|
||||
mold::MoldActionExt,
|
||||
RustService,
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
|
Reference in New Issue
Block a user