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 612a755
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 62 deletions.
38 changes: 6 additions & 32 deletions .github/workflows/lint.yml → .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,41 @@
name: Lint the code
name: Lint the code with clippy

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

jobs:
linting:
name: Lint on ${{ matrix.os }} for ${{ matrix.target }}
clippy:
name: 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: ubuntu-latest
target: aarch64-unknown-linux-musl
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
- os: ubuntu-latest
target: arm-unknown-linux-musleabihf
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin

steps:
- name: Checkout code
Expand All @@ -56,7 +44,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 +61,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
20 changes: 7 additions & 13 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@ on:
- "**/Cargo.lock"

jobs:
publish:
name: Create test coverage on ${{ matrix.os }} for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
coverage:
name: on ubuntu-latest
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu

steps:
- name: Checkout code
Expand All @@ -41,7 +35,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
targets: ${{ matrix.target }}
targets: x86_64-unknown-linux-gnu

- uses: actions/cache@v3
with:
Expand All @@ -51,10 +45,10 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-coverage-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
key: cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-coverage-${{ matrix.target }}-
${{ runner.os }}-cargo-${{ matrix.target }}-
cargo-coverage-
cargo-
- name: Install cargo-llvm-cov and nextest
uses: taiki-e/install-action@v2
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Check code formatting

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

jobs:
format:
runs-on: ubuntu-latest
strategy:
fail-fast: false

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
69 changes: 69 additions & 0 deletions .github/workflows/lint_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Lint the code docs

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

jobs:
lint_docs:
name: on ${{ matrix.os }} for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-pc-windows-msvc
- x86_64-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
if: ${{ !startsWith(matrix.os, 'windows') }}

# These lines should mirror the `just lint` command.
- name: cargo doc lints
run: $env:RUSTDOCFLAGS='-D warnings'; cargo doc --document-private-items --no-deps
if: startsWith(matrix.os, 'windows')
52 changes: 52 additions & 0 deletions .github/workflows/lint_toml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Lint toml files

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

jobs:
lint_toml:
runs-on: ubuntu-22.04
strategy:
fail-fast: false

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'
4 changes: 2 additions & 2 deletions .github/workflows/package-binary.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Packaging
name: Packaging and publish

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

jobs:
publish:
name: Publish on ${{ matrix.os }} for ${{ matrix.target }}
name: on ${{ matrix.os }} for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Test Build"
name: Build and run tests

on:
push:
Expand All @@ -19,8 +19,8 @@ on:
- "**/Cargo.lock"

jobs:
publish:
name: Test on ${{ matrix.os }} for ${{ matrix.target }}
test:
name: on ${{ matrix.os }} for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
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
2 changes: 1 addition & 1 deletion pueue/src/client/commands/state/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use limit::Limit;
use order_by::Direction;

/// See the pest docs on how this derive macro works and how to use pest:
/// https://docs.rs/pest/latest/pest/
/// <https://docs.rs/pest/latest/pest/>
#[derive(Parser)]
#[grammar = "./src/client/commands/state/query/syntax.pest"]
struct QueryParser;
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;
Loading

0 comments on commit 612a755

Please sign in to comment.