From 5d0be0ef701c1dec59e2c75eec6c35b94ca9859e Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 13 Dec 2024 12:20:48 +1100 Subject: [PATCH 1/3] Exclude verify from workspace The `verify` crate is a dev tool and should not have been included in the workspace because it has no lock file requirements. Exclude `verify` from the workspace and update the lock files. --- Cargo-minimal.lock | 58 ---------------------------------------------- Cargo-recent.lock | 58 ---------------------------------------------- Cargo.toml | 4 ++-- 3 files changed, 2 insertions(+), 118 deletions(-) diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock index adcaf0d..0d406fe 100644 --- a/Cargo-minimal.lock +++ b/Cargo-minimal.lock @@ -2,21 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" - [[package]] name = "arrayvec" version = "0.7.4" @@ -184,12 +169,6 @@ version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - [[package]] name = "minreq" version = "2.11.2" @@ -219,35 +198,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "regex" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" - [[package]] name = "ryu" version = "1.0.18" @@ -333,14 +283,6 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" -[[package]] -name = "verify" -version = "0.1.0" -dependencies = [ - "anyhow", - "regex", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo-recent.lock b/Cargo-recent.lock index adcaf0d..0d406fe 100644 --- a/Cargo-recent.lock +++ b/Cargo-recent.lock @@ -2,21 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" - [[package]] name = "arrayvec" version = "0.7.4" @@ -184,12 +169,6 @@ version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - [[package]] name = "minreq" version = "2.11.2" @@ -219,35 +198,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "regex" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" - [[package]] name = "ryu" version = "1.0.18" @@ -333,14 +283,6 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" -[[package]] -name = "verify" -version = "0.1.0" -dependencies = [ - "anyhow", - "regex", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 9c329fd..4535a60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] -members = ["client", "types", "jsonrpc", "verify"] -exclude = ["integration_test", "node"] +members = ["client", "types", "jsonrpc"] +exclude = ["integration_test", "node", "verify"] resolver = "2" [patch.crates-io.corepc-client] From 4b20b3e160f42c9d6bd9ba9bad5458697930d1da Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 16 Dec 2024 11:27:28 +1100 Subject: [PATCH 2/3] verify: Use clap and add version arg Add a version arg to the `verify` command. Use `clap` to do so. --- verify/Cargo.toml | 1 + verify/src/main.rs | 51 +++++++++++++++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/verify/Cargo.toml b/verify/Cargo.toml index 573376d..5a66851 100644 --- a/verify/Cargo.toml +++ b/verify/Cargo.toml @@ -5,4 +5,5 @@ edition = "2021" [dependencies] anyhow = "1.0.93" +clap = { version = "4.5.23", features = ["cargo"] } regex = "1" diff --git a/verify/src/main.rs b/verify/src/main.rs index 765f5c0..568cbaf 100644 --- a/verify/src/main.rs +++ b/verify/src/main.rs @@ -9,36 +9,59 @@ //! - That there is a `model` type if required. //! - That the method has an integration test. -use std::env; +use std::process; use anyhow::Result; +use clap::{arg, Command}; use verify::method::{Method, Return}; use verify::versioned::{self, Status}; use verify::{method, model, ssot, Version}; -/// The default version of Core if no command line argument is provided. -const DEFAULT_VERSION: Version = Version::V17; +// TODO: Enable running from any directory, currently errors if run from `src/`. +// TODO: Add a --quiet option. -// FIXME: Enable running from any directory, currently errors if run from `src/`. +const VERSIONS: [Version; 2] = [Version::V17, Version::V18]; fn main() -> Result<()> { - let args: Vec = env::args().collect(); - - let version = if args.len() < 2 { - DEFAULT_VERSION + let cmd = Command::new("verify") + .args([ + arg!([version] "Verify specific version of Core (use \"all\" for all versions)").required(true), + ]); + + let matches = cmd.clone().get_matches(); + let version = matches.get_one::("version").unwrap(); + + if version == "all" { + verify_all_versions()?; + } else if let Ok(v) = version.parse::() { + verify_version(v)?; } else { - let v = &args[1]; - v.parse::()? - }; - println!("\nVerifying support for Bitcoin Core {}\n", version); + eprint!("Unrecognised version: {} (supported versions:", version); + for version in VERSIONS { + eprint!(" {}", version); + } + eprintln!(")"); + process::exit(1); + } + Ok(()) +} + +fn verify_all_versions() -> Result<()> { + for version in VERSIONS { + println!("Verifying for Bitcoin Core version {} ...\n", version); + verify_version(version)?; + } + Ok(()) +} +fn verify_version(version: Version) -> Result<()> { let s = format!("{}::METHOD data", version); let msg = format!("Checking that the {} list is correct", s); check(&msg); let correct = verify_correct_methods(version, method::all_methods(version), &s)?; close(correct); if !correct { - std::process::exit(1); + process::exit(1); } let s = "rustdoc version specific rustdocs"; @@ -47,7 +70,7 @@ fn main() -> Result<()> { let correct = verify_correct_methods(version, method::all_methods(version), s)?; close(correct); if !correct { - std::process::exit(1); + process::exit(1); } let msg = "Checking that the status claimed in the version specific rustdocs is correct"; From b2d962ca633a51512d3bc7db6f8917a2c8d0b65e Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 16 Dec 2024 10:32:03 +1100 Subject: [PATCH 3/3] CI: Add a job that runs verify Add a job that runs `verify --all` to CI. --- .github/workflows/README.md | 1 + .github/workflows/rust.yaml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index fc18863..1dc043e 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -22,6 +22,7 @@ Run from `rust.yml` unless stated otherwise. Total 11 jobs. 8. `Docs` 9. `Docsrs` 10. `Format` +11. `Verify` +15 jobs - 1 for each supported version of Core. diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index df96b42..e93d7f3 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -188,6 +188,20 @@ jobs: - name: "Check formatting" run: cargo fmt --all -- --check + Verify: # 1 job, run `verify` directly. + name: Verify - stable toolchain + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + - name: "Select toolchain" + uses: dtolnay/rust-toolchain@stable + - name: "Run the verify program" + # Verify all versions (known to the verify program) + run: cd verify && cargo run all + Integration: # 1 job for each bitcoind version we support. name: Integration tests - stable toolchain runs-on: ubuntu-latest