Skip to content

Commit

Permalink
Improvements to CI and the Justfile. (#119)
Browse files Browse the repository at this point in the history
In CI, I have added workflows and jobs to:

* run `cargo machete`
* ensure the lockfile doesn't change
* share a Rust cache

I've also aligned the justfile with CI, and fixed the `just dev` target.
  • Loading branch information
SamirTalwar authored Mar 12, 2024
1 parent 7247041 commit dee4037
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 341 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,27 @@ jobs:
rustup show
- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs

- name: build
run: |
cargo build --release --all-targets --all-features
# Sadly, `cargo build --locked` isn't enough to check that the lockfile
# is up to date, as it will happily run even if there are extra entries in
# there.
#
# It does, however, make sure that the file is not updated, which is quite
# unhelpful.
- name: ensure lockfile hasn't changed
run: |
if [[ -n "$(git status --porcelain Cargo.lock)" ]]; then
echo 'The Cargo.lock file was changed!'
git diff Cargo.lock
exit 1
fi
- name: clippy
run: |
cargo clippy --release --all-targets --all-features
22 changes: 22 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: format

on:
push:

jobs:
cargo-fmt:
name: check formatting with cargo fmt
runs-on: ubuntu-latest
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
RUSTFLAGS: "-D warnings" # fail on warnings
steps:
- uses: actions/checkout@v4

- name: install tools
run: |
rustup show
- name: check formatting
run: |
cargo fmt --all --check
43 changes: 0 additions & 43 deletions .github/workflows/lint.yaml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/machete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: find unused dependencies

on:
push:

jobs:
cargo-machete:
name: find unused dependencies with cargo machete
runs-on: ubuntu-latest
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
RUSTFLAGS: "-D warnings" # fail on warnings
steps:
- uses: actions/checkout@v4

- name: install tools
run: |
rustup show
cargo install cargo-machete
- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs
save-if: false

- name: find unused dependencies
run: |
cargo machete --with-metadata
5 changes: 4 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
rustup show
- uses: Swatinem/rust-cache@v2
with:
shared-key: "build" # share the cache across jobs
save-if: false

- name: run tests
run: cargo test
run: cargo test --release --all-targets --all-features
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# direnv
/.direnv

# testing
/tmp/empty
Loading

0 comments on commit dee4037

Please sign in to comment.