Skip to content

Commit

Permalink
feat: Add support to config for email via SMTP (email-smtp feature) (
Browse files Browse the repository at this point in the history
…#388)

Also:

- Move contents of module `app_config` to parent `config` module
- Update `feature_powerset` feature groups
- Add `lettre` dependency for email/smtp support
- Add `cargo-insta` to `just init` command
  • Loading branch information
spencewenski authored Oct 7, 2024
1 parent eda5eb8 commit b7eeac3
Show file tree
Hide file tree
Showing 53 changed files with 628 additions and 352 deletions.
12 changes: 6 additions & 6 deletions .cargo-husky/hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ cargo fmt --all --check
echo "### build --no-default-features ###"
RUSTFLAGS="-D warnings" cargo build --no-default-features
echo "### nextest run --no-default-features ###"
cargo nextest run --no-default-features
cargo nextest run --no-default-features --no-fail-fast
# Nextest doesn't support doc tests, run those separately
echo "### test --doc --no-default-features ###"
cargo test --doc --no-default-features
cargo test --doc --no-default-features --no-fail-fast
echo "### check --no-default-features ###"
cargo check --no-default-features
echo "### clippy --all-targets --no-default-features -- -D warnings ###"
Expand All @@ -24,10 +24,10 @@ cargo clippy --all-targets --no-default-features -- -D warnings
echo "### build ###"
cargo build
echo "### nextest run ###"
cargo nextest run
cargo nextest run --no-fail-fast
# Nextest doesn't support doc tests, run those separately
echo "### test --doc ###"
cargo test --doc
cargo test --doc --no-fail-fast
echo "### check ###"
cargo check
echo "### clippy --all-targets -- -D warnings ###"
Expand All @@ -37,10 +37,10 @@ cargo clippy --all-targets -- -D warnings
echo "### build --all-features ###"
cargo build --all-features
echo "### nextest run --all-features --workspace ###"
cargo nextest run --all-features --workspace
cargo nextest run --all-features --no-fail-fast --workspace
# Nextest doesn't support doc tests, run those separately
echo "### test --doc --all-features --workspace ###"
cargo test --doc --all-features --workspace
cargo test --doc --all-features --no-fail-fast --workspace
echo "### check --all-features --workspace ###"
cargo check --all-features --workspace
echo "### clippy --workspace --all-targets --all-features -- -D warnings ###"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/feature_powerset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
# protoc is needed to build examples that have grpc enabled
- uses: taiki-e/install-action@protoc
- name: Test
run: cargo hack nextest run --no-fail-fast --feature-powerset --depth 3 --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features
run: cargo hack nextest run --no-fail-fast --feature-powerset --depth 3 --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --group-features email-smtp,email --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features
- name: Check disk usage
run: df -h

Expand All @@ -74,7 +74,7 @@ jobs:
# protoc is needed to build examples that have grpc enabled
- uses: taiki-e/install-action@protoc
- name: Doc test
run: cargo hack test --doc --no-fail-fast --feature-powerset --depth 3 --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features
run: cargo hack test --doc --no-fail-fast --feature-powerset --depth 3 --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --group-features email-smtp,email --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features

powerset_check:
name: Powerset Check
Expand All @@ -89,7 +89,7 @@ jobs:
# protoc is needed to build examples that have grpc enabled
- uses: taiki-e/install-action@protoc
- name: Check
run: cargo hack check --feature-powerset --depth 3 --no-dev-deps --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features
run: cargo hack check --feature-powerset --depth 3 --no-dev-deps --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --group-features email-smtp,email --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features

powerset_clippy:
name: Powerset Clippy
Expand All @@ -104,4 +104,4 @@ jobs:
# protoc is needed to build examples that have grpc enabled
- uses: taiki-e/install-action@protoc
- name: Clippy
run: cargo hack clippy --all-targets --feature-powerset --depth 3 --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features -- -D warnings
run: cargo hack clippy --all-targets --feature-powerset --depth 3 --skip default --group-features jwt-ietf,jwt --group-features jwt-openid,jwt --group-features open-api,http --group-features email-smtp,email --clean-per-run --log-group github-actions --exclude-no-default-features --exclude-all-features -- -D warnings
10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ http = ["dep:axum-extra", "dep:tower", "dep:tower-http"]
open-api = ["http", "dep:aide", "dep:schemars"]
sidekiq = ["dep:rusty-sidekiq", "dep:bb8", "dep:num_cpus"]
db-sql = ["dep:sea-orm", "dep:sea-orm-migration"]
email = ["dep:lettre"]
email-smtp = ["email"]
jwt = ["dep:jsonwebtoken"]
jwt-ietf = ["jwt"]
jwt-openid = ["jwt"]
Expand Down Expand Up @@ -62,6 +64,9 @@ http-body-util = "0.1.0"
sea-orm = { workspace = true, features = ["debug-print", "runtime-tokio-rustls", "sqlx-postgres", "macros"], optional = true }
sea-orm-migration = { workspace = true, features = ["runtime-tokio-rustls", "sqlx-postgres"], optional = true }

# Email
lettre = { workspace = true, features = ["serde"], optional = true }

# Workers
rusty-sidekiq = { workspace = true, optional = true }
bb8 = { version = "0.8.0", optional = true }
Expand Down Expand Up @@ -95,7 +100,7 @@ strum_macros = "0.26.0"
itertools = "0.13.0"
serde_json = "1.0.96"
toml = "0.8.0"
url = { version = "2.2.2", features = ["serde"] }
url = { version = "2.4.0", features = ["serde"] }
uuid = { version = "1.1.2", features = ["v4", "serde"] }
futures = "0.3.21"
futures-core = "0.3.31"
Expand Down Expand Up @@ -136,6 +141,9 @@ schemars = "0.8.16"
sea-orm = { version = "1.0.1" }
sea-orm-migration = { version = "1.0.0" }

# Email
lettre = "0.11.0"

# CLI
clap = { version = "4.3.0", features = ["derive"] }

Expand Down
2 changes: 1 addition & 1 deletion examples/full/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
tonic_build::configure()
.file_descriptor_set_path(out_dir.join("helloworld_descriptor.bin"))
.compile(&["proto/helloworld.proto"], &["proto"])
.compile_protos(&["proto/helloworld.proto"], &["proto"])
.unwrap();
}

