Skip to content

Commit 3b85a37

Browse files
committed
CI: run Clippy in a separate job for several targets
1 parent 79c29da commit 3b85a37

File tree

6 files changed

+85
-39
lines changed

6 files changed

+85
-39
lines changed

.github/workflows/tests.yml

-36
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,6 @@ env:
1616
RUSTFLAGS: "-Dwarnings"
1717

1818
jobs:
19-
check-doc:
20-
name: Docs, deadlinks, minimal dependencies
21-
runs-on: ubuntu-22.04
22-
steps:
23-
- uses: actions/checkout@v3
24-
- uses: dtolnay/rust-toolchain@nightly # Needed for -Z minimal-versions and doc_cfg
25-
- name: Install precompiled cargo-deadlinks
26-
run: |
27-
VERSION=0.8.1
28-
URL="https://github.com/deadlinks/cargo-deadlinks/releases/download/${VERSION}/cargo-deadlinks-linux"
29-
wget -O ~/.cargo/bin/cargo-deadlinks $URL
30-
chmod +x ~/.cargo/bin/cargo-deadlinks
31-
cargo deadlinks --version
32-
- uses: Swatinem/rust-cache@v2
33-
- name: Generate Docs
34-
env:
35-
RUSTDOCFLAGS: --cfg docsrs
36-
run: cargo deadlinks -- --features=custom,std
37-
- run: |
38-
cargo generate-lockfile -Z minimal-versions
39-
cargo test --features=custom,std
40-
4119
main-tests:
4220
name: Tier 1 Test
4321
runs-on: ${{ matrix.os }}
@@ -385,17 +363,3 @@ jobs:
385363
targets: riscv32i-unknown-none-elf
386364
- uses: Swatinem/rust-cache@v2
387365
- run: cargo build --features custom --target riscv32i-unknown-none-elf
388-
389-
clippy-fmt:
390-
name: Clippy + rustfmt
391-
runs-on: ubuntu-22.04
392-
steps:
393-
- uses: actions/checkout@v1
394-
- uses: dtolnay/rust-toolchain@stable
395-
with:
396-
components: rustfmt, clippy
397-
- uses: Swatinem/rust-cache@v2
398-
- name: clippy
399-
run: cargo clippy --all --features=custom,std
400-
- name: fmt
401-
run: cargo fmt --all -- --check

.github/workflows/workspace.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Workspace
2+
3+
on:
4+
push:
5+
branches: master
6+
pull_request:
7+
branches: master
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
clippy:
14+
name: Clippy
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: dtolnay/rust-toolchain@master
19+
with:
20+
toolchain: nightly-2024-06-11
21+
components: clippy,rust-src
22+
- name: Linux (linux_android_with_fallback.rs)
23+
run: cargo clippy --target x86_64-unknown-linux-gnu
24+
- name: Linux (linux_android.rs)
25+
run: cargo clippy --target x86_64-unknown-linux-gnu --features linux_disable_fallback
26+
- name: macOS (getentropy.rs)
27+
run: cargo clippy -Zbuild-std --target x86_64-apple-darwin
28+
- name: Redox (use_file.rs)
29+
run: cargo clippy -Zbuild-std --target x86_64-unknown-redox
30+
- name: FreeBSD (getrandom.rs)
31+
run: cargo clippy -Zbuild-std --target x86_64-unknown-freebsd
32+
- name: Solaris (solaris.rs)
33+
run: cargo clippy -Zbuild-std --target x86_64-pc-solaris
34+
- name: NetBSD (netbsd.rs)
35+
run: cargo clippy -Zbuild-std --target x86_64-unknown-netbsd
36+
- name: Fuchsia (fuchsia.rs)
37+
run: cargo clippy -Zbuild-std --target x86_64-unknown-fuchsia
38+
- name: iOS (apple-other.rs)
39+
run: cargo clippy -Zbuild-std --target x86_64-apple-ios
40+
- name: WASI (wasi.rs)
41+
run: cargo clippy -Zbuild-std --target wasm32-wasip2
42+
- name: Hermit (hermit.rs)
43+
run: cargo clippy -Zbuild-std --target x86_64-unknown-hermit
44+
# - name: VxWorks (vxworks.rs)
45+
# run: cargo clippy -Zbuild-std --target x86_64-wrs-vxworks
46+
- name: SOLID (solid.rs)
47+
run: cargo clippy -Zbuild-std --target aarch64-kmc-solid_asp3
48+
- name: ESP-IDF (espidf.rs)
49+
run: cargo clippy -Zbuild-std --target riscv32imc-esp-espidf
50+
- name: Windows 7 (windows7.rs)
51+
run: cargo clippy -Zbuild-std --target x86_64-win7-windows-msvc
52+
- name: Windows (windows.rs)
53+
run: cargo clippy -Zbuild-std --target x86_64-pc-windows-msvc
54+
- name: Fortranix SGX (rdrand.rs)
55+
run: cargo clippy -Zbuild-std --target x86_64-fortanix-unknown-sgx
56+
- name: Web WASM (js.rs)
57+
run: cargo clippy -Zbuild-std --target wasm32-unknown-unknown --features js
58+
59+
fmt:
60+
name: rustfmt
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v1
64+
- uses: dtolnay/rust-toolchain@stable
65+
with:
66+
components: rustfmt
67+
- uses: Swatinem/rust-cache@v2
68+
- name: fmt
69+
run: cargo fmt --all -- --check
70+
71+
check-doc:
72+
name: rustdoc
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v3
76+
- uses: dtolnay/rust-toolchain@nightly # Needed for doc_auto_cfg
77+
- uses: Swatinem/rust-cache@v2
78+
- name: Generate Docs
79+
env:
80+
RUSTDOCFLAGS: "-Dwarnings --cfg docsrs"
81+
run: cargo doc --no-deps --features custom

src/lazy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(crate) struct LazyUsize(AtomicUsize);
2626

2727
impl LazyUsize {
2828
// The initialization is not completed.
29-
const UNINIT: usize = usize::max_value();
29+
const UNINIT: usize = usize::MAX;
3030

3131
pub const fn new() -> Self {
3232
Self(AtomicUsize::new(Self::UNINIT))

src/use_file.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use core::{
1717
/// - On AIX, /dev/urandom will "provide cryptographically secure output".
1818
/// - On Haiku and QNX Neutrino they are identical.
1919
const FILE_PATH: &[u8] = b"/dev/urandom\0";
20-
const FD_UNINIT: usize = usize::max_value();
20+
const FD_UNINIT: usize = usize::MAX;
2121

2222
// Do not inline this when it is the fallback implementation, but don't mark it
2323
// `#[cold]` because it is hot when it is actually used.

src/windows.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//! - Requires advapi32.dll (in addition to bcryptprimitives.dll)
1919
//! - Requires using name "SystemFunction036"
2020
//! - Thin wrapper around ProcessPrng
21+
//!
2122
//! For more information see the Windows RNG Whitepaper: https://aka.ms/win10rng
2223
use crate::Error;
2324
use core::mem::MaybeUninit;

src/windows7.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const TRUE: BOOLEAN = 1u8;
2525

2626
pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
2727
// Prevent overflow of u32
28-
for chunk in dest.chunks_mut(u32::max_value() as usize) {
28+
for chunk in dest.chunks_mut(u32::MAX as usize) {
2929
let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr().cast::<c_void>(), chunk.len() as u32) };
3030
if ret != TRUE {
3131
return Err(Error::WINDOWS_RTL_GEN_RANDOM);

0 commit comments

Comments
 (0)