Skip to content

Commit

Permalink
Merge #35: Run verify in CI
Browse files Browse the repository at this point in the history
b2d962c CI: Add a job that runs verify (Tobin C. Harding)
4b20b3e verify: Use clap and add version arg (Tobin C. Harding)
5d0be0e Exclude verify from workspace (Tobin C. Harding)

Pull request description:

  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 and add a job that runs it from CI.

ACKs for top commit:
  apoelstra:
    ACK b2d962c; successfully ran local tests; though "local tests" no longer include `verify` :)

Tree-SHA512: 9e1c38856882eb9d6c3146d410940af3a1b7321045e548995efe82295fb732abf94c437748c9b24c124b7dcbfe19aace808d6fb94b50af467eb5df0d9ad262f0
  • Loading branch information
tcharding committed Dec 16, 2024
2 parents dc11a47 + b2d962c commit 20d6a04
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 132 deletions.
1 change: 1 addition & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 0 additions & 58 deletions Cargo-minimal.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
58 changes: 0 additions & 58 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
1 change: 1 addition & 0 deletions verify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ edition = "2021"

[dependencies]
anyhow = "1.0.93"
clap = { version = "4.5.23", features = ["cargo"] }
regex = "1"
51 changes: 37 additions & 14 deletions verify/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = 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::<String>("version").unwrap();

if version == "all" {
verify_all_versions()?;
} else if let Ok(v) = version.parse::<Version>() {
verify_version(v)?;
} else {
let v = &args[1];
v.parse::<Version>()?
};
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";
Expand All @@ -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";
Expand Down

0 comments on commit 20d6a04

Please sign in to comment.