Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
chore: temporarily fix tag patching (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Dec 1, 2024
1 parent 0545d90 commit 59c6e2f
Showing 1 changed file with 84 additions and 25 deletions.
109 changes: 84 additions & 25 deletions packages/toolchain/src/tasks/deploy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ impl task::Task for Task {

ensure!(!build_ids.is_empty(), "No builds matched build tags");

task.log("");
task.log("[Deploy Finished]");

Ok(Output { build_ids })
Expand Down Expand Up @@ -106,16 +105,16 @@ async fn build_and_upload(
//
// Indicates the latest build to use for this environment. Used if not providing a client-side
// version.
let mut tags = HashMap::from([
(build::tags::VERSION.to_string(), version_name.to_string()),
(build::tags::CURRENT.to_string(), "true".to_string()),
]);
tags.extend(build.tags.clone());
// let mut tags = HashMap::from([
// (build::tags::VERSION.to_string(), version_name.to_string()),
// (build::tags::CURRENT.to_string(), "true".to_string()),
// ]);
// tags.extend(build.tags.clone());

let exclusive_tags = vec![
build::tags::VERSION.to_string(),
build::tags::CURRENT.to_string(),
];
// let exclusive_tags = vec![
// build::tags::VERSION.to_string(),
// build::tags::CURRENT.to_string(),
// ];

// Build & upload
let build_id = match &build.runtime {
Expand Down Expand Up @@ -146,24 +145,84 @@ async fn build_and_upload(
}
};

// Tag build
let complete_res = apis::actor_builds_api::actor_builds_patch_tags(
&ctx.openapi_config_cloud,
&build_id.to_string(),
models::ActorPatchBuildTagsRequest {
tags: Some(serde_json::to_value(&tags)?),
exclusive_tags: Some(exclusive_tags.clone()),
},
Some(&ctx.project.name_id),
Some(&env.slug),
)
.await;
if let Err(err) = complete_res.as_ref() {
task.log(format!("{err:?}"));
// // Tag build
// let complete_res = apis::actor_builds_api::actor_builds_patch_tags(
// &ctx.openapi_config_cloud,
// &build_id.to_string(),
// models::ActorPatchBuildTagsRequest {
// tags: Some(serde_json::to_value(&tags)?),
// exclusive_tags: Some(exclusive_tags.clone()),
// },
// Some(&ctx.project.name_id),
// Some(&env.slug),
// )
// .await;
// if let Err(err) = complete_res.as_ref() {
// task.log(format!("{err:?}"));
// }
// complete_res.context("complete_res")?;

// HACK: Multiple exclusive tags doesn't work atm
{
let complete_res = apis::actor_builds_api::actor_builds_patch_tags(
&ctx.openapi_config_cloud,
&build_id.to_string(),
models::ActorPatchBuildTagsRequest {
tags: Some(serde_json::to_value(&build.tags)?),
exclusive_tags: None,
},
Some(&ctx.project.name_id),
Some(&env.slug),
)
.await;
if let Err(err) = complete_res.as_ref() {
task.log(format!("{err:?}"));
}
complete_res.context("complete_res")?;

let complete_res = apis::actor_builds_api::actor_builds_patch_tags(
&ctx.openapi_config_cloud,
&build_id.to_string(),
models::ActorPatchBuildTagsRequest {
tags: Some(serde_json::to_value(&HashMap::from([(
build::tags::CURRENT.to_string(),
"true".to_string(),
)]))?),
exclusive_tags: Some(vec![build::tags::CURRENT.to_string()]),
},
Some(&ctx.project.name_id),
Some(&env.slug),
)
.await;
if let Err(err) = complete_res.as_ref() {
task.log(format!("{err:?}"));
}
complete_res.context("complete_res")?;

let complete_res = apis::actor_builds_api::actor_builds_patch_tags(
&ctx.openapi_config_cloud,
&build_id.to_string(),
models::ActorPatchBuildTagsRequest {
tags: Some(serde_json::to_value(&HashMap::from([(
build::tags::VERSION.to_string(),
version_name.to_string(),
)]))?),
// TODO: This does not behave correctly atm
exclusive_tags: None,
// exclusive_tags: Some(vec![build::tags::VERSION.to_string()]),
},
Some(&ctx.project.name_id),
Some(&env.slug),
)
.await;
if let Err(err) = complete_res.as_ref() {
task.log(format!("{err:?}"));
}
complete_res.context("complete_res")?;
}
complete_res.context("complete_res")?;

task.log(format!("[Build Finished] {build_id}"));
task.log("");

Ok(build_id)
}

0 comments on commit 59c6e2f

Please sign in to comment.