bdk icon indicating copy to clipboard operation
bdk copied to clipboard

feat: add `justfile`

Open luisschwab opened this issue 6 months ago • 6 comments

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:

luisschwab avatar Jun 18 '25 15:06 luisschwab

Did some thinking on this. Should we really exclude examples from formatting?

luisschwab avatar Jun 18 '25 16:06 luisschwab

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.

notmandatory avatar Jun 18 '25 16:06 notmandatory

Yes, check and also fmt --check.

luisschwab avatar Jun 18 '25 18:06 luisschwab

If there are no objections I'll make these changes on bdk_wallet as well.

luisschwab avatar Jun 18 '25 18:06 luisschwab

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.

ValuedMammal avatar Jun 25 '25 14:06 ValuedMammal

Makes sense. I reverted the changes to exclude the examples directory. Any other nits? If not I think this is ready to merge.

luisschwab avatar Jun 25 '25 16:06 luisschwab

Friendly ping @notmandatory @ValuedMammal

luisschwab avatar Jun 28 '25 15:06 luisschwab

@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.

ValuedMammal avatar Jun 30 '25 13:06 ValuedMammal

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.

ValuedMammal avatar Jun 30 '25 13:06 ValuedMammal

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.

luisschwab avatar Jul 01 '25 17:07 luisschwab