From fc303f84db283952ee87946150d83f33a21d3cb5 Mon Sep 17 00:00:00 2001 From: xgreenx Date: Fri, 18 Mar 2022 09:22:03 +0200 Subject: [PATCH 1/2] Added support of `--skip--linting` flag. --- CHANGELOG.md | 3 +++ src/cmd/build.rs | 56 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e9f8e64..0d615466 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- `--skip-linting` flag that allows to skip the linting step during build process - [#466](https://github.com/paritytech/cargo-contract/pull/467) + ## [1.0.0] - 2022-03-17 ### Changed diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 3541952e..46be86a2 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -50,6 +50,7 @@ pub(crate) struct ExecuteArgs { unstable_flags: UnstableFlags, optimization_passes: OptimizationPasses, keep_debug_symbols: bool, + skip_linting: bool, output_type: OutputType, } @@ -73,6 +74,9 @@ pub struct BuildCommand { /// Build offline #[clap(long = "--offline")] build_offline: bool, + /// Skips linting checks during the build process + #[clap(long = "--skip-linting")] + skip_linting: bool, /// Which build artifacts to generate. /// /// - `all`: Generate the Wasm, the metadata and a bundled `.contract` file. @@ -176,6 +180,7 @@ impl BuildCommand { unstable_flags, optimization_passes, keep_debug_symbols: self.keep_debug_symbols, + skip_linting: self.skip_linting, output_type, }; @@ -211,6 +216,7 @@ impl CheckCommand { unstable_flags, optimization_passes: OptimizationPasses::Zero, keep_debug_symbols: false, + skip_linting: false, output_type: OutputType::default(), }; @@ -760,6 +766,7 @@ pub(crate) fn execute(args: ExecuteArgs) -> Result { unstable_flags, optimization_passes, keep_debug_symbols, + skip_linting, output_type, } = args; @@ -771,13 +778,22 @@ pub(crate) fn execute(args: ExecuteArgs) -> Result { } let build = || -> Result { - maybe_println!( - verbosity, - " {} {}", - format!("[1/{}]", build_artifact.steps()).bold(), - "Checking ink! linting rules".bright_green().bold() - ); - exec_cargo_dylint(&crate_metadata, verbosity)?; + if skip_linting { + maybe_println!( + verbosity, + " {} {}", + format!("[1/{}]", build_artifact.steps()).bold(), + "Skip ink! linting rules".bright_yellow().bold() + ); + } else { + maybe_println!( + verbosity, + " {} {}", + format!("[1/{}]", build_artifact.steps()).bold(), + "Checking ink! linting rules".bright_green().bold() + ); + exec_cargo_dylint(&crate_metadata, verbosity)?; + } maybe_println!( verbosity, @@ -816,13 +832,22 @@ pub(crate) fn execute(args: ExecuteArgs) -> Result { let (opt_result, metadata_result) = match build_artifact { BuildArtifacts::CheckOnly => { - maybe_println!( - verbosity, - " {} {}", - format!("[1/{}]", build_artifact.steps()).bold(), - "Checking ink! linting rules".bright_green().bold() - ); - exec_cargo_dylint(&crate_metadata, verbosity)?; + if skip_linting { + maybe_println!( + verbosity, + " {} {}", + format!("[1/{}]", build_artifact.steps()).bold(), + "Skip ink! linting rules".bright_yellow().bold() + ); + } else { + maybe_println!( + verbosity, + " {} {}", + format!("[1/{}]", build_artifact.steps()).bold(), + "Checking ink! linting rules".bright_green().bold() + ); + exec_cargo_dylint(&crate_metadata, verbosity)?; + } maybe_println!( verbosity, @@ -1029,6 +1054,7 @@ mod tests_ci_only { // we choose zero optimization passes as the "cli" parameter optimization_passes: Some(OptimizationPasses::Zero), keep_debug_symbols: false, + skip_linting: false, output_json: false, }; @@ -1070,6 +1096,7 @@ mod tests_ci_only { // we choose no optimization passes as the "cli" parameter optimization_passes: None, keep_debug_symbols: false, + skip_linting: false, output_json: false, }; @@ -1239,6 +1266,7 @@ mod tests_ci_only { unstable_options: UnstableOptions::default(), optimization_passes: None, keep_debug_symbols: false, + skip_linting: false, output_json: false, }; let res = cmd.exec().expect("build failed"); -- GitLab From 9825c14adf77680e7177706dadd29d3c538cb7d0 Mon Sep 17 00:00:00 2001 From: xgreenx Date: Fri, 18 Mar 2022 09:23:45 +0200 Subject: [PATCH 2/2] Correct number of PR --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d615466..027acf0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -- `--skip-linting` flag that allows to skip the linting step during build process - [#466](https://github.com/paritytech/cargo-contract/pull/467) +- `--skip-linting` flag that allows to skip the linting step during build process - [#468](https://github.com/paritytech/cargo-contract/pull/468) ## [1.0.0] - 2022-03-17 -- GitLab