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

Defaults to non interactive mode when running on CI #1723

Merged
merged 1 commit into from
Aug 9, 2023
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
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