feat: add `justfile`
Description
Closes #1967.
This PR adds a justfile, updates the PR template to use it, and adds a section on the README.md to show available recipes.
These are the implemented recipes:
alias b := build
alias c := check
alias f := fmt
alias t := test
alias p := pre-push
_default:
@just --list
# Build the project
build:
cargo build
# Check code: formatting, compilation, linting, and commit signature
check:
cargo +nightly fmt --all -- --check
cargo check --workspace --exclude 'examples' --all-features
cargo clippy --all-features --all-targets -- -D warnings
@[ "$(git log --pretty='format:%G?' -1 HEAD)" = "N" ] && \
echo "\n⚠️ Unsigned commit: BDK requires that commits be signed." || \
true
# Format all code
fmt:
cargo +nightly fmt
# Run all tests on the workspace with all features
test:
cargo test --workspace --exclude 'examples' --all-features
# Run pre-push suite: format, check, and test
pre-push: fmt check test
check will verify if HEAD was signed and echo that warning if not. It does not check all commits, but I think that checking only the last is a pretty good heuristic (who only signs the last commit?).
Before pushing, one only needs to run just p.
Checklists
All Submissions:
- [X] I've signed all my commits
- [X] I followed the contribution guidelines
- [X] I ran
just pbefore pushing
Did some thinking on this. Should we really exclude examples from formatting?
You mean exclude examples from cargo check? I think the only reason we exclude them in CI was to avoid MSRV dependency issues, but for this Justfile it shouldn't be a problem so probably should be checking everything.
Yes, check and also fmt --check.
If there are no objections I'll make these changes on bdk_wallet as well.
The example crates really should be excluded since they're not part of the core library. I'm still in favor of making examples into a separate workspace (if not outright removing them), and any just/cargo commands should be invoked from the examples/ directory. For wallet it will be easier to move the "examples" to the wallet/examples directory and include the necessary blockchain crates as dev-dependencies.
Makes sense. I reverted the changes to exclude the examples directory. Any other nits? If not I think this is ready to merge.
Friendly ping @notmandatory @ValuedMammal
@luisschwab Thanks for the reminder. About the example crates, my comment was more about the overall structure of the repo, not to say they have to be excluded from the justfile entirely. The argument for having a separate command for the examples though is that example_cli already doesn't respect the MSRV, so isn't subject to the same clippy lints for example. Obviously the example code should be formatted, which is covered by just fmt.
If it makes things less complicated, then I also agree with @notmandatory that we don't have to be very strict about excluding the examples.
switching toolchains, pinning dependencies, or checking various feature configurations
What would this look like? We can add it now.
I'll also circle back to bdk_wallet and add these changes there.