diff --git a/packages/toolchain/toolchain/src/util/docker/build_remote.rs b/packages/toolchain/toolchain/src/util/docker/build_remote.rs index 951b2aa710..7516c78798 100644 --- a/packages/toolchain/toolchain/src/util/docker/build_remote.rs +++ b/packages/toolchain/toolchain/src/util/docker/build_remote.rs @@ -39,13 +39,13 @@ pub async fn build_remote( task.log("[Remote Build] Starting remote build process"); // Get or create CI namespace - let _ci_namespace = get_or_create_ci_namespace(ctx, task.clone()).await?; + let ci_env = get_or_create_ci_namespace(ctx, task.clone()).await?; // Get build IDs for CI manager and runner - let ci_manager_build_id = upload_ci_manager_build(ctx, task.clone()).await?; - let ci_runner_build_id = upload_ci_runner_build(ctx, task.clone()).await?; + let ci_manager_build_id = upload_ci_manager_build(ctx, task.clone(), &ci_env).await?; + let ci_runner_build_id = upload_ci_runner_build(ctx, task.clone(), &ci_env).await?; - // Get or create ci-runner actor + // Get or create ci-manager actor let (ci_runner_actor_id, ci_runner_endpoint) = get_or_create_ci_manager_actor(ctx, task.clone(), ci_manager_build_id, ci_runner_build_id) .await?; @@ -126,17 +126,26 @@ async fn get_or_create_ci_namespace( Ok(TEMPEnvironment::from(*namespace_response.namespace)) } -async fn upload_ci_manager_build(ctx: &ToolchainCtx, task: task::TaskCtx) -> Result { - upload_ci_build(ctx, task, "ci-manager", CI_MANAGER_RELEASE_URL).await +async fn upload_ci_manager_build( + ctx: &ToolchainCtx, + task: task::TaskCtx, + ci_env: &TEMPEnvironment +) -> Result { + upload_ci_build(ctx, task, ci_env, "ci-manager", CI_MANAGER_RELEASE_URL).await } -async fn upload_ci_runner_build(ctx: &ToolchainCtx, task: task::TaskCtx) -> Result { - upload_ci_build(ctx, task, "ci-runner", CI_RUNNER_RELEASE_URL).await +async fn upload_ci_runner_build( + ctx: &ToolchainCtx, + task: task::TaskCtx, + ci_env: &TEMPEnvironment +) -> Result { + upload_ci_build(ctx, task, ci_env, "ci-runner", CI_RUNNER_RELEASE_URL).await } async fn upload_ci_build( ctx: &ToolchainCtx, task: task::TaskCtx, + ci_env: &TEMPEnvironment, name: &str, url: &str, ) -> Result { @@ -145,11 +154,6 @@ async fn upload_ci_build( name )); - // Get the CI environment - let ci_env = get_ci_environment(ctx, task.clone()) - .await - .context("Failed to get CI environment")?; - // Check if build already exists with this URL tag let tags_filter = serde_json::to_string(&serde_json::json!({ "name": name, @@ -221,10 +225,6 @@ async fn upload_ci_build( Ok(push_output.build_id) } -async fn get_ci_environment(ctx: &ToolchainCtx, task: task::TaskCtx) -> Result { - get_or_create_ci_namespace(ctx, task).await -} - async fn download_file(url: &str) -> Result { let response = reqwest::get(url) .await