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

Use cargo hack to test feature powerset #30

Merged
merged 3 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .cargo-husky/hooks/pre-push
Original file line number Diff line number Diff line change
@@ -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 rustdoc::all" cargo doc --all-features --no-deps

# With no features
echo "### test --no-default-features --workspace ###"
cargo test --no-default-features --workspace
Expand Down
75 changes: 16 additions & 59 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 --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 -- -D warnings

check_formatting:
name: Formatting
Expand All @@ -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"
run: cargo doc --all-features --no-deps
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! # Roadster
//!
//! Todo: Add documentation

#![forbid(unsafe_code)]

pub mod app;
Expand Down
4 changes: 2 additions & 2 deletions src/util/serde_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, D::Error>
where
Expand All @@ -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<S, T>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down