From 32b790be7bd205b5484083f52a326579cc02f3b8 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 23 Nov 2022 10:26:03 +1000 Subject: [PATCH] change(ci): Fail CI if there are doc warnings (#5683) * Fail CI if there are doc warnings * Try a different syntax * Use an env var * Fix spacing, add reference * Allow intra-doc links * Note that rustdoc settings need to stay in sync --- .cargo/config.toml | 15 ++++++++++----- .github/workflows/lint.yml | 7 +++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 0d373727..94136187 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -36,10 +36,9 @@ rustflags = [ "-Wclippy::unnecessary_cast", # Incomplete code - "-Wmissing_docs", "-Wclippy::dbg_macro", "-Wclippy::todo", - + # Manual debugging output. # Use tracing::trace!() or tracing::debug!() instead. "-Wclippy::print_stdout", @@ -49,12 +48,18 @@ rustflags = [ # Code styles we want to accept "-Aclippy::try_err", - # Links in public docs can point to private items. - "-Arustdoc::private_intra_doc_links", - # Panics "-Wclippy::fallible_impl_from", "-Wclippy::unwrap_in_result", + + # Documentation + "-Wmissing_docs", + + # These rustdoc -A and -W settings must be the same as the RUSTDOCFLAGS in: + # https://github.com/ZcashFoundation/zebra/blob/main/.github/workflows/lint.yml#L152 + + # Links in public docs can point to private items. + "-Arustdoc::private_intra_doc_links", # TODOs: # `cargo fix` might help do these fixes, diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8cbdbbc4..e7810947 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -143,6 +143,13 @@ jobs: runs-on: ubuntu-latest needs: changed-files if: ${{ needs.changed-files.outputs.rust == 'true' }} + # cargo doc doesn't support '-- -D warnings', so we have to add it here + # https://github.com/rust-lang/cargo/issues/8424#issuecomment-774662296 + # + # These -A and -W settings must be the same as the rustdoc settings in: + # https://github.com/ZcashFoundation/zebra/blob/main/.cargo/config.toml#L53 + env: + RUSTDOCFLAGS: -D warnings -A rustdoc::private_intra_doc_links steps: - uses: actions/checkout@v3.1.0