Expand Down
2 changes: 1 addition & 1 deletion examples/full/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use migration::Migrator;
use roadster::app::context::AppContext;
use roadster::app::metadata::AppMetadata;
use roadster::app::App as RoadsterApp;
use roadster::config::app_config::AppConfig;
use roadster::config::AppConfig;
use roadster::error::RoadsterResult;
use roadster::service::function::service::FunctionService;
#[cfg(feature = "grpc")]
Expand Down
2 changes: 1 addition & 1 deletion examples/leptos-ssr/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use migration::Migrator;
use roadster::app::context::AppContext;
use roadster::app::metadata::AppMetadata;
use roadster::app::App as RoadsterApp;
use roadster::config::app_config::AppConfig;
use roadster::config::environment::Environment;
use roadster::config::AppConfig;
use roadster::error::RoadsterResult;
use roadster::service::http::service::HttpService;
use roadster::service::registry::ServiceRegistry;
Expand Down
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ help:

# Run all of our unit tests.
test:
cargo nextest run --all-features
cargo test --doc --all-features
cargo nextest run --all-features --no-fail-fast
cargo test --doc --all-features --no-fail-fast

# Run all of our unit tests whenever files in the repo change.
test-watch:
Expand Down Expand Up @@ -50,4 +50,4 @@ validate-codecov-config:

# Initialize a new installation of the repo (e.g., install deps)
init:
cargo binstall cargo-nextest cargo-llvm-cov sea-orm-cli
cargo binstall cargo-nextest cargo-llvm-cov sea-orm-cli cargo-insta cargo-minimal-versions cargo-hack
2 changes: 1 addition & 1 deletion src/api/http/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn api_schema_route(context: &AppContext) -> &str {
#[cfg(test)]
mod tests {
use super::*;
use crate::config::app_config::AppConfig;
use crate::config::AppConfig;
use rstest::rstest;

// Todo: Is there a better way to structure these tests (and the ones in `health` and `ping`)
Expand Down
2 changes: 1 addition & 1 deletion src/api/http/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn health_get_docs(op: TransformOperation) -> TransformOperation {
#[cfg(test)]
mod tests {
use crate::app::context::AppContext;
use crate::config::app_config::AppConfig;
use crate::config::AppConfig;
use rstest::rstest;

// Todo: Is there a better way to structure this test (and the ones in `docs` and `ping`)
Expand Down
2 changes: 1 addition & 1 deletion src/api/http/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn ping_get_docs(op: TransformOperation) -> TransformOperation {
#[cfg(test)]
mod tests {
use crate::app::context::AppContext;
use crate::config::app_config::AppConfig;
use crate::config::AppConfig;
use rstest::rstest;

// Todo: Is there a better way to structure this test (and the ones in `health` and `ping`)
Expand Down
2 changes: 1 addition & 1 deletion src/app/context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::app::metadata::AppMetadata;
use crate::app::App;
use crate::config::app_config::AppConfig;
use crate::config::AppConfig;
use crate::error::RoadsterResult;
use crate::health_check::registry::HealthCheckRegistry;
use crate::health_check::HealthCheck;
Expand Down
2 changes: 1 addition & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ use crate::api::cli::MockTestCli;
#[cfg(feature = "cli")]
use crate::api::cli::RunCommand;
use crate::app::metadata::AppMetadata;
use crate::config::app_config::AppConfig;
#[cfg(not(feature = "cli"))]
use crate::config::environment::Environment;
use crate::config::AppConfig;
use crate::error::RoadsterResult;
use crate::health_check::registry::HealthCheckRegistry;
use crate::lifecycle::registry::LifecycleHandlerRegistry;
Expand Down
2 changes: 1 addition & 1 deletion src/app/roadster_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::app;
use crate::app::context::AppContext;
use crate::app::metadata::AppMetadata;
use crate::app::App;
use crate::config::app_config::AppConfig;
use crate::config::AppConfig;
use crate::error::RoadsterResult;
use crate::health_check::registry::HealthCheckRegistry;
use crate::health_check::HealthCheck;
Expand Down
Loading

0 comments on commit b7eeac3

Please sign in to comment.