Skip to content

Commit

Permalink
CI: run Clippy in a separate job for several targets
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Jun 12, 2024
1 parent 79c29da commit 3b85a37
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 39 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
81 changes: 81 additions & 0 deletions .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/use_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/windows7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const TRUE: BOOLEAN = 1u8;

pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> 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::<c_void>(), chunk.len() as u32) };
if ret != TRUE {
return Err(Error::WINDOWS_RTL_GEN_RANDOM);
Expand Down

0 comments on commit 3b85a37

Please sign in to comment.