From ef733ec2d62a530818f4ca3091586a34bbb3edaf Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Tue, 5 Mar 2024 14:24:00 +0000 Subject: [PATCH] [ci] use `cargo deadlinks` to check for dead links Since `cargo deadlinks` is just a link-checking wrapper around `cargo doc`, we can simply replace our `doc` invocation with `deadlinks` to get the benefits of both. --- .github/workflows/ci.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b27fb5a168..1689c5356a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -277,6 +277,17 @@ jobs: export RUSTDOCFLAGS="${{ matrix.toolchain == 'nightly' && '-Z unstable-options --document-hidden-items' || '' }} $RUSTDOCFLAGS $METADATA_DOCS_RS_RUSTDOC_ARGS" ./cargo.sh +${{ matrix.toolchain }} doc --document-private-items --package ${{ matrix.crate }} ${{ matrix.features }} + - name: Check dead links + run: | + cargo install -q cargo-deadlinks --version 0.8.1 + METADATA_DOCS_RS_RUSTDOC_ARGS="$(cargo metadata --format-version 1 | \ + jq -r ".packages[] | select(.name == \"zerocopy\").metadata.docs.rs.\"rustdoc-args\".[]" | tr '\n' ' ')" + # Nearly identical to the above `cargo doc` invocation, but invoking + # `cargo deadlinks` instead. + export RUSTDOCFLAGS="$RUSTDOCFLAGS $METADATA_DOCS_RS_RUSTDOC_ARGS" + ./cargo.sh +${{ matrix.toolchain }} deadlinks --check-intra-doc-links -- --document-private-items --package ${{ matrix.crate }} ${{ matrix.features }} + if: matrix.toolchain == 'nightly' + # Check semver compatibility with the most recently-published version on # crates.io. We do this in the matrix rather than in its own job so that it # gets run on different targets. Some of our API is target-specific (e.g., @@ -412,11 +423,12 @@ jobs: # in parallel. # # [1] https://stackoverflow.com/a/42139535/836390 - cargo check --workspace --tests &> /dev/null & - cargo metadata &> /dev/null & - cargo install cargo-readme --version 3.2.0 &> /dev/null & - cargo install --locked kani-verifier &> /dev/null & - cargo kani setup &> /dev/null & + cargo check --workspace --tests &> /dev/null & + cargo metadata &> /dev/null & + cargo install cargo-readme --version 3.2.0 &> /dev/null & + cargo install cargo-deadlinks --version 0.8.1 &> /dev/null & + cargo install --locked kani-verifier &> /dev/null & + cargo kani setup &> /dev/null & wait