bitcoindevkit / rust-esplora-client

Bitcoin Esplora API client library. Supports plaintext, TLS and Onion servers. Blocking or async.
MIT License
29 stars 44 forks source link

Justfile for running test matrix locally? #106

Open praveenperera opened 1 week ago

praveenperera commented 1 week ago

@ValuedMammal We've had a lot of back and forth on this PR: #103, mostly because I only ran cargo test and missed tests in the matrix, was wondering if you what you think about adding a justfile so anyone contributing could run the tests locally before doing a PR. If you want I can make the PR, it would look mostly like this.


# Default recipe shows available commands
default:
    @just --list

# Set default values
rust_version := "stable"
feature := "default"

# Build with specific Rust version and feature
build VERSION=rust_version FEAT=feature:
    @echo "Building with Rust {{VERSION}} and feature {{FEAT}}"
    cargo build --features {{FEAT}} --no-default-features

# Test with specific Rust version and feature
test VERSION=rust_version FEAT=feature:
    @echo "Testing with Rust {{VERSION}} and feature {{FEAT}}"
    cargo test --features {{FEAT}} --no-default-features -- --test-threads=1

# Switch Rust version
switch-rust VERSION:
    rustup default {{VERSION}}
    rustup set profile minimal
    rustup update

# Pin dependencies for MSRV 1.63.0
pin-msrv:
    cargo update -p zstd-sys --precise "2.0.8+zstd.1.5.5"
    cargo update -p time --precise "0.3.20"
    cargo update -p home --precise 0.5.5
    cargo update -p url --precise "2.5.0"
    cargo update -p tokio --precise "1.38.1"
    cargo update -p tokio-util --precise "0.7.11"

# Run full test matrix
test-matrix: 
    just test-stable
    just test-msrv

# Test all features on stable Rust
test-stable:
    #!/usr/bin/env bash
    features=(
        "default"
        "blocking"
        "blocking-https"
        "blocking-https-rustls"
        "blocking-https-native"
        "blocking-https-bundled"
        "async"
        "async-https"
        "async-https-native"
        "async-https-rustls"
        "async-https-rustls-manual-roots"
    )

    just switch-rust stable
    for feature in "${features[@]}"; do
        just test stable "$feature"
    done

# Test all features on MSRV (1.63.0)
test-msrv:
    #!/usr/bin/env bash
    features=(
        "default"
        "blocking"
        "blocking-https"
        "blocking-https-rustls"
        "blocking-https-native"
        "blocking-https-bundled"
        "async"
        "async-https"
        "async-https-native"
        "async-https-rustls"
        "async-https-rustls-manual-roots"
    )

    just switch-rust 1.63.0
    just pin-msrv
    for feature in "${features[@]}"; do
        just test 1.63.0 "$feature"
    done

# Clean build artifacts
clean:
    cargo clean
ValuedMammal commented 6 days ago

I agree this would be useful, I would add checks for things like rustfmt and clippy. I'm sort of indifferent to the idea of committing it to the repo because of course we'd have to maintain it. @oleonardolima what do you think?

oleonardolima commented 6 days ago

I have mixed feelings about it, it looks fine to add but would be yet another thing to maintain and keep it in pair with CI and MSRV deps pinning.

Also, because same behavior can be achieved by either (1) activating and running the CI on your own forked repository (it's what I usually do), or (2) execute the CI locally using some tool, (e.g act).