Skip to content

Commit

Permalink
ci: Split cargo checks into separate files & jobs
Browse files Browse the repository at this point in the history
Separating into different jobs and files allows for more detailed
failures in the CI overview as well as separate badges in the readme
  • Loading branch information
max-ishere committed Feb 7, 2024
1 parent 51f2802 commit 6d66890
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 82 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ tab_width = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120

[*.yml]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120
40 changes: 40 additions & 0 deletions .github/workflows/cargo-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build

on:
push:
paths:
- '**.rs'
- '.github/workflows/**.yml'
pull_request:
paths:
- '**.rs'
- '.github/workflows/**.yml'
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- --lib
- --bins
- --examples

steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
with:
path: target/
key: cargo-build-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-build-${{ hashFiles('Cargo.lock') }}
cargo-build-
cargo-
- name: build
run: cargo build --release ${{ matrix.target }} --keep-going --verbose
58 changes: 58 additions & 0 deletions .github/workflows/cargo-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Linter

on:
push:
paths:
- '**.rs'
- '.github/workflows/**.yml'
pull_request:
paths:
- '**.rs'
- '.github/workflows/**.yml'
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
clippy:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- --lib
- --bins
- --examples
- --tests

steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
with:
path: target/
key: cargo-lint-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-lint-${{ hashFiles('Cargo.lock') }}
cargo-lint-
cargo-
- name: clippy
run: cargo clippy --no-deps ${{ matrix.target }} --verbose -- -Dwarnings

fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
with:
path: target/
key: cargo-lint-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-lint-${{ hashFiles('Cargo.lock') }}
cargo-lint-
cargo-
- name: fmt
run: cargo fmt --all --check --verbose
42 changes: 42 additions & 0 deletions .github/workflows/cargo-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests

on:
push:
paths:
- '**.rs'
- '.github/workflows/**.yml'
pull_request:
paths:
- '**.rs'
- '.github/workflows/**.yml'
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- --lib
- --bins
- --examples
- --tests
- --doc

steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
with:
path: target/
key: cargo-test-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-test-${{ hashFiles('Cargo.lock') }}
cargo-test-
cargo-
- name: test
run: cargo test --no-fail-fast ${{ matrix.target }} --verbose
82 changes: 0 additions & 82 deletions .github/workflows/cargo.yml

This file was deleted.

0 comments on commit 6d66890

Please sign in to comment.