From 368b1126f73f47c7ec30fe523834f6a0962a193b Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Mon, 12 Aug 2024 11:27:58 +0800 Subject: [PATCH] Fix examples CI --- .github/workflows/rust.yml | 10 +++++----- examples/loco_example/src/bin/main.rs | 3 ++- examples/loco_example/tests/tasks/seed.rs | 7 ++++--- examples/loco_seaography/Cargo.toml | 2 +- examples/loco_seaography/src/bin/main.rs | 3 ++- examples/loco_seaography/src/models/users.rs | 2 +- examples/loco_seaography/src/tasks/seed.rs | 7 ++++--- examples/loco_starter/src/bin/main.rs | 3 ++- examples/loco_starter/src/models/users.rs | 2 +- examples/loco_starter/src/tasks/seed.rs | 7 ++++--- examples/react_admin/backend/Cargo.toml | 2 +- examples/react_admin/backend/src/bin/main.rs | 3 ++- examples/react_admin/backend/src/models/users.rs | 2 +- examples/react_admin/backend/src/tasks/seed.rs | 7 ++++--- examples/seaography_example/graphql/Cargo.toml | 5 +---- 15 files changed, 35 insertions(+), 30 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 38767f265..e7ecfdbe4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -238,16 +238,16 @@ jobs: examples/basic, examples/graphql_example, examples/jsonrpsee_example, - # examples/loco_example, - # examples/loco_starter, - # examples/loco_seaography, + examples/loco_example, + examples/loco_starter, + examples/loco_seaography, examples/poem_example, examples/proxy_gluesql_example, - # examples/react_admin, + examples/react_admin, examples/rocket_example, examples/rocket_okapi_example, examples/salvo_example, - # examples/seaography_example, + examples/seaography_example, examples/tonic_example, ] steps: diff --git a/examples/loco_example/src/bin/main.rs b/examples/loco_example/src/bin/main.rs index 99ad18522..07b1e7d72 100644 --- a/examples/loco_example/src/bin/main.rs +++ b/examples/loco_example/src/bin/main.rs @@ -4,5 +4,6 @@ use todolist::app::App; #[tokio::main] async fn main() -> eyre::Result<()> { - cli::main::().await + cli::main::().await?; + Ok(()) } diff --git a/examples/loco_example/tests/tasks/seed.rs b/examples/loco_example/tests/tasks/seed.rs index e9909ad4a..472353cbf 100644 --- a/examples/loco_example/tests/tasks/seed.rs +++ b/examples/loco_example/tests/tasks/seed.rs @@ -13,7 +13,6 @@ //! ```sh //! cargo run task seed_data refresh:true //! ``` -use std::collections::BTreeMap; use loco_rs::{db, prelude::*}; use migration::Migrator; @@ -29,8 +28,10 @@ impl Task for SeedData { detail: "Task for seeding data".to_string(), } } - async fn run(&self, app_context: &AppContext, vars: &BTreeMap) -> Result<()> { - let refresh = vars.get("refresh").is_some_and(|refresh| refresh == "true"); + async fn run(&self, app_context: &AppContext, vars: &task::Vars) -> Result<()> { + let refresh = vars + .cli_arg("refresh") + .is_ok_and(|refresh| refresh == "true"); if refresh { db::reset::(&app_context.db).await?; diff --git a/examples/loco_seaography/Cargo.toml b/examples/loco_seaography/Cargo.toml index 6fb8a6ba6..52fb9850f 100644 --- a/examples/loco_seaography/Cargo.toml +++ b/examples/loco_seaography/Cargo.toml @@ -26,7 +26,7 @@ include_dir = "0.7" uuid = { version = "1.6.0", features = ["v4"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json"] } -seaography = { version = "1.0.0", features = ["with-decimal", "with-chrono"] } +seaography = { version = "1.1.0-rc.1", features = ["with-decimal", "with-chrono"] } async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] } async-graphql-axum = { version = "7.0" } lazy_static = { version = "1.4" } diff --git a/examples/loco_seaography/src/bin/main.rs b/examples/loco_seaography/src/bin/main.rs index 1f83ec08a..226711dcf 100644 --- a/examples/loco_seaography/src/bin/main.rs +++ b/examples/loco_seaography/src/bin/main.rs @@ -4,5 +4,6 @@ use migration::Migrator; #[tokio::main] async fn main() -> eyre::Result<()> { - cli::main::().await + cli::main::().await?; + Ok(()) } diff --git a/examples/loco_seaography/src/models/users.rs b/examples/loco_seaography/src/models/users.rs index b9c2ec62b..7729755e9 100644 --- a/examples/loco_seaography/src/models/users.rs +++ b/examples/loco_seaography/src/models/users.rs @@ -192,7 +192,7 @@ impl super::_entities::users::Model { /// /// when could not convert user claims to jwt token pub fn generate_jwt(&self, secret: &str, expiration: &u64) -> ModelResult { - Ok(jwt::JWT::new(secret).generate_token(expiration, self.pid.to_string())?) + Ok(jwt::JWT::new(secret).generate_token(expiration, self.pid.to_string(), None)?) } } diff --git a/examples/loco_seaography/src/tasks/seed.rs b/examples/loco_seaography/src/tasks/seed.rs index 8405ddb99..1647beb84 100644 --- a/examples/loco_seaography/src/tasks/seed.rs +++ b/examples/loco_seaography/src/tasks/seed.rs @@ -13,7 +13,6 @@ //! ```sh //! cargo run task seed_data refresh:true //! ``` -use std::collections::BTreeMap; use loco_rs::{db, prelude::*}; use migration::Migrator; @@ -31,8 +30,10 @@ impl Task for SeedData { } } - async fn run(&self, app_context: &AppContext, vars: &BTreeMap) -> Result<()> { - let refresh = vars.get("refresh").is_some_and(|refresh| refresh == "true"); + async fn run(&self, app_context: &AppContext, vars: &task::Vars) -> Result<()> { + let refresh = vars + .cli_arg("refresh") + .is_ok_and(|refresh| refresh == "true"); if refresh { db::reset::(&app_context.db).await?; diff --git a/examples/loco_starter/src/bin/main.rs b/examples/loco_starter/src/bin/main.rs index 57fe67cd5..92b46682b 100644 --- a/examples/loco_starter/src/bin/main.rs +++ b/examples/loco_starter/src/bin/main.rs @@ -4,5 +4,6 @@ use migration::Migrator; #[tokio::main] async fn main() -> eyre::Result<()> { - cli::main::().await + cli::main::().await?; + Ok(()) } diff --git a/examples/loco_starter/src/models/users.rs b/examples/loco_starter/src/models/users.rs index b9c2ec62b..7729755e9 100644 --- a/examples/loco_starter/src/models/users.rs +++ b/examples/loco_starter/src/models/users.rs @@ -192,7 +192,7 @@ impl super::_entities::users::Model { /// /// when could not convert user claims to jwt token pub fn generate_jwt(&self, secret: &str, expiration: &u64) -> ModelResult { - Ok(jwt::JWT::new(secret).generate_token(expiration, self.pid.to_string())?) + Ok(jwt::JWT::new(secret).generate_token(expiration, self.pid.to_string(), None)?) } } diff --git a/examples/loco_starter/src/tasks/seed.rs b/examples/loco_starter/src/tasks/seed.rs index 8405ddb99..1647beb84 100644 --- a/examples/loco_starter/src/tasks/seed.rs +++ b/examples/loco_starter/src/tasks/seed.rs @@ -13,7 +13,6 @@ //! ```sh //! cargo run task seed_data refresh:true //! ``` -use std::collections::BTreeMap; use loco_rs::{db, prelude::*}; use migration::Migrator; @@ -31,8 +30,10 @@ impl Task for SeedData { } } - async fn run(&self, app_context: &AppContext, vars: &BTreeMap) -> Result<()> { - let refresh = vars.get("refresh").is_some_and(|refresh| refresh == "true"); + async fn run(&self, app_context: &AppContext, vars: &task::Vars) -> Result<()> { + let refresh = vars + .cli_arg("refresh") + .is_ok_and(|refresh| refresh == "true"); if refresh { db::reset::(&app_context.db).await?; diff --git a/examples/react_admin/backend/Cargo.toml b/examples/react_admin/backend/Cargo.toml index b0a5a7efe..6911467eb 100644 --- a/examples/react_admin/backend/Cargo.toml +++ b/examples/react_admin/backend/Cargo.toml @@ -26,7 +26,7 @@ include_dir = "0.7" uuid = { version = "1.6.0", features = ["v4"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json"] } -seaography = { version = "1.0.0", features = ["with-decimal", "with-chrono"] } +seaography = { version = "1.1.0-rc.1", features = ["with-decimal", "with-chrono"] } async-graphql = { version = "7.0", features = ["decimal", "chrono", "dataloader", "dynamic-schema"] } async-graphql-axum = { version = "7.0" } lazy_static = { version = "1.4" } diff --git a/examples/react_admin/backend/src/bin/main.rs b/examples/react_admin/backend/src/bin/main.rs index 1f83ec08a..226711dcf 100644 --- a/examples/react_admin/backend/src/bin/main.rs +++ b/examples/react_admin/backend/src/bin/main.rs @@ -4,5 +4,6 @@ use migration::Migrator; #[tokio::main] async fn main() -> eyre::Result<()> { - cli::main::().await + cli::main::().await?; + Ok(()) } diff --git a/examples/react_admin/backend/src/models/users.rs b/examples/react_admin/backend/src/models/users.rs index b9c2ec62b..7729755e9 100644 --- a/examples/react_admin/backend/src/models/users.rs +++ b/examples/react_admin/backend/src/models/users.rs @@ -192,7 +192,7 @@ impl super::_entities::users::Model { /// /// when could not convert user claims to jwt token pub fn generate_jwt(&self, secret: &str, expiration: &u64) -> ModelResult { - Ok(jwt::JWT::new(secret).generate_token(expiration, self.pid.to_string())?) + Ok(jwt::JWT::new(secret).generate_token(expiration, self.pid.to_string(), None)?) } } diff --git a/examples/react_admin/backend/src/tasks/seed.rs b/examples/react_admin/backend/src/tasks/seed.rs index 8405ddb99..1647beb84 100644 --- a/examples/react_admin/backend/src/tasks/seed.rs +++ b/examples/react_admin/backend/src/tasks/seed.rs @@ -13,7 +13,6 @@ //! ```sh //! cargo run task seed_data refresh:true //! ``` -use std::collections::BTreeMap; use loco_rs::{db, prelude::*}; use migration::Migrator; @@ -31,8 +30,10 @@ impl Task for SeedData { } } - async fn run(&self, app_context: &AppContext, vars: &BTreeMap) -> Result<()> { - let refresh = vars.get("refresh").is_some_and(|refresh| refresh == "true"); + async fn run(&self, app_context: &AppContext, vars: &task::Vars) -> Result<()> { + let refresh = vars + .cli_arg("refresh") + .is_ok_and(|refresh| refresh == "true"); if refresh { db::reset::(&app_context.db).await?; diff --git a/examples/seaography_example/graphql/Cargo.toml b/examples/seaography_example/graphql/Cargo.toml index d01779a27..d9b7acb80 100644 --- a/examples/seaography_example/graphql/Cargo.toml +++ b/examples/seaography_example/graphql/Cargo.toml @@ -15,10 +15,7 @@ tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] } tracing = { version = "0.1.37" } tracing-subscriber = { version = "0.3.17" } lazy_static = { version = "1.4.0" } - -[dependencies.seaography] -version = "1.0.0" # seaography version -features = ["with-decimal", "with-chrono"] +seaography = { version = "1.1.0-rc.1", features = ["with-decimal", "with-chrono"] } [dev-dependencies] serde_json = { version = "1.0.103" }