|
| 1 | +# Maintainer Tools |
| 2 | + |
| 3 | +Maintainer tools for Rust-based projects in the Bitcoin domain. Built with [xshell](https://github.com/matklad/xshell). |
| 4 | + |
| 5 | +## Configuration |
| 6 | + |
| 7 | +Configuration for `rbmt` is stored in `contrib/rbmt.toml`. The file can live at both the workspace root (e.g. `$ROOT/contrib/rbmt.toml`) as well as per-crate (e.g. `$ROOT/$CRATE/contrib/rbmt.toml`) within a repository. |
| 8 | + |
| 9 | +### Lint |
| 10 | + |
| 11 | +The `lint` command detects duplicate dependencies, but some may be unavoidable (e.g., during dependency updates where transitive dependencies haven't caught up). Configure the `[lint]` section to whitelist specific duplicates for a workspace (or a crate if only one crate in a repository). |
| 12 | + |
| 13 | +```toml |
| 14 | +[lint] |
| 15 | +allowed_duplicates = [ |
| 16 | + "syn", |
| 17 | + "bitcoin_hashes", |
| 18 | +] |
| 19 | +``` |
| 20 | + |
| 21 | +### Test |
| 22 | + |
| 23 | +The `test` command can be configured to run feature matrix testing for your crate. Configure with the `contrib/rbmt.toml` file at the crate level. |
| 24 | + |
| 25 | +```toml |
| 26 | +[test] |
| 27 | +# Examples to run with specific features enabled. |
| 28 | +# Format: "example_name:feature1 feature2" |
| 29 | +examples = [ |
| 30 | + "example1:serde", |
| 31 | + "example2:serde rand", |
| 32 | +] |
| 33 | + |
| 34 | +# Features to test with the conventional `std` feature enabled. |
| 35 | +# Tests each feature alone with std, all pairs, and all together. |
| 36 | +# Example: ["serde", "rand"] tests: std+serde, std+rand, std+serde+rand |
| 37 | +features_with_std = ["serde", "rand"] |
| 38 | + |
| 39 | +# Features to test without the `std` feature. |
| 40 | +# Tests each feature alone, all pairs, and all together. |
| 41 | +# Example: ["serde", "rand"] tests: serde, rand, serde+rand |
| 42 | +features_without_std = ["serde", "rand"] |
| 43 | + |
| 44 | +# Exact feature combinations to test. |
| 45 | +# Use for crates that don't follow conventional `std` patterns. |
| 46 | +# Each inner array is tested as-is with no automatic combinations. |
| 47 | +# Example: [["serde", "rand"], ["rand"]] tests exactly those two combinations |
| 48 | +exact_features = [ |
| 49 | + ["serde", "rand"], |
| 50 | + ["rand"], |
| 51 | +] |
| 52 | + |
| 53 | +# Features to test with an explicit `no-std` feature enabled. |
| 54 | +# Only use if your crate has a `no-std` feature (rust-miniscript pattern). |
| 55 | +# Tests each feature with no-std, all pairs, and all together. |
| 56 | +# Example: ["serde", "rand"] tests: no-std+serde, no-std+rand, no-std+serde+rand |
| 57 | +features_with_no_std = ["serde", "rand"] |
| 58 | +``` |
| 59 | + |
| 60 | +### Environment Variables |
| 61 | + |
| 62 | +* `RBMT_LOG_LEVEL=quiet` - Suppress verbose output and reduce cargo noise. |
| 63 | + |
| 64 | +## Lock Files |
| 65 | + |
| 66 | +To ensure your crate works with the full range of declared dependency versions, `rbmt` requires two lock files in your repository. |
| 67 | + |
| 68 | +* `Cargo-minimal.lock` - Minimum versions that satisfy your dependency constraints. |
| 69 | +* `Cargo-recent.lock` - Recent/updated versions of dependencies. |
| 70 | + |
| 71 | +The `rbmt lock` command generates and maintains these files for you. You can then use `--lock-file` with any command to test against either version set. |
| 72 | + |
| 73 | +### Usage |
| 74 | + |
| 75 | +**Generate/update lock files** |
| 76 | + |
| 77 | +```bash |
| 78 | +rbmt lock |
| 79 | +``` |
| 80 | + |
| 81 | +1. Verify that direct dependency versions aren't being bumped by transitive dependencies. |
| 82 | +2. Generate `Cargo-minimal.lock` with minimal versions across the entire dependency tree. |
| 83 | +3. Update `Cargo-recent.lock` with conservatively updated dependencies. |
| 84 | + |
| 85 | +**Use a specific lock file** |
| 86 | + |
| 87 | +```bash |
| 88 | +# Test with minimal versions. |
| 89 | +rbmt --lock-file minimal test stable |
| 90 | + |
| 91 | +# Test with recent versions. |
| 92 | +rbmt --lock-file recent test stable |
| 93 | + |
| 94 | +# Works with any command. |
| 95 | +rbmt --lock-file minimal lint |
| 96 | +rbmt --lock-file minimal docs |
| 97 | +``` |
| 98 | + |
| 99 | +When you specify `--lock-file`, the tool copies that lock file to `Cargo.lock` before running the command. This allows you to test your code against different dependency version constraints. |
| 100 | + |
| 101 | +## Workspace Integration |
| 102 | + |
| 103 | +`rbmt` can simply be installed globally, or as a dev-dependency for more granular control of dependency versions. |
| 104 | + |
| 105 | +### 1. Install globally |
| 106 | + |
| 107 | +Install the tool globally on your system with `cargo install`. |
| 108 | + |
| 109 | +```bash |
| 110 | + |
| 111 | +``` |
| 112 | + |
| 113 | +Then run from anywhere in your repository. |
| 114 | + |
| 115 | +```bash |
| 116 | +rbmt lint |
| 117 | +``` |
| 118 | + |
| 119 | +### 2. Add as a dev-dependency |
| 120 | + |
| 121 | +Add as a dev-dependency to a workspace member. This pins the tool version in your lockfile for reproducible builds. |
| 122 | + |
| 123 | +```toml |
| 124 | +[dev-dependencies] |
| 125 | +rust-bitcoin-maintainer-tools = "0.1.0" |
| 126 | +``` |
| 127 | + |
| 128 | +Then run via cargo. |
| 129 | + |
| 130 | +```bash |
| 131 | +cargo run --bin rbmt -- lint |
| 132 | +``` |
| 133 | + |
| 134 | +It might be worth wrapping in an [xtask](https://github.com/matklad/cargo-xtask) package for a clean interface. |
0 commit comments