Skip to content

Commit 95a2fd3

Browse files
committed
Merge #29: Convert rbmt to a cargo subcommand and move configs to the root
2aa3f6c Move config to root, not under contrib (Nick Johnson) 83680d9 Rename cargo-rbmt following cargo subcommand conventions (Nick Johnson) Pull request description: More learnings from working on the rust-psbt integration. The first patch renames the package and crate to `cargo-rbmt` which follows the [cargo subcommand convention](https://doc.rust-lang.org/cargo/reference/external-tools.html#custom-subcommands) so the tool can be called with `cargo rbmt...` after it is installed with `cargo install`. It can still be called with `cargo-rbmt` as well. The second patch moves the config out of `contrib`. I put it there initially just following the style of the old shell scripts, but I think it is just confusing once it is the only thing sitting there (and is toml). ACKs for top commit: tcharding: ACK 2aa3f6c Tree-SHA512: 46db3492b4e5be6cc713df673989df176930a942b1b257b4770a0544c7f359ff4af1238eafddef0157f46dd22d2b8d4ed14ad20ae5be9c36e87943861153b6d2
2 parents 4eb8e3b + 2aa3f6c commit 95a2fd3

File tree

14 files changed

+47
-39
lines changed

14 files changed

+47
-39
lines changed

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
members = [
33
"releases",
4-
"tasks",
4+
"cargo-rbmt",
55
]
66
resolver = "2"
File renamed without changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
2-
name = "rust-bitcoin-maintainer-tools"
2+
name = "cargo-rbmt"
33
version = "0.1.0"
44
authors = ["Nick Johnson <[email protected]>"]
55
license = "CC0-1.0"
66
edition = "2021"
77
rust-version = "1.74.0"
88

99
[[bin]]
10-
name = "rbmt"
10+
name = "cargo-rbmt"
1111
path = "src/main.rs"
1212

1313
[dependencies]

tasks/README.md renamed to cargo-rbmt/README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Maintainer tools for Rust-based projects in the Bitcoin domain. Built with [xshe
44

55
## Configuration
66

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.
7+
Configuration for `rbmt` is stored in `rbmt.toml`. The file can live at both the workspace root (e.g. `$ROOT/rbmt.toml`) as well as per-package (e.g. `$ROOT/$PACKAGE/rbmt.toml`) within a repository.
88

99
### Lint
1010

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).
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 package if only one package in a repository).
1212

1313
```toml
1414
[lint]
@@ -20,7 +20,7 @@ allowed_duplicates = [
2020

2121
### Test
2222

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.
23+
The `test` command can be configured to run feature matrix testing for your package. Configure with the `rbmt.toml` file at the package level.
2424

2525
```toml
2626
[test]
@@ -42,7 +42,7 @@ features_with_std = ["serde", "rand"]
4242
features_without_std = ["serde", "rand"]
4343

