Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test coverage for docs build #1505

Merged
merged 3 commits into from Feb 10, 2023

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Dec 23, 2022

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.

Done after seeing: #1504 and CI should fail on this PR until 1504 is in.

# We use rustdoc so that we can check for broken links.
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly rustdoc --all-features -- -D rustdoc::broken-intra-doc-links -D warnings
# This, in unison with the command above, checks that we feature guarded docs imports correctly.
cargo +nightly doc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're doing this we should still have all features and deny warnings, just docsrs disabled. And probably test it on stable instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and face palm for --all-features and deny warnings. For test on stable, seems reasonably, will require more thinking though since DO_DOCS is only run on nightly, perhaps we need to agree on what is expected from each toolchain since this is similar to the discussion on features only working on some toolchains (#1498 (comment))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just adding +stable should work? It's a bit ugly hack, yes. Or just split it up into DO_DOCSRS and DO_DOCS.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm missing something the stable toolchain won't be installed on the VM when we use DO_DOCS. I used your DO_DOCSRS idea, adding a DO_DOCS for stable builds.

# We use rustdoc so that we can check for broken links.
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly rustdoc --all-features -- -D rustdoc::broken-intra-doc-links -D warnings
# This, in unison with the command above, checks that we feature guarded docs imports correctly.
cargo +nightly doc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@tcharding
Copy link
Member Author

@apoelstra if this merges it will likely mean you have to modify your test scripts if you are testing docs builds locally before merging.

Kixunil
Kixunil previously approved these changes Dec 28, 2022
Copy link
Collaborator

@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 43e3d2b

@Kixunil Kixunil dismissed their stale review December 28, 2022 11:53

Didn't notice cargo +stable doc vs cargo doc +stable

@tcharding
Copy link
Member Author

My bad, fixed.

@tcharding tcharding force-pushed the 12-24-ci-docs branch 2 times, most recently from 3892d2f to 44e56f9 Compare December 29, 2022 00:56
@Kixunil
Copy link
Collaborator

Kixunil commented Dec 30, 2022

There are conflicts now.

@tcharding
Copy link
Member Author

Rebase only, no other changes.

@apoelstra
Copy link
Member

Thanks for the heads up! I'm not currently testing docs but I should start.

apoelstra
apoelstra previously approved these changes Jan 1, 2023
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK fb23a94

Copy link
Collaborator

@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this contain changes to CI?

@tcharding
Copy link
Member Author

Shouldn't this contain changes to CI?

Oops, thanks man. Now includes CI changes.

@tcharding tcharding force-pushed the 12-24-ci-docs branch 2 times, most recently from 19bf3ac to 48df5ad Compare January 9, 2023 02:45
@tcharding
Copy link
Member Author

Now includes additional patch to fix docs build warnings.

if [ "$DO_DOCS" = true ]; then
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly rustdoc --all-features -- -D rustdoc::broken-intra-doc-links -D warnings || exit 1
cargo +stable doc --all-features
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this have -D warnings as well?

Copy link
Member Author

@tcharding tcharding Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-D warnings is a cargo rustdoc option not a cargo doc option (I learned while doing this PR).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can still put it into RUSTDOCFLAGS. cargo doc literally runs rustdoc inside.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL, that's awesome I didn't realise. I changed both invocations to use cargo doc to make it uniform. While testing I noticed we do not have a contrib/test.sh file for internals, will add.

@Kixunil
Copy link
Collaborator

Kixunil commented Jan 13, 2023

Looks like #1545 must go in first.

@Kixunil Kixunil added the Blocked Some other work is required to make this possible label Jan 13, 2023
We already use `set -ex`, adding an explicit exit on command fail is
redundant.
Cargo emits various warnings when building the docs:

 warning: this URL is not a hyperlink

As suggested, add angle brackets to create automatic links.
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.
@tcharding
Copy link
Member Author

Rebase only, no other changes.

@Kixunil Kixunil removed the Blocked Some other work is required to make this possible label Jan 16, 2023
apoelstra

This comment was marked as duplicate.

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6dfacd1

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 41f2dcf

@tcharding
Copy link
Member Author

No changes since your ack of fb23a94 except for rebasing @Kixunil. If you get a second can you ack this one again please.

Copy link
Collaborator

@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 41f2dcf

@apoelstra apoelstra merged commit 9615dd1 into rust-bitcoin:master Feb 10, 2023
@tcharding tcharding deleted the 12-24-ci-docs branch February 13, 2023 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants