33@_ default :
44 just --list
55
6- # Clean all build artifacts
7- clean :
8- cargo clean
9- rm -f Cargo.lock
6+ # Run tests, and accept their results. Requires insta to be installed.
7+ bless : (cargo-install " cargo-insta" )
8+ TRYBUILD=overwrite cargo insta test --accept --all-features
109
11- # Update all dependencies, including breaking changes. Requires nightly toolchain (install with `rustup install nightly`)
12- update :
13- cargo + nightly -Z unstable-options update --breaking
14- cargo update
10+ # Default build
11+ build * ARGS :
12+ cargo build --all-targets --workspace --all-features {{ ARGS}}
1513
16- # Find unused dependencies. Install it with `cargo install cargo-udeps`
17- udeps :
18- cargo + nightly udeps --all-targets --workspace --all-features
14+ # Quick compile without building a binary
15+ check :
16+ cargo check --workspace --all-targets --all-features
1917
20- # Check semver compatibility with prior published version. Install it with `cargo install cargo-semver-checks`
21- semver * ARGS :
22- cargo semver-checks {{ ARGS}}
18+ # Verify that the current version of the crate is not the same as the one published on crates.io
19+ check-if-published : (assert " jq" )
20+ #!/usr/bin/env bash
21+ set -euo pipefail
22+ LOCAL_VERSION=" $(grep '^version =' Cargo.toml | sed -E 's/version = " ([^" ]*)" .*/ \1 / ' )"
23+ echo "Detected crate version: $LOCAL_VERSION"
24+ CRATE_NAME="$(grep ' ^name =' Cargo.toml | head -1 | sed -E ' s/ name = " (.*)"/ \1 / ' )"
25+ echo "Detected crate name: $CRATE_NAME"
26+ PUBLISHED_VERSION="$(cargo search ${CRATE_NAME} | grep "^${CRATE_NAME} =" | sed -E ' s/ .* = " (.*)" .*/ \1 / ' )"
27+ echo "Published crate version: $PUBLISHED_VERSION"
28+ if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then
29+ echo "ERROR: The current crate version has already been published."
30+ exit 1
31+ else
32+ echo "The current crate version has not yet been published."
33+ fi
2334
24- # Find the minimum supported Rust version (MSRV) using cargo-msrv extension, and update Cargo.toml
25- msrv :
26- cargo msrv find --write-msrv --component rustfmt --all-features --ignore-lockfile -- {{ just_executable ()}} ci-test-msrv
35+ # Generate code coverage report to upload to codecov.io
36+ ci-coverage: && \
37+ (coverage ' --codecov --output-path target/ llvm-cov/ codecov.info' )
38+ # ATTENTION: the full file path above is used in the CI workflow
39+ mkdir -p target/llvm-cov
40+
41+ # Run all tests as expected by CI
42+ ci-test: rust-info test-fmt
43+ RUSTFLAGS=' -D warnings' {{ just_executable ()}} build
44+ {{ just_executable ()}} clippy -- -D warnings
45+ RUSTFLAGS=' -D warnings' {{ just_executable ()}} test
46+ RUSTDOCFLAGS=' -D warnings' {{ just_executable ()}} test-doc
47+
48+ # Run minimal subset of tests to ensure compatibility with MSRV
49+ ci-test-msrv: rust-info test
50+
51+ # Clean all build artifacts
52+ clean:
53+ cargo clean
54+ rm -f Cargo.lock
2755
2856# Run cargo clippy to lint the code
2957clippy *ARGS:
3058 cargo clippy --workspace --all-targets --all-features {{ ARGS}}
3159
32- # Test code formatting
33- test-fmt :
34- cargo fmt --all -- --check
60+ # Generate code coverage report
61+ coverage *ARGS="--no-clean --open":
62+ cargo llvm-cov test --workspace --all-targets --all-features --include-build-script {{ ARGS}}
63+
64+ # Build and open code documentation
65+ docs:
66+ cargo doc --no-deps --all-features --open
3567
3668# Reformat all code `cargo fmt`. If nightly is available, use it for better results
3769fmt:
4577 cargo fmt --all
4678 fi
4779
48- # Build and open code documentation
49- docs :
50- cargo doc --no-deps --all-features --open
51-
52- # Quick compile without building a binary
53- check :
54- cargo check --workspace --all-targets --all-features
55-
56- # Default build
57- build * ARGS :
58- cargo build --all-targets --workspace --all-features {{ ARGS}}
80+ # Find the minimum supported Rust version (MSRV) using cargo-msrv extension, and update Cargo.toml
81+ msrv:
82+ cargo msrv find --write-msrv --component rustfmt --all-features --ignore-lockfile -- {{ just_executable ()}} ci-test-msrv
5983
60- # Generate code coverage report
61- coverage * ARGS = " --no-clean --open" :
62- cargo llvm-cov test --workspace --all-targets --all-features --include-build-script {{ ARGS }}
84+ rust-info:
85+ rustc --version
86+ cargo --version
6387
64- # Generate code coverage report to upload to codecov.io
65- ci-coverage : && \
66- (coverage ' --codecov --output-path target/llvm-cov/codecov.info' )
67- # ATTENTION: the full file path above is used in the CI workflow
68- mkdir -p target/ llvm-cov
88+ # Check semver compatibility with prior published version. Install it with `cargo install cargo-semver-checks`
89+ semver *ARGS:
90+ cargo semver-checks {{ ARGS}}
6991
7092# Run all tests
7193test *ARGS:
7294 cargo test --all-targets --workspace --all-features {{ ARGS}}
7395
74- # Use the experimental workspace publishing with --dry-run. Requires nightly Rust.
75- test-publish :
76- cargo + nightly -Z package-workspace publish --dry-run
77-
78- # Run tests, and accept their results. Requires insta to be installed.
79- bless : (cargo-install " cargo-insta" )
80- TRYBUILD=overwrite cargo insta test --accept --all-features
81-
8296# Test documentation
8397test-doc:
8498 cargo test --doc --all-features
8599 cargo doc --no-deps --all-features
86100
87- rust-info :
88- rustc --version
89- cargo --version
101+ # Test code formatting
102+ test-fmt:
103+ cargo fmt --all -- --check
90104
91- # Run all tests as expected by CI
92- ci-test : rust-info test-fmt
93- RUSTFLAGS=' -D warnings' {{ just_executable ()}} build
94- {{ just_executable ()}} clippy -- -D warnings
95- RUSTFLAGS=' -D warnings' {{ just_executable ()}} test
96- RUSTDOCFLAGS=' -D warnings' {{ just_executable ()}} test-doc
105+ # Use the experimental workspace publishing with --dry-run. Requires nightly Rust.
106+ test-publish:
107+ cargo +nightly -Z package-workspace publish --dry-run
97108
98- # Run minimal subset of tests to ensure compatibility with MSRV
99- ci-test-msrv : rust-info test
109+ # Find unused dependencies. Install it with `cargo install cargo-udeps`
110+ udeps:
111+ cargo +nightly udeps --all-targets --workspace --all-features
112+
113+ # Update all dependencies, including breaking changes. Requires nightly toolchain (install with `rustup install nightly`)
114+ update:
115+ cargo +nightly -Z unstable-options update --breaking
116+ cargo update
117+
118+ # Ensure that a certain command is available
119+ [private]
120+ assert $COMMAND:
121+ @if ! type "{{ COMMAND}} " > /dev/null; then \
122+ echo "Command ' {{COMMAND}}' could not be found. Please make sure it has been installed on your computer." ;\
123+ exit 1 ;\
124+ fi
100125
101126# Check if a certain Cargo command is installed, and install it if needed
102127[private]
@@ -112,28 +137,3 @@ cargo-install $COMMAND $INSTALL_CMD="" *ARGS="":
112137 cargo binstall ${INSTALL_CMD:-$COMMAND} {{ ARGS}}
113138 fi
114139 fi
115-
116- # Verify that the current version of the crate is not the same as the one published on crates.io
117- check-if-published : (assert " jq" )
118- #!/usr/bin/env bash
119- set -euo pipefail
120- LOCAL_VERSION=" $(grep '^version =' Cargo.toml | sed -E 's/version = " ([^" ]*)" .*/ \1 / ' )"
121- echo "Detected crate version: $LOCAL_VERSION"
122- CRATE_NAME="$(grep ' ^name =' Cargo.toml | head -1 | sed -E ' s/ name = " (.*)"/ \1 / ' )"
123- echo "Detected crate name: $CRATE_NAME"
124- PUBLISHED_VERSION="$(cargo search ${CRATE_NAME} | grep "^${CRATE_NAME} =" | sed -E ' s/ .* = " (.*)" .*/ \1 / ' )"
125- echo "Published crate version: $PUBLISHED_VERSION"
126- if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then
127- echo "ERROR: The current crate version has already been published."
128- exit 1
129- else
130- echo "The current crate version has not yet been published."
131- fi
132-
133- # Ensure that a certain command is available
134- [private]
135- assert $COMMAND:
136- @if ! type "{{ COMMAND}} " > /dev/null; then \
137- echo "Command ' {{COMMAND}}' could not be found. Please make sure it has been installed on your computer." ;\
138- exit 1 ;\
139- fi
0 commit comments