From f4e7def72f30480d87fb61a3fa7292e2a98fdc80 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 13 Jan 2023 07:38:08 +1100 Subject: [PATCH] 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