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
This commit is contained in:
nicoo 2020-08-10 16:53:32 +02:00 committed by GitHub
parent b0ac07296f
commit dc6b9a8d62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 14 deletions

View file

@ -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: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
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: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
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: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
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: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
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

View file

@ -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;

View file

@ -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};