Skip to content

Commit

Permalink
Make delay between crate publishes configurable and reduce default (#…
Browse files Browse the repository at this point in the history
…3290)

This change reduces the time delay between crate publishes from 5
seconds down to 1, and makes it configurable in case this leads to
release issues.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
  • Loading branch information
jdisanti authored Dec 7, 2023
1 parent 82b190c commit 2c993e5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tools/ci-build/publisher/src/subcommand/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use std::path::{Path, PathBuf};
use std::time::Duration;
use tracing::info;

const DEFAULT_DELAY_MILLIS: usize = 1000;

#[derive(Parser, Debug)]
pub struct PublishArgs {
/// Path containing the crates to publish. Crates will be discovered recursively
Expand All @@ -32,18 +34,24 @@ pub struct PublishArgs {
/// Don't prompt for confirmation before publishing
#[clap(short('y'))]
skip_confirmation: bool,

/// Time delay between crate publishes to avoid crates.io throttling errors.
#[clap(long)]
delay_millis: Option<usize>,
}

pub async fn subcommand_publish(
PublishArgs {
location,
skip_confirmation,
delay_millis,
}: &PublishArgs,
) -> Result<()> {
// Make sure cargo exists
cargo::confirm_installed_on_path()?;

let location = resolve_publish_location(location);
let delay_millis = Duration::from_millis(delay_millis.unwrap_or(DEFAULT_DELAY_MILLIS) as _);

info!("Discovering crates to publish...");
let (batches, stats) = discover_and_validate_package_batches(Fs::Real, &location).await?;
Expand All @@ -60,7 +68,7 @@ pub async fn subcommand_publish(
publish(&package.handle, &package.crate_path).await?;

// Keep things slow to avoid getting throttled by crates.io
tokio::time::sleep(Duration::from_secs(5)).await;
tokio::time::sleep(delay_millis).await;

// Sometimes it takes a little bit of time for the new package version
// to become available after publish. If we proceed too quickly, then
Expand Down

0 comments on commit 2c993e5

Please sign in to comment.