diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ef63b82a08..a7f0cfb190 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,6 +1,8 @@ name: Release on: + pull_request: + branches: [main] create: tags: - v* @@ -127,7 +129,7 @@ jobs: with: target: ${{ matrix.target }} manylinux: auto - args: --release --out dist + args: --no-default-features --release --out dist maturin-version: "v0.13.0" - uses: uraimo/run-on-arch-action@v2.0.5 if: matrix.target != 'ppc64' diff --git a/Cargo.toml b/Cargo.toml index f9fb21392c..0d79ddb03b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,9 +29,13 @@ rustpython-parser = { features = ["lalrpop"], git = "https://github.com/charlier serde = { version = "1.0.143", features = ["derive"] } serde_json = { version = "1.0.83" } toml = { version = "0.5.9" } -update-informer = { version = "0.5.0", default_features = false, features = ["pypi"] } +update-informer = { version = "0.5.0", default_features = false, features = ["pypi"], optional = true } walkdir = { version = "2.3.2" } +[features] +default = ["update-informer"] +update-informer = ["dep:update-informer"] + [profile.release] panic = "abort" lto = "thin" diff --git a/src/main.rs b/src/main.rs index 7e6e6e41c9..701d589009 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,13 +12,13 @@ use rayon::prelude::*; use walkdir::DirEntry; use ::ruff::checks::CheckCode; +use ::ruff::checks::CheckKind; use ::ruff::fs::iter_python_files; use ::ruff::linter::lint_path; use ::ruff::logging::set_up_logging; use ::ruff::message::Message; use ::ruff::settings::Settings; use ::ruff::tell_user; -use ruff::checks::CheckKind; const CARGO_PKG_NAME: &str = env!("CARGO_PKG_NAME"); const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -55,6 +55,30 @@ struct Cli { ignore: Vec, } +#[cfg(feature = "update-informer")] +fn check_for_updates() { + use update_informer::{registry, Check}; + + let informer = update_informer::new(registry::PyPI, CARGO_PKG_NAME, CARGO_PKG_VERSION); + + if let Some(new_version) = informer.check_version().ok().flatten() { + let msg = format!( + "A new version of {pkg_name} is available: v{pkg_version} -> {new_version}", + pkg_name = CARGO_PKG_NAME.italic().cyan(), + pkg_version = CARGO_PKG_VERSION, + new_version = new_version.to_string().green() + ); + + let cmd = format!( + "Run to update: {cmd} {pkg_name}", + cmd = "pip3 install --upgrade".green(), + pkg_name = CARGO_PKG_NAME.green() + ); + + println!("\n{msg}\n{cmd}"); + } +} + fn run_once( files: &[PathBuf], settings: &Settings, @@ -210,6 +234,7 @@ fn inner_main() -> Result { report_once(&messages)?; } + #[cfg(feature = "update-informer")] check_for_updates(); if !messages.is_empty() && !cli.exit_zero { @@ -220,29 +245,6 @@ fn inner_main() -> Result { Ok(ExitCode::SUCCESS) } -fn check_for_updates() { - use update_informer::{registry, Check}; - - let informer = update_informer::new(registry::PyPI, CARGO_PKG_NAME, CARGO_PKG_VERSION); - - if let Some(new_version) = informer.check_version().ok().flatten() { - let msg = format!( - "A new version of {pkg_name} is available: v{pkg_version} -> {new_version}", - pkg_name = CARGO_PKG_NAME.italic().cyan(), - pkg_version = CARGO_PKG_VERSION, - new_version = new_version.to_string().green() - ); - - let cmd = format!( - "Run to update: {cmd} {pkg_name}", - cmd = "pip3 install --upgrade".green(), - pkg_name = CARGO_PKG_NAME.green() - ); - - println!("\n{msg}\n{cmd}"); - } -} - fn main() -> ExitCode { match inner_main() { Ok(code) => code,