From c1ad3a142ec198ef4db10b422a41fbd4e1eb2d85 Mon Sep 17 00:00:00 2001 From: Spencer Ferris <3319370+spencewenski@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:49:55 -0700 Subject: [PATCH 1/3] Use `cargo hack` to test feature powerset Also fix warnings in docs, and check that docs build without warnings in CI and husky https://github.com/roadster-rs/roadster/issues/28 --- .cargo-husky/hooks/pre-push | 6 +++ .github/workflows/ci.yml | 75 ++++++++----------------------------- src/util/serde_util.rs | 4 +- 3 files changed, 24 insertions(+), 61 deletions(-) diff --git a/.cargo-husky/hooks/pre-push b/.cargo-husky/hooks/pre-push index b792e81a..6ba6bc39 100755 --- a/.cargo-husky/hooks/pre-push +++ b/.cargo-husky/hooks/pre-push @@ -1,9 +1,15 @@ #!/usr/bin/env bash +# Exit immediately if any command returns non-zero exit status. +set -e + # `fmt` doesn't depend on which features are enabled echo "### fmt --all --check ###" cargo fmt --all --check +echo "### cargo doc --all-features --no-deps ###" +RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps + # With no features echo "### test --no-default-features --workspace ###" cargo test --no-default-features --workspace diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1582aac..8db7e630 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,71 +10,18 @@ env: CARGO_TERM_COLOR: always jobs: - roadster_no_features: - name: No features + roadster_feature_powerset: + name: Feature powerset runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: taiki-e/install-action@cargo-hack - name: Test - run: cargo test --no-fail-fast --no-default-features --workspace + run: cargo hack test --no-fail-fast --feature-powerset --no-dev-deps --workspace - name: Check - run: cargo check --no-default-features --workspace + run: cargo hack check --feature-powerset --no-dev-deps --workspace - name: Clippy - run: cargo clippy --workspace --all-targets --no-default-features -- -D warnings - - roadster_default_features: - name: Default features - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Test - run: cargo test --no-fail-fast --workspace - - name: Check - run: cargo check --workspace - - name: Clippy - run: cargo clippy --workspace --all-targets -- -D warnings - - roadster_all_features: - name: All features - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Test - run: cargo test --no-fail-fast --all-features --workspace - - name: Check - run: cargo check --all-features --workspace - - name: Clippy - run: cargo clippy --workspace --all-targets --all-features -- -D warnings - - roadster_with_all_feature_combinations: - name: Feature combos - runs-on: ubuntu-latest - strategy: - matrix: - # Todo: Is there a way to generate this list automatically? - features: - - sidekiq - - db-sql - - open-api - - sidekiq,db-sql - - sidekiq,open-api - - db-sql,open-api - steps: - - uses: actions/checkout@v4 - - name: Test - run: cargo test --no-fail-fast --no-default-features --features ${{matrix.features}} --workspace - - name: Check - run: cargo check --no-default-features --workspace - - name: Clippy - run: cargo clippy --workspace --all-targets --features ${{matrix.features}} -- -D warnings - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Clippy - run: cargo clippy --workspace -- -D warnings + run: cargo hack clippy --workspace --all-targets --feature-powerset --no-dev-deps -- -D warnings check_formatting: name: Formatting @@ -83,3 +30,13 @@ jobs: - uses: actions/checkout@v4 - name: Formatting run: cargo fmt --all --check + + check-docs: + name: Docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Docs + env: + RUSTDOCFLAGS: "-D rustdoc::all -A rustdoc::private-doc-tests" + run: cargo doc --all-features --no-deps diff --git a/src/util/serde_util.rs b/src/util/serde_util.rs index d6c32c08..2cbffe23 100644 --- a/src/util/serde_util.rs +++ b/src/util/serde_util.rs @@ -5,7 +5,7 @@ use serde::{de, Deserializer, Serializer}; use serde_derive::{Deserialize, Serialize}; use url::Url; -/// Custom deserializer to allow deserializing a string field as the given type type [T], as long as +/// Custom deserializer to allow deserializing a string field as the given type `T`, as long as /// the type implements [FromStr]. pub fn deserialize_from_str<'de, D, T>(deserializer: D) -> Result where @@ -21,7 +21,7 @@ where } } -/// Custom deserializer to allow serializing the given type [T] as a string, as long as the type +/// Custom serializer to allow serializing the given type `T` as a string, as long as the type /// implements [FromStr]. pub fn serialize_to_str(value: &T, serializer: S) -> Result where From 406d31d038a44b44ecfa2fa7778b76457a19324f Mon Sep 17 00:00:00 2001 From: Spencer Ferris <3319370+spencewenski@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:23:43 -0700 Subject: [PATCH 2/3] Remove `--no-dev-deps` where it can't be used in github ci workflow --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8db7e630..a40a1a0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,11 +17,11 @@ jobs: - uses: actions/checkout@v4 - uses: taiki-e/install-action@cargo-hack - name: Test - run: cargo hack test --no-fail-fast --feature-powerset --no-dev-deps --workspace + run: cargo hack test --no-fail-fast --feature-powerset --workspace - name: Check run: cargo hack check --feature-powerset --no-dev-deps --workspace - name: Clippy - run: cargo hack clippy --workspace --all-targets --feature-powerset --no-dev-deps -- -D warnings + run: cargo hack clippy --workspace --all-targets --feature-powerset -- -D warnings check_formatting: name: Formatting From 2a73f261ca143985d88eeb48543ac7b86d581773 Mon Sep 17 00:00:00 2001 From: Spencer Ferris <3319370+spencewenski@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:32:42 -0700 Subject: [PATCH 3/3] Fix a `rustdoc::all` warning --- .cargo-husky/hooks/pre-push | 2 +- .github/workflows/ci.yml | 2 +- src/lib.rs | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.cargo-husky/hooks/pre-push b/.cargo-husky/hooks/pre-push index 6ba6bc39..6a0f996f 100755 --- a/.cargo-husky/hooks/pre-push +++ b/.cargo-husky/hooks/pre-push @@ -8,7 +8,7 @@ echo "### fmt --all --check ###" cargo fmt --all --check echo "### cargo doc --all-features --no-deps ###" -RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps +RUSTDOCFLAGS="-D rustdoc::all" cargo doc --all-features --no-deps # With no features echo "### test --no-default-features --workspace ###" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a40a1a0f..f9c411a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,5 +38,5 @@ jobs: - uses: actions/checkout@v4 - name: Docs env: - RUSTDOCFLAGS: "-D rustdoc::all -A rustdoc::private-doc-tests" + RUSTDOCFLAGS: "-D rustdoc::all" run: cargo doc --all-features --no-deps diff --git a/src/lib.rs b/src/lib.rs index f4dfbfde..40280ef7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,7 @@ +//! # Roadster +//! +//! Todo: Add documentation + #![forbid(unsafe_code)] pub mod app;