Skip to content

Commit 09ef00f

Browse files
committed
CI: Add lint workflow
We now ensure that the `clippy` and `rustfmt` components are installed for the `crates` MSRV via the `rust-toolchain.toml` file.
1 parent 47d2d8a commit 09ef00f

File tree

11 files changed

+104
-2
lines changed

11 files changed

+104
-2
lines changed

.github/workflows/_build_and_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99

1010
jobs:
1111
build-and-test:
12+
name: Build and test
1213
runs-on: ubuntu-latest
1314
defaults:
1415
run:

.github/workflows/_lints.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Reusable workflow for lints
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
target:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
clippy:
12+
name: Clippy (MSRV)
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: ${{ inputs.target }}
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Install build dependencies
20+
run: sudo apt install libudev-dev
21+
- name: Run Clippy
22+
uses: auguwu/[email protected]
23+
with:
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
working-directory: ${{ inputs.target }}
26+
args: --all-features --all-targets -- -D warnings
27+
28+
clippy-beta:
29+
name: Clippy (beta)
30+
runs-on: ubuntu-latest
31+
continue-on-error: true
32+
defaults:
33+
run:
34+
working-directory: ${{ inputs.target }}
35+
steps:
36+
- uses: actions/checkout@v3
37+
- name: Install build dependencies
38+
run: sudo apt install libudev-dev
39+
- uses: dtolnay/rust-toolchain@beta
40+
id: toolchain
41+
with:
42+
components: clippy
43+
- run: rustup override set ${{ steps.toolchain.outputs.name }}
44+
- name: Run Clippy (beta)
45+
uses: auguwu/[email protected]
46+
continue-on-error: true
47+
with:
48+
token: ${{ secrets.GITHUB_TOKEN }}
49+
working-directory: ${{ inputs.target }}
50+
args: --all-features --all-targets -- -W clippy::all
51+
52+
doc-links:
53+
name: Intra-doc links
54+
runs-on: ubuntu-latest
55+
defaults:
56+
run:
57+
working-directory: ${{ inputs.target }}
58+
steps:
59+
- uses: actions/checkout@v3
60+
- name: Install build dependencies
61+
run: sudo apt install libudev-dev
62+
- run: cargo fetch
63+
# Requires #![deny(rustdoc::broken_intra_doc_links)] in crates.
64+
- name: Check intra-doc links
65+
run: cargo doc --workspace --document-private-items
66+
67+
fmt:
68+
name: Rustfmt
69+
runs-on: ubuntu-latest
70+
defaults:
71+
run:
72+
working-directory: ${{ inputs.target }}
73+
steps:
74+
- uses: actions/checkout@v3
75+
- run: cargo fmt --all --check

.github/workflows/lints.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Lints
2+
3+
# We only run these lints on trial-merges of PRs to reduce noise.
4+
on:
5+
pull_request:
6+
branches: ["main"]
7+
8+
jobs:
9+
crates:
10+
uses: ./.github/workflows/_lints.yml
11+
with:
12+
target: crates
13+
14+
tools:
15+
uses: ./.github/workflows/_lints.yml
16+
with:
17+
target: tools

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
CARGO_TERM_COLOR: always
1111

1212
jobs:
13-
build:
13+
crates:
1414
uses: ./.github/workflows/_build_and_test.yml
1515
with:
1616
target: crates

crates/alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! *Note:* This currently requires using nightly.
33
44
#![no_std]
5+
#![deny(rustdoc::broken_intra_doc_links)]
56

67
use core::alloc::{GlobalAlloc, Layout};
78
use core::ffi::c_void;

crates/flipperzero/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
#![no_std]
44
#![cfg_attr(test, no_main)]
5+
#![deny(rustdoc::broken_intra_doc_links)]
56

67
#[cfg(feature = "alloc")]
78
extern crate alloc;

crates/rt/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! is linked directly into the `.text` section.
55
66
#![no_std]
7+
#![deny(rustdoc::broken_intra_doc_links)]
78

89
pub mod manifest;
910
pub mod panic_handler;

crates/rust-toolchain.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[toolchain]
22
channel = "nightly-2023-05-03"
33
targets = [ "thumbv7em-none-eabihf" ]
4+
components = [ "clippy", "rustfmt" ]

crates/sys/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Low-level bindings for the Flipper Zero.
22
33
#![no_std]
4+
#![deny(rustdoc::broken_intra_doc_links)]
45

56
// Features that identify thumbv7em-none-eabihf.
67
// Until target_abi is stable, this also permits thumbv7em-none-eabi.
@@ -20,6 +21,7 @@ mod inlines;
2021
#[allow(non_upper_case_globals)]
2122
#[allow(non_camel_case_types)]
2223
#[allow(non_snake_case)]
24+
#[allow(rustdoc::broken_intra_doc_links)]
2325
mod bindings;
2426

2527
/// Create a static C string.

crates/test/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![no_std]
2+
#![deny(rustdoc::broken_intra_doc_links)]
23

34
pub use flipperzero_test_macros::{tests, tests_runner};
45

tools/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
pub mod storage;
1+
#![deny(rustdoc::broken_intra_doc_links)]
2+
23
pub mod serial;
4+
pub mod storage;

0 commit comments

Comments
 (0)