11#!/ usr/ bin/ env just --justfile
22
3- CRATE_NAME := ' sqlite-hashes'
4- BIN_NAME := ' sqlite_hashes'
5- SQLITE3 := ' sqlite3'
3+ main_crate := ' sqlite-hashes'
4+ bin_name := ' sqlite_hashes'
5+ sqlite3 := ' sqlite3'
66
77# if running in CI, treat warnings as errors by setting RUSTFLAGS and RUSTDOCFLAGS to '-D warnings' unless they are already set
88# Use `CI=true just ci-test` to run the same tests as in GitHub CI.
99# Use `just env-info` to see the current values of RUSTFLAGS and RUSTDOCFLAGS
10- export RUSTFLAGS := env (' RUSTFLAGS' , if env (' CI' , ' ' ) == ' true' {' -D warnings' } else {' ' })
11- export RUSTDOCFLAGS := env (' RUSTDOCFLAGS' , if env (' CI' , ' ' ) == ' true' {' -D warnings' } else {' ' })
12- export RUST_BACKTRACE := env (' RUST_BACKTRACE' , if env (' CI' , ' ' ) == ' true' {' 1' } else {' ' })
10+ ci_mode := if env (' CI' , ' ' ) != ' ' { ' 1' } else { ' ' }
11+ export RUSTFLAGS := env (' RUSTFLAGS' , if ci_mode == ' 1' {' -D warnings' } else {' ' })
12+ export RUSTDOCFLAGS := env (' RUSTDOCFLAGS' , if ci_mode == ' 1' {' -D warnings' } else {' ' })
13+ export RUST_BACKTRACE := env (' RUST_BACKTRACE' , if ci_mode == ' 1' {' 1' } else {' ' })
1314
1415@_ default :
1516 just --list
@@ -21,14 +22,14 @@ bench:
2122
2223# Run integration tests and save its output as the new expected output
2324bless * args : (cargo-install ' cargo-insta' )
24- cargo insta test --accept --unreferenced=auto {{ args}}
25+ cargo insta test --accept --unreferenced=delete {{ args}}
2526
2627# Build the project
2728build : build-lib build-ext
2829
2930# Build extension binary
3031build-ext * args :
31- cargo build --example {{ BIN_NAME }} --no-default-features --features default_loadable_extension {{ args}}
32+ cargo build --example {{ bin_name }} --no-default-features --features default_loadable_extension {{ args}}
3233
3334# Build the lib
3435build-lib :
@@ -88,14 +89,14 @@ clippy *args:
8889 cargo clippy --workspace --all-targets {{ args}}
8990 cargo clippy --no-default-features --features default_loadable_extension {{ args}}
9091
91- # Generate code coverage report
92- coverage * args = ' --no-clean --open':
92+ # Generate code coverage report. Will install `cargo llvm-cov` if missing.
93+ coverage * args = ' --no-clean --open': ( cargo-install ' cargo-llvm-cov' )
9394 cargo llvm-cov --workspace --all-targets --include-build-script {{ args}}
9495 # TODO: add test coverage for the loadable extension too, and combine them
95- # cargo llvm-cov --example {{BIN_NAME }} --no-default-features --features default_loadable_extension --codecov --output-path codecov.info
96+ # cargo llvm-cov --example {{bin_name }} --no-default-features --features default_loadable_extension --codecov --output-path codecov.info
9697
9798cross-build-ext * args :
98- cross build --example {{ BIN_NAME }} --no-default-features --features default_loadable_extension {{ args}}
99+ cross build --example {{ bin_name }} --no-default-features --features default_loadable_extension {{ args}}
99100
100101cross-build-ext-aarch64 : (cross-build-ext ' --target=aarch64-unknown-linux-gnu' ' --release' )
101102
@@ -105,7 +106,7 @@ cross-test-ext-aarch64:
105106 - v " $(pwd):/workspace" \
106107 - w / workspace \
107108 - -entrypoint sh \
108- - e EXTENSION_FILE=target/ aarch64 -unknown-linux-gnu/ release/ examples/ lib{{ BIN_NAME }} \
109+ - e EXTENSION_FILE=target/ aarch64 -unknown-linux-gnu/ release/ examples/ lib{{ bin_name }} \
109110 - -platform linux/ arm64 \
110111 arm64 v8/ ubuntu \
111112 - c ' apt-get update && apt-get install -y sqlite3 && tests/test-ext.sh'
@@ -114,16 +115,21 @@ cross-test-ext-aarch64:
114115docs :
115116 cargo doc --no-deps --open
116117
117- # Print Rust version information
118+ # Print environment info
118119env -info:
120+ @ echo " Running {{ if ci_mode == ' 1' {' in CI mode' } else {' in dev mode' } }} on {{ os ()}} / {{ arch ()}} "
121+ {{ just_executable ()}} --version
119122 rustc --version
120123 cargo --version
124+ rustup --version
125+ @ echo " RUSTFLAGS='$RUSTFLAGS'"
126+ @ echo " RUSTDOCFLAGS='$RUSTDOCFLAGS'"
121127
122128# Reformat all code `cargo fmt`. If nightly is available, use it for better results
123129fmt :
124130 #!/usr/bin/env bash
125131 set -euo pipefail
126- if command -v cargo + nightly &> / dev/ null; then
132+ if rustup component list --toolchain nightly | grep rustfmt &> / dev/ null; then
127133 echo ' Reformatting Rust code using nightly Rust fmt to sort imports'
128134 cargo + nightly fmt --all -- --config imports_granularity=Module,group_imports=StdExternalCrate
129135 else
132138 fi
133139
134140# Get any package's field from the metadata
135- get-crate-field field package = CRATE_NAME :
141+ get-crate-field field package = main_crate :
136142 cargo metadata --format-version 1 | jq -r ' .packages | map(select(.name == "{{ package}} ")) | first | .{{ field}} '
137143
138144# Get the minimum supported Rust version (MSRV) for the crate
@@ -183,6 +189,7 @@ test-doc:
183189 cargo test --doc
184190 cargo doc --no-deps
185191
192+ # Test extension by loading it into sqlite and running SQL tests
186193test-ext: build-ext
187194 ./tests/test-ext.sh
188195
@@ -201,9 +208,9 @@ update:
201208
202209# Ensure that a certain command is available
203210[private]
204- assert $COMMAND :
205- @if ! type " {{ COMMAND }} " > /dev/null; then \
206- echo "Command ' {{ COMMAND }} ' could not be found. Please make sure it has been installed on your computer." ;\
211+ assert command :
212+ @if ! type {{ command }} > /dev/null; then \
213+ echo "Command ' {{ command }} ' could not be found. Please make sure it has been installed on your computer." ;\
207214 exit 1 ;\
208215 fi
209216
@@ -226,12 +233,12 @@ cargo-install $COMMAND $INSTALL_CMD='' *args='':
226233is-sqlite3-available:
227234 #!/usr/bin/env bash
228235 set -euo pipefail
229- if ! command -v {{ SQLITE3 }} > /dev/null; then
230- echo "{{ SQLITE3 }} executable could not be found"
236+ if ! command -v {{ sqlite3 }} > /dev/null; then
237+ echo "{{ sqlite3 }} executable could not be found"
231238 exit 1
232239 fi
233- echo "Found {{ SQLITE3 }} executable:"
234- {{ SQLITE3 }} --version
240+ echo "Found {{ sqlite3 }} executable:"
241+ {{ sqlite3 }} --version
235242
236243[private]
237244test-one-lib *args:
0 commit comments