Skip to content

feat: add justfile#1979

Merged
evanlinjin merged 1 commit intobitcoindevkit:masterfrom
luisschwab:feat/justfile
Jul 10, 2025
Merged

feat: add justfile#1979
evanlinjin merged 1 commit intobitcoindevkit:masterfrom
luisschwab:feat/justfile

Conversation

@luisschwab
Copy link
Copy Markdown
Member

@luisschwab luisschwab commented Jun 18, 2025

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 --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 for all crates with all features enabled
test:
   @just _test-bitcoind_rpc
   @just _test-chain
   @just _test-core
   @just _test-electrum
   @just _test-esplora
   @just _test-file_store
   @just _test-testenv

_test-bitcoind_rpc:
    cargo test -p bdk_bitcoind_rpc --all-features

_test-chain:
    cargo test -p bdk_chain --all-features

_test-core:
    cargo test -p bdk_core --all-features

_test-electrum:
    cargo test -p bdk_electrum --all-features

_test-esplora:
    cargo test -p bdk_esplora --all-features

_test-file_store:
    cargo test -p bdk_file_store --all-features

_test-testenv:
    cargo test -p bdk_testenv --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 signs the last commit only?).

Before pushing, one only needs to run just p.

Checklists

All Submissions:

@luisschwab luisschwab self-assigned this Jun 18, 2025
@luisschwab luisschwab added the chore Non-coding related work label Jun 18, 2025
@luisschwab luisschwab moved this to Needs Review in BDK Chain Jun 18, 2025
@luisschwab
Copy link
Copy Markdown
Member Author

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

@notmandatory
Copy link
Copy Markdown
Member

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.

@luisschwab
Copy link
Copy Markdown
Member Author

luisschwab commented Jun 18, 2025

Yes, check and also fmt --check.

@luisschwab
Copy link
Copy Markdown
Member Author

luisschwab commented Jun 18, 2025

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

@ValuedMammal
Copy link
Copy Markdown
Collaborator

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.

@luisschwab
Copy link
Copy Markdown
Member Author

luisschwab commented Jun 25, 2025

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

@luisschwab
Copy link
Copy Markdown
Member Author

Friendly ping @notmandatory @ValuedMammal

@ValuedMammal
Copy link
Copy Markdown
Collaborator

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

Comment thread justfile Outdated
Comment thread justfile Outdated
Comment on lines +28 to +29
test:
cargo test --workspace --exclude 'examples' --all-features
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📌 I think it would be a good idea to test each package individually. I was also going to suggest reducing --test-threads for tests that rely heavily on the testenv, but I just tested this on my own machine with no issues.

Copy link
Copy Markdown
Member Author

@luisschwab luisschwab Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do something like this:

test:
   @just test-chain
   @just test-core
   @just test-file_store
   @just test-electrum
   @just test-esplora
   @just test-bitcoind_rpc

test-chain:
    cargo test -p bdk_chain --all-features

test-core:
    cargo test -p bdk_core --all-features

test-file_store:
    cargo test -p bdk_file_core --all-features

test-electrum:
    cargo test -p bdk_electrum --all-features

test-esplora:
    cargo test -p bdk_esplora --all-features

test-bitcoind_rpc:
    cargo test -p bdk_bitcoind_rpc --all-features

I could also add the underscore so those recipes don't show up when running just.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also going to suggest reducing --test-threads for tests that rely heavily on the testenv, but I just tested this on my own machine with no issues.

I don't think that's necessary, running this on a low-end laptop doesn't take too long.

Comment thread .github/pull_request_template.md Outdated
@ValuedMammal
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Collaborator

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Valid to note that the justfile can be used for basic sanity checking but at the moment doesn't help with switching toolchains, pinning dependencies, or checking various feature configurations, but these can be added as needed.

Comment thread CONTRIBUTING.md Outdated
Comment thread justfile
@luisschwab
Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Collaborator

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 501766e

switching toolchains, pinning dependencies, or checking various feature configurations

I think we should do more work on CI along the lines of #1944 - to help elucidate the relevant/important features, and uncover things we're not testing.

Copy link
Copy Markdown
Member

@evanlinjin evanlinjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 501766e

@evanlinjin evanlinjin merged commit ff8f114 into bitcoindevkit:master Jul 10, 2025
19 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in BDK Chain Jul 10, 2025
@oleonardolima oleonardolima mentioned this pull request Jul 31, 2025
16 tasks
@luisschwab luisschwab deleted the feat/justfile branch September 29, 2025 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Non-coding related work

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Create justfile

4 participants