Skip to content

Commit

Permalink
Add rustdoc tests to CI
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Carl Jones <[email protected]>
  • Loading branch information
dannycjones committed Jan 6, 2025
1 parent 4284e64 commit b4eb032
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,36 @@ jobs:
- name: Build CRT binding documentation
run: cargo doc --no-deps -p mountpoint-s3-crt

doctests:
name: rustdoc tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
# setup-rust-toolchain sets "-D warnings" by default, and Rust treats any warning as compile error.
# We need to this currently because `vendor/fuser` contains some warnings and it breaks the build.
rustflags: ""
components: rust-docs
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ runner.arch }}-${{ github.job }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run doctests for all crates
# Some of the generated bindings seem to be interpretted as rustdoc tests, skip them for now.
run: cargo test --doc -- --skip=mountpoint_s3_crt_sys::generated

deny:
name: Licenses
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions mountpoint-s3-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
//! To construct a new S3 client and download an object from a bucket in the `us-east-1` region:
//! ```no_run
//! # async fn test() {
//! use futures::TryStreamExt;
//! use futures::{TryFutureExt, TryStreamExt};
//! use mountpoint_s3_client::types::GetObjectParams;
//! use mountpoint_s3_client::{S3CrtClient, ObjectClient};
//!
//! let client = S3CrtClient::new(Default::default()).expect("client construction failed");
//!
//! let response = client.get_object("my-bucket", "my-key", &GetObjectParams::new().await.expect("get_object failed"));
//! let response = client.get_object("my-bucket", "my-key", &GetObjectParams::new()).await.expect("get_object failed");
//! let body = response.map_ok(|(offset, body)| body.to_vec()).try_concat().await.expect("body streaming failed");
//! # }
//! ```
Expand All @@ -33,8 +34,7 @@
//!
//! let config = S3ClientConfig::new()
//! .endpoint_config(EndpointConfig::new("us-west-2"))
//! .auth_config(S3ClientAuthConfig::NoSigning)
//! .user_agent_prefix("my-test-client");
//! .auth_config(S3ClientAuthConfig::NoSigning);
//! let client = S3CrtClient::new(config).expect("client construction failed");
//! ```
//!
Expand Down

0 comments on commit b4eb032

Please sign in to comment.