4444
# Exact feature combinations to test.
45-
# Use for crates that don't follow conventional `std` patterns.
45+
# Use for packages that don't follow conventional `std` patterns.
4646
# Each inner array is tested as-is with no automatic combinations.
4747
# Example: [["serde", "rand"], ["rand"]] tests exactly those two combinations
4848
exact_features = [
@@ -51,7 +51,7 @@ exact_features = [
5151
]
5252

5353
# Features to test with an explicit `no-std` feature enabled.
54-
# Only use if your crate has a `no-std` feature (rust-miniscript pattern).
54+
# Only use if your package has a `no-std` feature (rust-miniscript pattern).
5555
# Tests each feature with no-std, all pairs, and all together.
5656
# Example: ["serde", "rand"] tests: no-std+serde, no-std+rand, no-std+serde+rand
5757
features_with_no_std = ["serde", "rand"]
@@ -63,19 +63,19 @@ features_with_no_std = ["serde", "rand"]
6363

6464
## Lock Files
6565

66-
To ensure your crate works with the full range of declared dependency versions, `rbmt` requires two lock files in your repository.
66+
To ensure your package works with the full range of declared dependency versions, `cargo-rbmt` requires two lock files in your repository.
6767

6868
* `Cargo-minimal.lock` - Minimum versions that satisfy your dependency constraints.
6969
* `Cargo-recent.lock` - Recent/updated versions of dependencies.
7070

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.
71+
The `lock` command generates and maintains these files for you. You can then use `--lock-file` with any command to test against either version set.
7272

7373
### Usage
7474

7575
**Generate/update lock files**
7676

7777
```bash
78-
rbmt lock
78+
cargo rbmt lock
7979
```
8080

8181
1. Verify that direct dependency versions aren't being bumped by transitive dependencies.
@@ -86,49 +86,49 @@ rbmt lock
8686

8787
```bash
8888
# Test with minimal versions.
89-
rbmt --lock-file minimal test stable
89+
cargo rbmt --lock-file minimal test stable
9090

9191
# Test with recent versions.
92-
rbmt --lock-file recent test stable
92+
cargo rbmt --lock-file recent test stable
9393

9494
# Works with any command.
95-
rbmt --lock-file minimal lint
96-
rbmt --lock-file minimal docs
95+
cargo rbmt --lock-file minimal lint
96+
cargo rbmt --lock-file minimal docs
9797
```
9898

9999
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.
100100

101101
## Workspace Integration
102102

103-
`rbmt` can simply be installed globally, or as a dev-dependency for more granular control of dependency versions.
103+
`cargo-rbmt` can simply be installed globally on a system or added as a dev-dependency to a package.
104104

105-
### 1. Install globally
105+
### 1. Install on system
106106

107107
Install the tool globally on your system with `cargo install`.
108108

109109
```bash
110-
cargo install rust-bitcoin-maintainer-tools@0.1.0
110+
cargo install cargo-rbmt@0.1.0
111111
```
112112

113-
Then run from anywhere in your repository.
113+
Then run from anywhere in your repository as a cargo subcommand. It can also be called directly as `cargo-rbmt`.
114114

115115
```bash
116-
rbmt lint
116+
cargo rbmt lint
117117
```
118118

119119
### 2. Add as a dev-dependency
120120

121-
Add as a dev-dependency to a workspace member. This pins the tool version in your lockfile for reproducible builds.
121+
Add as a dev-dependency to a workspace member. This pins the tool version in your lockfile for reproducible builds. But this also means that `cargo-rbmt` dependencies could influence version resolution for the workspace.
122122

123123
```toml
124124
[dev-dependencies]
125-
rust-bitcoin-maintainer-tools = "0.1.0"
125+
cargo-rbmt = "0.1.0"
126126
```
127127

128128
Then run via cargo.
129129

130130
```bash
131-
cargo run --bin rbmt -- lint
131+
cargo run --bin cargo-rbmt -- lint
132132
```
133133

134134
It might be worth wrapping in an [xtask](https://github.com/matklad/cargo-xtask) package for a clean interface.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use xshell::{cmd, Shell};
77
const LOG_LEVEL_ENV_VAR: &str = "RBMT_LOG_LEVEL";
88

99
/// Path to the RBMT configuration file relative to workspace/crate root.
10-
pub const CONFIG_FILE_PATH: &str = "contrib/rbmt.toml";
10+
pub const CONFIG_FILE_PATH: &str = "rbmt.toml";
1111

1212
/// Check if we're in quiet mode via environment variable.
1313
pub fn is_quiet_mode() -> bool {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::environment::{get_crate_dirs, quiet_println, CONFIG_FILE_PATH};
55
use crate::quiet_cmd;
66
use crate::toolchain::{check_toolchain, Toolchain};
77

8-
/// Lint configuration loaded from contrib/rbmt.toml.
8+
/// Lint configuration loaded from rbmt.toml.
99
#[derive(Debug, serde::Deserialize, Default)]
1010
#[serde(default)]
1111
struct Config {

0 commit comments

Comments
 (0)