internals: Add CI test script

We do not currently run the `internals` crate tests in CI. Bad
rust-bitcoin developers, no biscuit.
This commit is contained in:
Tobin C. Harding 2023-01-13 07:38:08 +11:00
parent db6b3f1df5
commit f4e7def72f
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
3 changed files with 57 additions and 3 deletions

View File

@ -20,7 +20,7 @@ jobs:
DO_LINT: true DO_LINT: true
AS_DEPENDENCY: false AS_DEPENDENCY: false
DO_NO_STD: true 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. DO_SCHEMARS_TESTS: true # Currently only used in hashes crate.
run: ./contrib/test.sh run: ./contrib/test.sh
@ -70,7 +70,7 @@ jobs:
uses: dtolnay/rust-toolchain@1.41.1 uses: dtolnay/rust-toolchain@1.41.1
- name: Running test script - name: Running test script
env: env:
DO_FEATURE_MATRIX: true # Currently only used in hashes crate. DO_FEATURE_MATRIX: true
run: ./contrib/test.sh run: ./contrib/test.sh
NoStd: NoStd:

View File

@ -2,7 +2,7 @@
set -ex set -ex
CRATES="bitcoin hashes" CRATES="bitcoin hashes internals"
for crate in ${CRATES} for crate in ${CRATES}
do do

54
internals/contrib/test.sh Executable file
View File

@ -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