Skip to content

Commit 0eaa823

Browse files
committed
chore: minor justfile adjustments
1 parent 3f98068 commit 0eaa823

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

justfile

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
#!/usr/bin/env just --justfile
22

3+
# Define the name of the main crate based
34
main_crate := file_name(justfile_directory())
4-
packages := '--workspace' # All crates in the workspace
5-
features := '--all-features' # Enable all features
6-
targets := '--all-targets' # For all targets (lib, bin, tests, examples, benches)
5+
# How to call the current just executable. Note that just_executable() may have `\` in Windows paths, so we need to quote it.
6+
just := quote(just_executable())
7+
# cargo-binstall needs a workaround due to caching when used in CI
8+
binstall_args := if env('CI', '') != '' {'--no-confirm --no-track --disable-telemetry'} else {''}
79

810
# if running in CI, treat warnings as errors by setting RUSTFLAGS and RUSTDOCFLAGS to '-D warnings' unless they are already set
911
# Use `CI=true just ci-test` to run the same tests as in GitHub CI.
1012
# Use `just env-info` to see the current values of RUSTFLAGS and RUSTDOCFLAGS
1113
ci_mode := if env('CI', '') != '' {'1'} else {''}
12-
# cargo-binstall needs a workaround due to caching
13-
# ci_mode might be manually set by user, so re-check the env var
14-
binstall_args := if env('CI', '') != '' {'--no-confirm --no-track --disable-telemetry'} else {''}
1514
export RUSTFLAGS := env('RUSTFLAGS', if ci_mode == '1' {'-D warnings'} else {''})
1615
export RUSTDOCFLAGS := env('RUSTDOCFLAGS', if ci_mode == '1' {'-D warnings'} else {''})
1716
export RUST_BACKTRACE := env('RUST_BACKTRACE', if ci_mode == '1' {'1'} else {'0'})
1817

1918
@_default:
20-
{{quote(just_executable())}} --list
19+
{{just}} --list
2120

2221
# Run integration tests and save its output as the new expected output
2322
bless *args: (cargo-install 'cargo-insta')
2423
cargo insta test --accept --unreferenced=delete -p bindgen_helpers_tests {{args}}
2524

2625
# Build the project
2726
build:
28-
cargo build {{packages}} {{features}} {{targets}}
27+
cargo build --workspace --all-features --all-targets
2928

3029
# Quick compile without building a binary
3130
check:
32-
cargo check {{packages}} {{features}} {{targets}}
31+
cargo check --workspace --all-features --all-targets
3332

3433
# Generate code coverage report to upload to codecov.io
3534
ci-coverage: env-info && \
@@ -50,21 +49,21 @@ clean:
5049

5150
# Run cargo clippy to lint the code
5251
clippy *args:
53-
cargo clippy {{packages}} {{features}} {{targets}} {{args}}
52+
cargo clippy --workspace --all-features --all-targets {{args}}
5453

5554
# Generate code coverage report. Will install `cargo llvm-cov` if missing.
5655
coverage *args='--no-clean --open': (cargo-install 'cargo-llvm-cov')
57-
cargo llvm-cov {{packages}} {{features}} {{targets}} --include-build-script {{args}}
56+
cargo llvm-cov --workspace --all-features --all-targets --include-build-script {{args}}
5857

5958
# Build and open code documentation
6059
docs *args='--open':
61-
DOCS_RS=1 cargo doc --no-deps {{args}} {{packages}} {{features}}
60+
DOCS_RS=1 cargo doc --no-deps {{args}} --workspace --all-features
6261

6362
# Print environment info
6463
env-info:
6564
@echo "Running for '{{main_crate}}' crate {{if ci_mode == '1' {'in CI mode'} else {'in dev mode'} }} on {{os()}} / {{arch()}}"
6665
@echo "PWD $(pwd)"
67-
{{quote(just_executable())}} --version
66+
{{just}} --version
6867
rustc --version
6968
cargo --version
7069
rustup --version
@@ -86,9 +85,9 @@ fmt:
8685

8786
# Reformat all Cargo.toml files using cargo-sort
8887
fmt-toml *args: (cargo-install 'cargo-sort')
89-
cargo sort {{packages}} --grouped {{args}}
88+
cargo sort --workspace --grouped {{args}}
9089

91-
# Get any package's field from the metadata
90+
# Get a package field from the metadata
9291
get-crate-field field package=main_crate: (assert-cmd 'jq')
9392
cargo metadata --format-version 1 | jq -e -r '.packages | map(select(.name == "{{package}}")) | first | .{{field}} // error("Field \"{{field}}\" is missing in Cargo.toml for package {{package}}")'
9493

@@ -97,20 +96,20 @@ get-msrv package=main_crate: (get-crate-field 'rust_version' package)
9796

9897
# Find the minimum supported Rust version (MSRV) using cargo-msrv extension, and update Cargo.toml
9998
msrv: (cargo-install 'cargo-msrv')
100-
cargo msrv find --write-msrv --ignore-lockfile {{features}}
99+
cargo msrv find --write-msrv --ignore-lockfile --all-features
101100

102101
# Run cargo-release
103102
release *args='': (cargo-install 'release-plz')
104103
release-plz {{args}}
105104

106105
# Check semver compatibility with prior published version. Install it with `cargo install cargo-semver-checks`
107106
semver *args: (cargo-install 'cargo-semver-checks')
108-
cargo semver-checks {{features}} {{args}}
107+
cargo semver-checks --all-features {{args}}
109108

110109
# Run all tests
111110
test:
112-
cargo test {{packages}} {{features}} {{targets}}
113-
cargo test --doc {{packages}} {{features}}
111+
cargo test --workspace --all-features --all-targets
112+
cargo test --doc --workspace --all-features
114113

115114
# Test documentation generation
116115
test-doc: (docs '')
@@ -119,9 +118,9 @@ test-doc: (docs '')
119118
test-fmt: && (fmt-toml '--check' '--check-format')
120119
cargo fmt --all -- --check
121120

122-
# Find unused dependencies. Install it with `cargo install cargo-udeps`
121+
# Find unused dependencies. Uses `cargo-udeps`
123122
udeps: (cargo-install 'cargo-udeps')
124-
cargo +nightly udeps {{packages}} {{features}} {{targets}}
123+
cargo +nightly udeps --workspace --all-features --all-targets
125124

126125
# Update all dependencies, including breaking changes. Requires nightly toolchain (install with `rustup install nightly`)
127126
update:

0 commit comments

Comments
 (0)