Skip to content

Commit

Permalink
ci: Split lints into more jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nukesor committed Feb 15, 2025
1 parent 67a104d commit 325d571
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 19 deletions.
20 changes: 3 additions & 17 deletions .github/workflows/lint.yml → .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint the code
name: Lint the code with clippy

on:
push:
Expand All @@ -20,7 +20,7 @@ on:

jobs:
linting:
name: Lint on ${{ matrix.os }} for ${{ matrix.target }}
name: Lint with clippy on ${{ matrix.os }} for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -56,7 +56,6 @@ jobs:
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
targets: ${{ matrix.target }}

- uses: actions/cache@v4
Expand All @@ -74,18 +73,5 @@ jobs:
# ----- Actual linting logic ------
# These lines should mirror the `just lint` command.
- name: cargo fmt
run: cargo fmt --all -- --check

- name: cargo clippy
run: cargo clippy --tests --workspace -- -D warnings

# Only run taplo on linux to save some time.
# Also, taplo is broken on windows for some reason.
- name: Install taplo-cli
run: cargo install taplo-cli || exit 0
if: matrix.target == 'x86_64-unknown-linux-gnu'

- name: cargo sort
run: ~/.cargo/bin/taplo format --check
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: cargo clippy --tests --workspace --all -- -D warnings
51 changes: 51 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Check code formatting

on:
push:
branches:
- main
paths:
- ".github/**/*"
- "**.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"
pull_request:
branches:
- main
paths:
- ".github/**/*"
- "**.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"

jobs:
format:
name: Format code
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: format-${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
format-${{ runner.os }}-cargo-${{ matrix.target }}-
${{ runner.os }}-cargo-${{ matrix.target }}-
# ----- Actual linting logic ------
# These lines should mirror the `just lint` command.
- name: cargo fmt
run: cargo fmt --all -- --check
67 changes: 67 additions & 0 deletions .github/workflows/lint_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Lint the code docs

on:
push:
branches:
- main
paths:
- ".github/**/*"
- "**.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"
pull_request:
branches:
- main
paths:
- ".github/**/*"
- "**.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"

jobs:
linting:
name: Lint code docs on ${{ matrix.os }} for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- armv7-unknown-linux-musleabihf
- arm-unknown-linux-musleabihf
- x86_64-pc-windows-msvc
- x86_64-apple-darwin
- aarch64-apple-darwin
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable

- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: lint-docs-${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
lint-docs-${{ runner.os }}-cargo-${{ matrix.target }}-
${{ runner.os }}-cargo-${{ matrix.target }}-
# ----- Actual linting logic ------
# These lines should mirror the `just lint` command.
- name: cargo doc lints
run: RUSTDOCFLAGS='-D warnings' cargo doc --document-private-items --no-deps
51 changes: 51 additions & 0 deletions .github/workflows/lint_toml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Lint toml files

on:
push:
branches:
- main
paths:
- ".github/**/*"
- "**.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"
pull_request:
branches:
- main
paths:
- ".github/**/*"
- "**.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"

jobs:
linting:
name: Toml lints
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable

- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: lint-toml-${{ hashFiles('**/Cargo.lock') }}
restore-keys: lint-toml-

# Only run taplo on linux to save some time.
- name: Install taplo-cli
run: cargo install taplo-cli || exit 0
if: matrix.target == 'x86_64-unknown-linux-gnu'

- name: cargo sort
run: ~/.cargo/bin/taplo format --check
if: matrix.target == 'x86_64-unknown-linux-gnu'
1 change: 1 addition & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ lint:
cargo fmt --all -- --check
taplo format --check
cargo clippy --tests --workspace --all -- -D warnings
RUSTDOCFLAGS='-D warnings' cargo doc --document-private-items --no-deps

format:
just ensure-command taplo
Expand Down
4 changes: 2 additions & 2 deletions pueue/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ pub mod cli;
/// All subcommands have their dedicated file and functions in here.
mod commands;
pub(crate) mod display_helper;
/// The [`OutputStyle`] helper, responsible for formatting and styling output based on the current
/// settings.
/// The [`OutputStyle`](style::OutputStyle) helper, responsible for formatting and styling output
/// based on the current settings.
pub mod style;

pub use commands::handle_command;

0 comments on commit 325d571

Please sign in to comment.