From dc6b9a8d62fdee896233b0c0a026171f61503559 Mon Sep 17 00:00:00 2001 From: nicoo Date: Mon, 10 Aug 2020 16:53:32 +0200 Subject: [PATCH] CI: Improve annotations (#1584) * CI: Only run rustfmt in one environment - This displays clippy warnings even when rustfmt fails. - This avoids displaying 3 copies of the same rustfmt warning as Github annotations. - Avoids duplicated work. * CI: Suppress warnings when building for the oldest toolchain version We had cases of warnings emitted due to `rustc` bugs that were fixed in non-obsolete versions. * factor: Remove a workaround for warnings on obsolete rustc --- .github/workflows/CICD.yml | 57 +++++++++++++++++++------ src/uu/factor/src/numeric/mod.rs | 1 + src/uu/factor/src/numeric/montgomery.rs | 1 - 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 281af521c..eeb11a490 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -20,6 +20,47 @@ jobs: style: name: Style runs-on: ${{ matrix.job.os }} + strategy: + fail-fast: false + matrix: + job: + - { os: ubuntu-latest , features: unix } + steps: + - uses: actions/checkout@v1 + - name: Initialize workflow variables + id: vars + shell: bash + run: | + ## VARs setup + # target-specific options + # * CARGO_FEATURES_OPTION + CARGO_FEATURES_OPTION='' ; + if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi + echo set-output name=CARGO_FEATURES_OPTION::${CARGO_FEATURES_OPTION} + echo ::set-output name=CARGO_FEATURES_OPTION::${CARGO_FEATURES_OPTION} + - name: Install `rust` toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + default: true + profile: minimal # minimal component installation (ie, no documentation) + components: rustfmt + - name: "`fmt` testing" + shell: bash + run: | + # `fmt` testing + # * convert any warnings to GHA UI annotations; ref: + S=$(cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::warning file=\1,line=\2::WARNING: \`cargo fmt\`: style violation/p" ; } + - name: "`fmt` testing of tests" + shell: bash + run: | + # `fmt` testing of tests + # * convert any warnings to GHA UI annotations; ref: + S=$(find tests -name "*.rs" -print0 | xargs -0 cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" | sed -E -n "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::warning file=\1,line=\2::WARNING: \`cargo fmt\`: style violation/p" ; } + + clippy: + name: Clippy + runs-on: ${{ matrix.job.os }} strategy: fail-fast: false matrix: @@ -46,19 +87,7 @@ jobs: toolchain: stable default: true profile: minimal # minimal component installation (ie, no documentation) - components: rustfmt, clippy - - name: "`fmt` testing" - shell: bash - run: | - # `fmt` testing - # * convert any warnings to GHA UI annotations; ref: - S=$(cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::warning file=\1,line=\2::WARNING: \`cargo fmt\`: style violation/p" ; } - - name: "`fmt` testing of tests" - shell: bash - run: | - # `fmt` testing of tests - # * convert any warnings to GHA UI annotations; ref: - S=$(find tests -name "*.rs" -print0 | xargs -0 cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" | sed -E -n "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::warning file=\1,line=\2::WARNING: \`cargo fmt\`: style violation/p" ; } + components: clippy - name: "`clippy` testing" if: success() || failure() # run regardless of prior step success/failure shell: bash @@ -115,6 +144,8 @@ jobs: with: command: test args: --features "feat_os_unix" + env: + RUSTFLAGS: '-Awarnings' build: name: Build diff --git a/src/uu/factor/src/numeric/mod.rs b/src/uu/factor/src/numeric/mod.rs index d086027b8..4a2c94cec 100644 --- a/src/uu/factor/src/numeric/mod.rs +++ b/src/uu/factor/src/numeric/mod.rs @@ -9,6 +9,7 @@ mod gcd; pub use gcd::gcd; pub(crate) mod traits; +use traits::{DoubleInt, Int, OverflowingAdd}; mod modular_inverse; pub(crate) use modular_inverse::modular_inverse; diff --git a/src/uu/factor/src/numeric/montgomery.rs b/src/uu/factor/src/numeric/montgomery.rs index 730477bb5..22fcc21a1 100644 --- a/src/uu/factor/src/numeric/montgomery.rs +++ b/src/uu/factor/src/numeric/montgomery.rs @@ -6,7 +6,6 @@ // * For the full copyright and license information, please view the LICENSE file // * that was distributed with this source code. -use super::traits::{DoubleInt, Int, OverflowingAdd}; use super::*; use num_traits::identities::{One, Zero};