@@ -7,6 +7,9 @@ features_flag := '--all-features'
77# Use `CI=true just ci-test` to run the same tests as in GitHub CI.
88# Use `just env-info` to see the current values of RUSTFLAGS and RUSTDOCFLAGS
99ci_mode := if env (' CI' , ' ' ) != ' ' {' 1' } else {' ' }
10+ # cargo-binstall needs a workaround due to caching
11+ # ci_mode might be manually set by user, so re-check the env var
12+ binstall_args := if env (' CI' , ' ' ) != ' ' {' --no-track' } else {' ' }
1013export RUSTFLAGS := env (' RUSTFLAGS' , if ci_mode == ' 1' {' -D warnings' } else {' ' })
1114export RUSTDOCFLAGS := env (' RUSTDOCFLAGS' , if ci_mode == ' 1' {' -D warnings' } else {' ' })
1215export RUST_BACKTRACE := env (' RUST_BACKTRACE' , if ci_mode == ' 1' {' 1' } else {' ' })
@@ -63,6 +66,7 @@ docs *args='--open':
6366# Print environment info
6467env -info:
6568 @ echo " Running {{ if ci_mode == ' 1' {' in CI mode' } else {' in dev mode' } }} on {{ os ()}} / {{ arch ()}} "
69+ @ echo " PWD $(pwd)"
6670 {{ just_executable ()}} --version
6771 rustc --version
6872 cargo --version
@@ -75,14 +79,18 @@ env-info:
7579fmt :
7680 #!/usr/bin/env bash
7781 set -euo pipefail
78- if rustup component list --toolchain nightly | grep rustfmt &> / dev/ null; then
82+ if ( rustup toolchain list | grep nightly && rustup component list --toolchain nightly | grep rustfmt) &> / dev/ null; then
7983 echo ' Reformatting Rust code using nightly Rust fmt to sort imports'
8084 cargo + nightly fmt --all -- --config imports_granularity=Module,group_imports=StdExternalCrate
8185 else
8286 echo ' Reformatting Rust with the stable cargo fmt. Install nightly with `rustup install nightly` for better results'
8387 cargo fmt --all
8488 fi
8589
90+ # Reformat all Cargo.toml files using cargo-sort
91+ fmt-toml * args : (cargo-install ' cargo-sort' )
92+ cargo sort --workspace --grouped {{ args}}
93+
8694# Get any package's field from the metadata
8795get-crate-field field package = main_crate: (assert-cmd ' jq' )
8896 cargo metadata --format-version 1 | jq -e -r ' .packages | map(select(.name == "{{ package}} ")) | first | .{{ field}} | select(. != null)'
@@ -94,6 +102,7 @@ get-msrv package=main_crate: (get-crate-field 'rust_version' package)
94102msrv : (cargo-install ' cargo-msrv' )
95103 cargo msrv find --write-msrv --ignore-lockfile -- just ci-test-msrv
96104
105+ # Run cargo-release
97106release * args = ' ': (cargo-install ' release-plz' )
98107 release-plz {{ args}}
99108
@@ -110,7 +119,7 @@ test:
110119test-doc : (docs ' ' )
111120
112121# Test code formatting
113- test-fmt :
122+ test-fmt : && ( fmt-toml ' --check' ' --check-format' )
114123 cargo fmt --all -- --check
115124
116125# Run all tests for MSRV
@@ -155,7 +164,7 @@ cargo-install $COMMAND $INSTALL_CMD='' *args='':
155164 echo " $COMMAND could not be found. Installing it with cargo install ${INSTALL_CMD:-$COMMAND} --locked {{ args}} "
156165 cargo install ${INSTALL_CMD:-$COMMAND} --locked {{ args}}
157166 else
158- echo " $COMMAND could not be found. Installing it with cargo binstall ${INSTALL_CMD:-$COMMAND} --locked {{ args}} "
159- cargo binstall ${INSTALL_CMD:-$COMMAND} --locked {{ args}}
167+ echo " $COMMAND could not be found. Installing it with cargo binstall ${INSTALL_CMD:-$COMMAND} {{ binstall_args }} --locked {{ args}} "
168+ cargo binstall ${INSTALL_CMD:-$COMMAND} {{ binstall_args }} --locked {{ args}}
160169 fi
161170 fi
0 commit comments