11#!/ usr/ bin/ env just --justfile
22
3- # Define the name of the main crate based
4- main_crate := file_name (justfile_directory ())
3+ main_crate := ' tilejson'
54# How to call the current just executable. Note that just_executable() may have `\` in Windows paths, so we need to quote it.
65just := quote (just_executable ())
76# cargo-binstall needs a workaround due to caching when used in CI
87binstall_args := if env (' CI' , ' ' ) != ' ' {' --no-confirm --no-track --disable-telemetry' } else {' ' }
8+ # location of the coverage output, used by CI
9+ coverage_lcov := ' target/llvm-cov/lcov.info'
910
1011# if running in CI, treat warnings as errors by setting RUSTFLAGS and RUSTDOCFLAGS to '-D warnings' unless they are already set
1112# Use `CI=true just ci-test` to run the same tests as in GitHub CI.
@@ -26,17 +27,23 @@ build:
2627check :
2728 cargo check --workspace --all-features --all-targets
2829
29- # Generate code coverage report to upload to codecov.io
30+ # Generate LCOV coverage report for CI to upload to codecov.io
3031ci-coverage : env-info && \
31- (coverage ' --codecov --output-path target/llvm-cov/codecov.info' )
32- # ATTENTION: the full file path above is used in the CI workflow
33- mkdir -p target / llvm-cov
32+ (_coverage ' --lcov' ' --output-path' quote (coverage_lcov) )
33+ rm -rf {{ quote ( parent_directory (coverage_lcov)) }}
34+ mkdir -p {{ quote ( parent_directory (coverage_lcov)) }}
3435
3536# Run all tests as expected by CI
36- ci-test : env-info test-fmt clippy check test test-doc && assert-git-is-clean
37+ ci-test : env-info test-fmt clippy test test-doc && assert-git-is-clean
3738
38- # Run minimal subset of tests to ensure compatibility with MSRV
39- ci-test-msrv : env-info check test
39+ # Compile default features with minimal dependencies on the configured MSRV
40+ ci-test-msrv :
41+ {{ just}} ci_mode=0 env -info _check-msrv-default
42+ {{ just}} assert -git-is-clean
43+
44+ # Set toolchain and run ci-test-msrv
45+ ci-test-msrv-with-toolchain :
46+ RUSTUP_TOOLCHAIN=" $({{ just}} get-msrv)" {{ just}} ci-test-msrv
4047
4148# Clean all build artifacts
4249clean :
@@ -47,9 +54,14 @@ clean:
4754clippy * args :
4855 cargo clippy --workspace --all-features --all-targets {{ args}}
4956
50- # Generate code coverage report. Will install `cargo llvm-cov` if missing.
51- coverage * args = ' --no-clean --open': (cargo-install ' cargo-llvm-cov' )
52- cargo llvm-cov --workspace --all-features --all-targets --include-build-script {{ args}}
57+ # Generate and open the HTML coverage report
58+ coverage : (_coverage ' --open' )
59+
60+ # Clean, collect, and aggregate coverage using the requested report arguments
61+ _ coverage * report_args : (cargo-install ' cargo-llvm-cov' )
62+ cargo llvm-cov clean --workspace
63+ cargo llvm-cov --no-report --workspace --all-features --all-targets
64+ cargo llvm-cov report --include-build-script {{ report_args}}
5365
5466# Build and open code documentation
5567docs * args = ' --open':
@@ -58,7 +70,7 @@ docs *args='--open':
5870# Print environment info
5971env -info:
6072 @ echo " Running for '{{ main_crate}} ' crate {{ if ci_mode == ' 1' {' in CI mode' } else {' in dev mode' } }} on {{ os ()}} / {{ arch ()}} "
61- @ echo " PWD $(pwd) "
73+ @ echo " PWD {{ justfile_directory () }} "
6274 {{ just}} --version
6375 rustc --version
6476 cargo --version
@@ -85,14 +97,25 @@ fmt-toml *args: (cargo-install 'cargo-sort')
8597
8698# Get a package field from the metadata
8799get-crate-field field package = main_crate: (assert-cmd ' jq' )
88- 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}} ")'
100+ @ cargo metadata --no-deps --format-version 1 | jq -e -r ' .packages | map(select(.name == "{{ package}} ")) | first | .{{ field}} // error("Field \"{{ field}} \" is missing in Cargo.toml for package {{ package}} ")'
89101
90102# Get the minimum supported Rust version (MSRV) for the crate
91103get-msrv package = main_crate: (get-crate-field ' rust_version' package)
92104
93- # Find the minimum supported Rust version (MSRV) using cargo-msrv extension, and update Cargo.toml
105+ # Find the minimum supported Rust version (MSRV), update Cargo.toml, and test minimal dependencies
94106msrv : (cargo-install ' cargo-msrv' )
95- cargo msrv find --write-msrv --ignore-lockfile --all-features
107+ cargo msrv find --write-msrv --ignore-lockfile -- {{ just}} _check-msrv-default
108+
109+ # Compile the crate's default features using a dynamically generated minimal Cargo.lock
110+ _ check-msrv-default : (cargo-install ' cargo-minimal-versions' ) (cargo-install ' cargo-hack' )
111+ #!/usr/bin/env bash
112+ set -euo pipefail
113+ # cargo-msrv probes with rustup, but nested cargo subcommands may otherwise
114+ # fall back to the default Cargo and emit flags unsupported by the candidate rustc.
115+ toolchain=" $( rustc --version | cut -d' ' -f2) "
116+ export RUSTUP_TOOLCHAIN=" $toolchain "
117+ export CARGO=" $( rustup which --toolchain " $toolchain " cargo) "
118+ cargo minimal-versions check --direct --package {{main_crate}}
96119
97120# Run cargo-release
98121release * args = ' ': (cargo-install ' release-plz' )
@@ -102,7 +125,7 @@ release *args='': (cargo-install 'release-plz')
102125semver * args : (cargo-install ' cargo-semver-checks' )
103126 cargo semver-checks --all-features {{ args}}
104127
105- # Run all unit and integration tests
128+ # Run all tests
106129test :
107130 cargo test --workspace --all-features --all-targets
108131 cargo test --doc --workspace --all-features
@@ -135,11 +158,11 @@ assert-cmd command:
135158[private ]
136159assert -git-is-clean :
137160 @ if [ -n " $(git status --untracked-files --porcelain)" ]; then \
138- >&2 echo " ERROR: git repo is no longer clean. Make sure compilation and tests artifacts are in the .gitignore, and no repo files are modified." ;\
139- >&2 echo " ######### git status ##########" ;\
140- git status ;\
141- git --no-pager diff ;\
142- exit 1 ;\
161+ >&2 echo " ERROR: git repo is no longer clean. Make sure compilation and tests artifacts are in the .gitignore, and no repo files are modified." ;\
162+ >&2 echo " ######### git status ##########" ;\
163+ git status ;\
164+ git --no-pager diff ;\
165+ exit 1 ;\
143166 fi
144167
145168# Check if a certain Cargo command is installed, and install it if needed
0 commit comments