From 3b85a37fa5bce2672bcfd696787f7a44c486d71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Wed, 12 Jun 2024 16:43:01 +0400 Subject: [PATCH] CI: run Clippy in a separate job for several targets --- .github/workflows/tests.yml | 36 --------------- .github/workflows/workspace.yml | 81 +++++++++++++++++++++++++++++++++ src/lazy.rs | 2 +- src/use_file.rs | 2 +- src/windows.rs | 1 + src/windows7.rs | 2 +- 6 files changed, 85 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/workspace.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b40f1c6f9..e29c3ff18 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,28 +16,6 @@ env: RUSTFLAGS: "-Dwarnings" jobs: - check-doc: - name: Docs, deadlinks, minimal dependencies - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@nightly # Needed for -Z minimal-versions and doc_cfg - - name: Install precompiled cargo-deadlinks - run: | - VERSION=0.8.1 - URL="https://github.com/deadlinks/cargo-deadlinks/releases/download/${VERSION}/cargo-deadlinks-linux" - wget -O ~/.cargo/bin/cargo-deadlinks $URL - chmod +x ~/.cargo/bin/cargo-deadlinks - cargo deadlinks --version - - uses: Swatinem/rust-cache@v2 - - name: Generate Docs - env: - RUSTDOCFLAGS: --cfg docsrs - run: cargo deadlinks -- --features=custom,std - - run: | - cargo generate-lockfile -Z minimal-versions - cargo test --features=custom,std - main-tests: name: Tier 1 Test runs-on: ${{ matrix.os }} @@ -385,17 +363,3 @@ jobs: targets: riscv32i-unknown-none-elf - uses: Swatinem/rust-cache@v2 - run: cargo build --features custom --target riscv32i-unknown-none-elf - - clippy-fmt: - name: Clippy + rustfmt - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v1 - - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt, clippy - - uses: Swatinem/rust-cache@v2 - - name: clippy - run: cargo clippy --all --features=custom,std - - name: fmt - run: cargo fmt --all -- --check diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml new file mode 100644 index 000000000..e73b5ebf5 --- /dev/null +++ b/.github/workflows/workspace.yml @@ -0,0 +1,81 @@ +name: Workspace + +on: + push: + branches: master + pull_request: + branches: master + +permissions: + contents: read + +jobs: + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly-2024-06-11 + components: clippy,rust-src + - name: Linux (linux_android_with_fallback.rs) + run: cargo clippy --target x86_64-unknown-linux-gnu + - name: Linux (linux_android.rs) + run: cargo clippy --target x86_64-unknown-linux-gnu --features linux_disable_fallback + - name: macOS (getentropy.rs) + run: cargo clippy -Zbuild-std --target x86_64-apple-darwin + - name: Redox (use_file.rs) + run: cargo clippy -Zbuild-std --target x86_64-unknown-redox + - name: FreeBSD (getrandom.rs) + run: cargo clippy -Zbuild-std --target x86_64-unknown-freebsd + - name: Solaris (solaris.rs) + run: cargo clippy -Zbuild-std --target x86_64-pc-solaris + - name: NetBSD (netbsd.rs) + run: cargo clippy -Zbuild-std --target x86_64-unknown-netbsd + - name: Fuchsia (fuchsia.rs) + run: cargo clippy -Zbuild-std --target x86_64-unknown-fuchsia + - name: iOS (apple-other.rs) + run: cargo clippy -Zbuild-std --target x86_64-apple-ios + - name: WASI (wasi.rs) + run: cargo clippy -Zbuild-std --target wasm32-wasip2 + - name: Hermit (hermit.rs) + run: cargo clippy -Zbuild-std --target x86_64-unknown-hermit + # - name: VxWorks (vxworks.rs) + # run: cargo clippy -Zbuild-std --target x86_64-wrs-vxworks + - name: SOLID (solid.rs) + run: cargo clippy -Zbuild-std --target aarch64-kmc-solid_asp3 + - name: ESP-IDF (espidf.rs) + run: cargo clippy -Zbuild-std --target riscv32imc-esp-espidf + - name: Windows 7 (windows7.rs) + run: cargo clippy -Zbuild-std --target x86_64-win7-windows-msvc + - name: Windows (windows.rs) + run: cargo clippy -Zbuild-std --target x86_64-pc-windows-msvc + - name: Fortranix SGX (rdrand.rs) + run: cargo clippy -Zbuild-std --target x86_64-fortanix-unknown-sgx + - name: Web WASM (js.rs) + run: cargo clippy -Zbuild-std --target wasm32-unknown-unknown --features js + + fmt: + name: rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - uses: Swatinem/rust-cache@v2 + - name: fmt + run: cargo fmt --all -- --check + + check-doc: + name: rustdoc + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly # Needed for doc_auto_cfg + - uses: Swatinem/rust-cache@v2 + - name: Generate Docs + env: + RUSTDOCFLAGS: "-Dwarnings --cfg docsrs" + run: cargo doc --no-deps --features custom diff --git a/src/lazy.rs b/src/lazy.rs index 2b04c61db..32e726f79 100644 --- a/src/lazy.rs +++ b/src/lazy.rs @@ -26,7 +26,7 @@ pub(crate) struct LazyUsize(AtomicUsize); impl LazyUsize { // The initialization is not completed. - const UNINIT: usize = usize::max_value(); + const UNINIT: usize = usize::MAX; pub const fn new() -> Self { Self(AtomicUsize::new(Self::UNINIT)) diff --git a/src/use_file.rs b/src/use_file.rs index 36210dee9..0764766be 100644 --- a/src/use_file.rs +++ b/src/use_file.rs @@ -17,7 +17,7 @@ use core::{ /// - On AIX, /dev/urandom will "provide cryptographically secure output". /// - On Haiku and QNX Neutrino they are identical. const FILE_PATH: &[u8] = b"/dev/urandom\0"; -const FD_UNINIT: usize = usize::max_value(); +const FD_UNINIT: usize = usize::MAX; // Do not inline this when it is the fallback implementation, but don't mark it // `#[cold]` because it is hot when it is actually used. diff --git a/src/windows.rs b/src/windows.rs index e0e8049ef..e44c42926 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -18,6 +18,7 @@ //! - Requires advapi32.dll (in addition to bcryptprimitives.dll) //! - Requires using name "SystemFunction036" //! - Thin wrapper around ProcessPrng +//! //! For more information see the Windows RNG Whitepaper: https://aka.ms/win10rng use crate::Error; use core::mem::MaybeUninit; diff --git a/src/windows7.rs b/src/windows7.rs index df83c5e6b..ff8ff0e08 100644 --- a/src/windows7.rs +++ b/src/windows7.rs @@ -25,7 +25,7 @@ const TRUE: BOOLEAN = 1u8; pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { // Prevent overflow of u32 - for chunk in dest.chunks_mut(u32::max_value() as usize) { + for chunk in dest.chunks_mut(u32::MAX as usize) { let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr().cast::(), chunk.len() as u32) }; if ret != TRUE { return Err(Error::WINDOWS_RTL_GEN_RANDOM);