From 41f2dcf6ae83d3d8412ea42d212d997b49b1b8ce Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Sat, 24 Dec 2022 09:50:41 +1100 Subject: [PATCH] Improve test coverage for docs build Currently the docs build commands in `hashes` and `bitcoin` differ, they should be the same. Add a command `cargo doc` to improve coverage e.g., recently we botched the feature guarding but since CI only runs `cargo rustdoc` with custom compiler conditional set we didn't catch it. Run docs in CI using nightly and stable toolchains as required. --- .github/workflows/rust.yml | 3 ++- bitcoin/contrib/test.sh | 8 +++++++- hashes/contrib/test.sh | 8 +++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bb8fc446..940b6b68 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -20,6 +20,7 @@ jobs: DO_LINT: true AS_DEPENDENCY: false DO_NO_STD: true + DO_DOCS: true DO_FEATURE_MATRIX: true DO_SCHEMARS_TESTS: true # Currently only used in hashes crate. run: ./contrib/test.sh @@ -55,7 +56,7 @@ jobs: DO_BENCH: true AS_DEPENDENCY: false DO_NO_STD: true - DO_DOCS: true + DO_DOCSRS: true run: ./contrib/test.sh MSRV: diff --git a/bitcoin/contrib/test.sh b/bitcoin/contrib/test.sh index 0dd15588..4657f0aa 100755 --- a/bitcoin/contrib/test.sh +++ b/bitcoin/contrib/test.sh @@ -80,8 +80,14 @@ cargo run --example ecdsa-psbt --features=bitcoinconsensus cargo run --example taproot-psbt --features=rand-std,bitcoinconsensus # 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="--cfg docsrs" cargo +nightly rustdoc --all-features -- -D rustdoc::broken-intra-doc-links -D warnings + RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features fi # Fuzz if told to diff --git a/hashes/contrib/test.sh b/hashes/contrib/test.sh index b5a2a8b0..4bea1767 100755 --- a/hashes/contrib/test.sh +++ b/hashes/contrib/test.sh @@ -57,8 +57,14 @@ if [ "$DO_SCHEMARS_TESTS" = true ]; then 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="--cfg docsrs" cargo doc --features="$FEATURES" + RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features fi # Webassembly stuff