Skip to content

Commit

Permalink
tests(iroh): Feature-flag the doc test (#2983)
Browse files Browse the repository at this point in the history
## Description

This test can only work if the feature is enabled.  Feature-flag the
entire test contents.

Closes #2950.

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist

- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
  • Loading branch information
flub authored Dec 2, 2024
1 parent 4ffbd13 commit b30f218
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ jobs:
env:
RUSTC_WRAPPER: "sccache"
SCCACHE_GHA_ENABLED: "on"
RUSTDOCFLAGS: --cfg docsrs
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
Expand All @@ -226,8 +227,9 @@ jobs:

- name: Docs
run: cargo doc --workspace --all-features --no-deps --document-private-items
env:
RUSTDOCFLAGS: --cfg docsrs

- name: Docs (default features)
run: cargo doc --workspace --no-deps

clippy_check:
timeout-minutes: 30
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,25 @@ jobs:

- name: doctests
if: ${{ (! inputs.flaky) && matrix.features == 'all' }}
env:
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
run: |
if [ -n "${{ runner.debug }}" ]; then
export RUST_LOG=TRACE
else
export RUST_LOG=DEBUG
fi
cargo test --workspace --all-features --doc
# We can not check the doctest features by only compiling them,
# so are forced to run them once more.
- name: Check doctest features
if: ${{ ! inputs.flaky }}
env:
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
run: |
for i in ${CRATES_LIST//,/ }
do
echo "Checking $i doctest $FEATURES"
echo cargo test -p $i --doc $FEATURES
cargo test -p $i --doc $FEATURES
done
build_and_test_windows:
timeout-minutes: 30
name: "Tests"
Expand Down
4 changes: 2 additions & 2 deletions iroh-relay/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ pub struct QuicConfig {
pub bind_addr: SocketAddr,
/// The TLS server configuration for the QUIC server.
///
/// If this [`rustls::ServerConfig`] does not support
/// TLS 1.3, the QUIC server will fail at [`QuicServer::spawn`].
/// If this [`rustls::ServerConfig`] does not support TLS 1.3, the QUIC server will fail
/// to spawn.
pub server_config: rustls::ServerConfig,
}

Expand Down
24 changes: 19 additions & 5 deletions iroh/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
//!
//! - The [`PkarrResolver`] which can perform lookups from designated [pkarr relay servers]
//! using HTTP.
//!
//! - The [`LocalSwarmDiscovery`] discovers iroh nodes present on the local network,
//! very similar to mdNS.
#![cfg_attr(
feature = "discovery-local-network",
doc = "- [`LocalSwarmDiscovery`]: local_swarm_discovery::LocalSwarmDiscovery
very similar to mDNS."
)]
//!
//! - The [`DhtDiscovery`] also uses the [`pkarr`] system but can also publish and lookup
//! records to/from the Mainline DHT.
Expand Down Expand Up @@ -67,10 +69,18 @@
//! # }
//! ```
//!
//! To also enable [`LocalSwarmDiscovery`], it can be added as another service in the
//! To also enable
#![cfg_attr(feature = "discovery-local-network", doc = "[`LocalSwarmDiscovery`]")]
#![cfg_attr(
not(feature = "discovery-local-network"),
doc = "`LocalSwarmDiscovery`"
)]
//! it can be added as another service in the
//! [`ConcurrentDiscovery`]:
//!
//! ```no_run
//! # #[cfg(feature = "discovery-local-network")]
//! # {
//! # use iroh::discovery::dns::DnsDiscovery;
//! # use iroh::discovery::local_swarm_discovery::LocalSwarmDiscovery;
//! # use iroh::discovery::pkarr::PkarrPublisher;
Expand All @@ -86,6 +96,7 @@
//! ]);
//! # Ok(())
//! # }
//! # }
//! ```
//!
//! [`RelayUrl`]: crate::relay::RelayUrl
Expand All @@ -94,9 +105,12 @@
//! [Number 0]: https://n0.computer
//! [`PkarrResolver`]: pkarr::PkarrResolver
//! [`PkarrPublisher`]: pkarr::PkarrPublisher
//! [`LocalSwarmDiscovery`]: local_swarm_discovery::LocalSwarmDiscovery
//! [`DhtDiscovery`]: pkarr::dht::DhtDiscovery
//! [pkarr relay servers]: https://pkarr.org/#servers
#![cfg_attr(
feature = "discovery-local-network",
doc = "[`LocalSwarmDiscovery`]: local_swarm_discovery::LocalSwarmDiscovery"
)]

use std::time::Duration;

Expand Down

0 comments on commit b30f218

Please sign in to comment.