From 7593f1f334bb47de578b50e13917c109fa3349df Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 13 Jan 2023 07:32:30 +1100 Subject: [PATCH 1/3] Use set -ex Use the more typical form to enable bash features. Refactor only, no logic changes. --- hashes/contrib/test.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hashes/contrib/test.sh b/hashes/contrib/test.sh index bdd3462f..b5a2a8b0 100755 --- a/hashes/contrib/test.sh +++ b/hashes/contrib/test.sh @@ -1,4 +1,6 @@ -#!/bin/sh -ex +#!/bin/sh + +set -ex FEATURES="serde serde-std std core2" From db6b3f1df59ac9ce89cd94f9509262f9d00cb3ba Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 13 Jan 2023 07:44:13 +1100 Subject: [PATCH 2/3] Fix method names in rustdoc We have a few incorrect method names in the rustdocs for `internals`, fix them up. --- internals/src/hex/display.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internals/src/hex/display.rs b/internals/src/hex/display.rs index a95c4c72..f4eef37b 100644 --- a/internals/src/hex/display.rs +++ b/internals/src/hex/display.rs @@ -112,7 +112,7 @@ impl<'a> DisplayHex for &'a [u8] { } #[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(feature = "alloc"))] +#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] impl<'a> DisplayHex for &'a alloc::vec::Vec { type Display = DisplayByteSlice<'a>; @@ -130,7 +130,7 @@ impl<'a> DisplayHex for &'a alloc::vec::Vec { /// Displays byte slice as hex. /// -/// Created by [`<&[u8] as DisplayHex>::display_hex`](DisplayHex::display_hex). +/// Created by [`<&[u8] as DisplayHex>::as_hex`](DisplayHex::as_hex). pub struct DisplayByteSlice<'a> { // pub because we want to keep lengths in sync pub(crate) bytes: &'a [u8], @@ -166,7 +166,7 @@ impl<'a> fmt::UpperHex for DisplayByteSlice<'a> { /// Displays byte array as hex. /// -/// Created by [`<&[u8; LEN] as DisplayHex>::display_hex`](DisplayHex::display_hex). +/// Created by [`<&[u8; LEN] as DisplayHex>::as_hex`](DisplayHex::as_hex). pub struct DisplayArray where A::Item: Borrow { array: A, _buffer_marker: core::marker::PhantomData, From f4e7def72f30480d87fb61a3fa7292e2a98fdc80 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 13 Jan 2023 07:38:08 +1100 Subject: [PATCH 3/3] internals: Add CI test script We do not currently run the `internals` crate tests in CI. Bad rust-bitcoin developers, no biscuit. --- .github/workflows/rust.yml | 4 +-- contrib/test.sh | 2 +- internals/contrib/test.sh | 54 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100755 internals/contrib/test.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index dcd18b56..bb8fc446 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -20,7 +20,7 @@ jobs: DO_LINT: true AS_DEPENDENCY: false DO_NO_STD: true - DO_FEATURE_MATRIX: true # Currently only used in hashes crate. + DO_FEATURE_MATRIX: true DO_SCHEMARS_TESTS: true # Currently only used in hashes crate. run: ./contrib/test.sh @@ -70,7 +70,7 @@ jobs: uses: dtolnay/rust-toolchain@1.41.1 - name: Running test script env: - DO_FEATURE_MATRIX: true # Currently only used in hashes crate. + DO_FEATURE_MATRIX: true run: ./contrib/test.sh NoStd: diff --git a/contrib/test.sh b/contrib/test.sh index 2de2f1be..0bde2c60 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -2,7 +2,7 @@ set -ex -CRATES="bitcoin hashes" +CRATES="bitcoin hashes internals" for crate in ${CRATES} do diff --git a/internals/contrib/test.sh b/internals/contrib/test.sh new file mode 100755 index 00000000..f83302f7 --- /dev/null +++ b/internals/contrib/test.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +set -ex + +FEATURES="std alloc" + +cargo --version +rustc --version + +# Work out if we are using a nightly toolchain. +NIGHTLY=false +if cargo --version | grep nightly >/dev/null; then + NIGHTLY=true +fi + +# Make all cargo invocations verbose +export CARGO_TERM_VERBOSE=true + +# Defaults / sanity checks +cargo build +cargo test + +if [ "$DO_LINT" = true ] +then + cargo clippy --all-features --all-targets -- -D warnings +fi + +if [ "$DO_FEATURE_MATRIX" = true ]; then + # No features + cargo build --no-default-features + cargo test --no-default-features + + # All features + cargo build --no-default-features --features="$FEATURES" + cargo test --no-default-features --features="$FEATURES" + + # Single features + for feature in ${FEATURES} + do + cargo build --no-default-features --features="$feature" + cargo test --no-default-features --features="$feature" + done +fi + +# Build the docs if told to (this only works with the nightly toolchain) +if [ "$DO_DOCSRS" = true ]; then + RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features +fi + +# Build the docs with a stable toolchain, in unison with the DO_DOCSRS command +# above this checks that we feature guarded docs imports correctly. +if [ "$DO_DOCS" = true ]; then + RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features +fi