Skip to content

Commit

Permalink
Defaults to non interactive mode when running on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Aug 9, 2023
1 parent b239fbd commit 06e99b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ fn run() -> Result<()> {
#[cfg(feature = "upload")]
Opt::Publish {
build,
publish,
mut publish,
debug,
no_strip,
no_sdist,
Expand All @@ -358,6 +358,7 @@ fn run() -> Result<()> {
}

let items = wheels.into_iter().map(|wheel| wheel.0).collect::<Vec<_>>();
publish.non_interactive_on_ci();

upload_ui(&items, &publish)?
}
Expand Down Expand Up @@ -402,11 +403,12 @@ fn run() -> Result<()> {
#[cfg(feature = "scaffolding")]
Opt::GenerateCI(generate_ci) => generate_ci.execute()?,
#[cfg(feature = "upload")]
Opt::Upload { publish, files } => {
Opt::Upload { mut publish, files } => {
if files.is_empty() {
eprintln!("⚠️ Warning: No files given, exiting.");
return Ok(());
}
publish.non_interactive_on_ci();

upload_ui(&files, &publish)?
}
Expand Down
8 changes: 8 additions & 0 deletions src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ pub struct PublishOpt {
impl PublishOpt {
const DEFAULT_REPOSITORY_URL: &'static str = "https://upload.pypi.org/legacy/";
const TEST_REPOSITORY_URL: &'static str = "https://test.pypi.org/legacy/";

/// Set to non interactive mode if we're running on CI
pub fn non_interactive_on_ci(&mut self) {
if env::var("CI").map(|v| v == "true").unwrap_or_default() {
eprintln!("🎛️ Running in non-interactive mode on CI");
self.non_interactive = true;
}
}
}

/// Error type for different types of errors that can happen when uploading a
Expand Down

0 comments on commit 06e99b7

Please sign in to comment.