From fec9a7670f8ba9eff7b4631e7d3e5be5e8c6a82e Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 8 Nov 2024 13:59:00 +0000 Subject: [PATCH] fix: deploy requirements --- build/build/src/ci_gen/job.rs | 2 ++ build/build/src/engine.rs | 3 +++ build/build/src/engine/context.rs | 3 +++ build/build/src/release.rs | 15 ++------------- build/cli/src/lib.rs | 15 +++++++++++++++ 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/build/build/src/ci_gen/job.rs b/build/build/src/ci_gen/job.rs index b1c69a384bcb..ed543674b537 100644 --- a/build/build/src/ci_gen/job.rs +++ b/build/build/src/ci_gen/job.rs @@ -462,6 +462,7 @@ pub struct DeployYdocPolyglot; impl JobArchetype for DeployYdocPolyglot { fn job(&self, target: Target) -> Job { ecr_deploy_steps_builder("release deploy-ydoc-polyglot") + .cleaning(RELEASE_CLEANING_POLICY) .build_job("Upload polyglot Ydoc to ECR", target) } } @@ -472,6 +473,7 @@ pub struct DeployYdocNodejs; impl JobArchetype for DeployYdocNodejs { fn job(&self, target: Target) -> Job { ecr_deploy_steps_builder("release deploy-ydoc-nodejs") + .cleaning(RELEASE_CLEANING_POLICY) .build_job("Upload Node.js Ydoc to ECR", target) } } diff --git a/build/build/src/engine.rs b/build/build/src/engine.rs index c341af2b58fb..ef91b308a94a 100644 --- a/build/build/src/engine.rs +++ b/build/build/src/engine.rs @@ -199,6 +199,8 @@ pub struct BuildConfigurationFlags { pub build_engine_package: bool, /// Build the NI Engine Runner. pub build_native_runner: bool, + /// Build the Ydoc Native Image + pub build_native_ydoc: bool, /// Build the experimental Espresso+NI Engine Runner. pub build_espresso_runner: bool, pub build_launcher_package: bool, @@ -306,6 +308,7 @@ impl Default for BuildConfigurationFlags { build_engine_package: false, build_launcher_package: false, build_native_runner: false, + build_native_ydoc: false, build_espresso_runner: false, build_project_manager_package: false, build_launcher_bundle: false, diff --git a/build/build/src/engine/context.rs b/build/build/src/engine/context.rs index 42328320a7f4..3141cd8497fb 100644 --- a/build/build/src/engine/context.rs +++ b/build/build/src/engine/context.rs @@ -336,6 +336,9 @@ impl RunContext { if self.config.build_native_runner { tasks.push("engine-runner/buildNativeImage"); } + if self.config.build_native_ydoc { + tasks.push("ydoc-server/buildNativeImage"); + } if self.config.build_project_manager_package() { tasks.push("buildProjectManagerDistribution"); } diff --git a/build/build/src/release.rs b/build/build/src/release.rs index 81c0528b80a8..b0715e126947 100644 --- a/build/build/src/release.rs +++ b/build/build/src/release.rs @@ -4,7 +4,6 @@ use crate::prelude::*; use crate::changelog::Changelog; use crate::context::BuildContext; -use crate::engine; use crate::env::ENSO_ADMIN_TOKEN; use crate::paths::generated; use crate::paths::TargetTriple; @@ -17,7 +16,6 @@ use crate::version::Versions; use ide_ci::github; use ide_ci::io::web::handle_error_response; use ide_ci::programs::Docker; -use ide_ci::programs::Pnpm; use ide_ci::programs::SevenZip; use octocrab::models::repos::Release; use octocrab::params::repos::Reference; @@ -295,15 +293,9 @@ pub async fn deploy_runtime_to_ecr(context: &BuildContext, repository: String) - /// /// Builds the polyglot Ydoc image and pushes it to our ECR. pub async fn deploy_ydoc_polyglot_to_ecr(context: &BuildContext, repository: String) -> Result { - let sbt = engine::sbt::Context { - repo_root: context.repo_root.path.clone(), - system_properties: default(), - }; - sbt.call_arg("ydoc-server/buildNativeImage").await?; let client = crate::aws::ecr::client_from_env().await; let repository_uri = crate::aws::ecr::get_repository_uri(&client, &repository).await?; - let tag_name = repository_uri.replace("/runtime", "/ydoc-polyglot"); - let tag = format!("{}:{}", tag_name, context.triple.versions.version); + let tag = format!("{}/{}:{}", repository_uri, "ydoc-polyglot", context.triple.versions.version); // We don't care about the image ID, we will refer to it by the tag. let _image_id = generate_ydoc_polyglot_image(context, &tag).await?; let credentials = crate::aws::ecr::get_credentials(&client).await?; @@ -315,12 +307,9 @@ pub async fn deploy_ydoc_polyglot_to_ecr(context: &BuildContext, repository: Str /// /// Builds the Node.js Ydoc image and pushes it to our ECR. pub async fn deploy_ydoc_nodejs_to_ecr(context: &BuildContext, repository: String) -> Result { - Pnpm.cmd()?.install().run_ok().await?; - Pnpm.cmd()?.run("-r").arg("compile").run_ok().await?; let client = crate::aws::ecr::client_from_env().await; let repository_uri = crate::aws::ecr::get_repository_uri(&client, &repository).await?; - let tag_name = repository_uri.replace("/runtime", "/ydoc-nodejs"); - let tag = format!("{}:{}", tag_name, context.triple.versions.version); + let tag = format!("{}/{}:{}", repository_uri, "ydoc-nodejs", context.triple.versions.version); // We don't care about the image ID, we will refer to it by the tag. let _image_id = generate_ydoc_nodejs_image(context, &tag).await?; let credentials = crate::aws::ecr::get_credentials(&client).await?; diff --git a/build/cli/src/lib.rs b/build/cli/src/lib.rs index af5ba9b2a305..bea3ce848e23 100644 --- a/build/cli/src/lib.rs +++ b/build/cli/src/lib.rs @@ -73,6 +73,7 @@ use ide_ci::programs::git; use ide_ci::programs::git::clean; use ide_ci::programs::rustc; use ide_ci::programs::Cargo; +use ide_ci::programs::Pnpm; use octocrab::models::ReleaseId; use std::time::Duration; use tokio::process::Child; @@ -786,10 +787,24 @@ pub async fn main_internal(config: Option) -> Result { .await?; } Action::DeployYdocPolyglot(args) => { + let config = enso_build::engine::BuildConfigurationFlags { + build_native_ydoc: true, + ..default() + }; + let backend_context = ctx.prepare_backend_context(config).await?; + backend_context.build().await?; + enso_build::release::deploy_ydoc_polyglot_to_ecr(&ctx, args.ecr_repository).await?; // TODO: dispatch cloud workflow } Action::DeployYdocNodejs(args) => { + enso_build::web::install(&ctx.repo_root).await?; + Pnpm.cmd()? + .with_current_dir(&ctx.repo_root) + .run("-r") + .arg("compile") + .run_ok() + .await?; enso_build::release::deploy_ydoc_nodejs_to_ecr(&ctx, args.ecr_repository).await?; // TODO: dispatch cloud workflow }