Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): Actively wait for packages only after tag #4734

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/backend-api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ mod queries {
#[derive(cynic::QueryFragment, Debug)]
pub struct TagPackageReleasePayload {
pub success: bool,
pub package_version: Option<PackageVersion>,
}

#[derive(cynic::InputObject, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/commands/package/common/wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub async fn wait_package(
state.bindings = false
}
wasmer_registry::subscriptions::PackageVersionState::NATIVE_EXES_GENERATED => {
state.native_executables = true
state.native_executables = false
}
wasmer_registry::subscriptions::PackageVersionState::Other(_) => {}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/commands/package/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ impl PackagePublish {
package_namespace: self.package_namespace.clone(),
timeout: self.timeout,
non_interactive: self.non_interactive,
wait: self.wait,
package_path: self.package_path.clone(),
};

push_cmd.push(client, manifest, manifest_path).await?
};

PackageTag {
wait: self.wait,
api: self.api.clone(),
env: self.env.clone(),
dry_run: self.dry_run,
Expand Down
16 changes: 2 additions & 14 deletions lib/cli/src/commands/package/push.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::common::{macros::*, wait::*, *};
use super::common::{macros::*, *};
use crate::{
commands::{AsyncCliCommand, PackageBuild},
opts::{ApiOpts, WasmerEnv},
Expand Down Expand Up @@ -46,17 +46,6 @@ pub struct PackagePush {
#[clap(long, default_value_t = !std::io::stdin().is_terminal())]
pub non_interactive: bool,

/// Wait for package to be available on the registry before exiting.
#[clap(
long,
require_equals = true,
num_args = 0..=1,
default_value_t = PublishWait::None,
default_missing_value = "container",
value_enum
)]
pub wait: PublishWait,

/// Directory containing the `wasmer.toml`, or a custom *.toml manifest file.
///
/// Defaults to current working directory.
Expand Down Expand Up @@ -124,7 +113,7 @@ impl PackagePush {
spinner_ok!(pb, "Package correctly uploaded");

let pb = make_spinner!(self.quiet, "Waiting for package to become available...");
let id = match wasmer_api::query::push_package_release(
match wasmer_api::query::push_package_release(
client,
None,
namespace,
Expand All @@ -143,7 +132,6 @@ impl PackagePush {
None => anyhow::bail!("An unidentified error occurred while publishing the package."), // <- This is extremely bad..
};

wait_package(client, self.wait, id, self.timeout).await?;
let msg = format!("Succesfully pushed release to namespace {namespace} on the registry");
spinner_ok!(pb, msg);

Expand Down
18 changes: 17 additions & 1 deletion lib/cli/src/commands/package/tag.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
commands::{
package::common::{macros::*, *},
package::common::{macros::*, wait::wait_package, *},
AsyncCliCommand,
},
opts::{ApiOpts, WasmerEnv},
Expand All @@ -16,6 +16,8 @@ use std::{
use wasmer_api::WasmerClient;
use wasmer_config::package::{Manifest, NamedPackageId, PackageBuilder, PackageHash, PackageIdent};

use super::PublishWait;

/// Tag an existing package.
#[derive(Debug, clap::Parser)]
pub struct PackageTag {
Expand Down Expand Up @@ -70,6 +72,17 @@ pub struct PackageTag {
/// Defaults to current working directory.
#[clap(name = "path", default_value = ".")]
pub package_path: PathBuf,

/// Wait for package to be available on the registry before exiting.
#[clap(
long,
require_equals = true,
num_args = 0..=1,
default_value_t = PublishWait::None,
default_missing_value = "container",
value_enum
)]
pub wait: PublishWait,
}

impl PackageTag {
Expand Down Expand Up @@ -185,6 +198,9 @@ impl PackageTag {
Some(r) => {
if r.success {
spinner_ok!(pb, format!("Successfully tagged package {id}",));
if let Some(package_version) = r.package_version {
wait_package(client, self.wait, package_version.id, self.timeout).await?;
}
Ok(())
} else {
spinner_err!(pb, "Could not tag package!");
Expand Down
Loading