From d4377c52801e61b0dda6661628ed145e4c53d776 Mon Sep 17 00:00:00 2001 From: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> Date: Sun, 2 Jun 2024 19:28:02 +0200 Subject: [PATCH 1/2] Ci improvements (#498) * bump wasm-bindgen version to 0.2.92 * change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest * check some common non-default feature configurations * add experimental semver checks --- .github/workflows/build_and_test.yml | 26 +++++++++++++++++++++++--- Cargo.lock | 20 ++++++++++---------- semver_release_checks.yml | 18 ++++++++++++++++++ 3 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 semver_release_checks.yml diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 0f680cc..d0ddba5 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -46,6 +46,26 @@ jobs: cargo build --verbose --all-features cargo test --verbose --all-features fi + - name: Check common non-default feature configurations + run: | + echo "No features:" + cargo check --features="" --no-default-features + echo "Only client:" + cargo check --features="client" --no-default-features + echo "Only backend:" + cargo check --features="backend" --no-default-features + echo "Only voice:" + cargo check --features="voice" --no-default-features + echo "Only voice gateway:" + cargo check --features="voice_gateway" --no-default-features + echo "Backend + client:" + cargo check --features="backend, client" --no-default-features + echo "Backend + voice:" + cargo check --features="backend, voice" --no-default-features + echo "Backend + voice gateway:" + cargo check --features="backend, voice_gateway" --no-default-features + echo "Client + voice gateway:" + cargo check --features="client, voice_gateway" --no-default-features # wasm-safari: # runs-on: macos-latest # steps: @@ -75,7 +95,7 @@ jobs: # cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.88" --force # SAFARIDRIVER=$(which safaridriver) cargo test --target wasm32-unknown-unknown --no-default-features --features="client, rt" --no-fail-fast wasm-gecko: - runs-on: macos-latest + runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/checkout@v4 @@ -101,7 +121,7 @@ jobs: run: | rustup target add wasm32-unknown-unknown curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash - cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.88" --force + cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.92" --force GECKODRIVER=$(which geckodriver) cargo test --target wasm32-unknown-unknown --no-default-features --features="client, rt, voice_gateway" wasm-chrome: runs-on: macos-latest @@ -130,5 +150,5 @@ jobs: run: | rustup target add wasm32-unknown-unknown curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash - cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.88" --force + cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.92" --force CHROMEDRIVER=$(which chromedriver) cargo test --target wasm32-unknown-unknown --no-default-features --features="client, rt, voice_gateway" diff --git a/Cargo.lock b/Cargo.lock index 53283cc..0d0cb0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2727,9 +2727,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2737,9 +2737,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", @@ -2764,9 +2764,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2774,9 +2774,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", @@ -2787,9 +2787,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-bindgen-test" diff --git a/semver_release_checks.yml b/semver_release_checks.yml new file mode 100644 index 0000000..12dd718 --- /dev/null +++ b/semver_release_checks.yml @@ -0,0 +1,18 @@ +name: Semver release checks + +on: + pull_request: + branches: ["main"] + +env: + CARGO_TERM_COLOR: always + +jobs: + semver-checks: + + runs-on: ubuntu-latest + timeout-minutes: 60 + + steps: + - uses: actions/checkout@v4 + - uses: obi1kenobi/cargo-semver-checks-action@v2 From eb087938ed48f348de2ed299f07f464efd865719 Mon Sep 17 00:00:00 2001 From: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> Date: Mon, 3 Jun 2024 07:32:11 +0200 Subject: [PATCH 2/2] Fix some iso timestamps being strings, not DateTime (#499) * fix: some iso timestamps being strings * fix: register uses dates, not datetimes --- src/types/entities/channel.rs | 6 +++--- src/types/entities/guild.rs | 2 +- src/types/entities/guild_member.rs | 7 ++++--- src/types/entities/message.rs | 5 +++-- src/types/events/channel.rs | 2 +- src/types/schema/auth.rs | 4 +++- tests/auth.rs | 10 +++++++--- tests/common/mod.rs | 8 ++++++-- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/types/entities/channel.rs b/src/types/entities/channel.rs index fd0c077..262897c 100644 --- a/src/types/entities/channel.rs +++ b/src/types/entities/channel.rs @@ -160,10 +160,10 @@ pub struct PermissionOverwrite { pub struct ThreadMetadata { pub archived: bool, pub auto_archive_duration: i32, - pub archive_timestamp: String, + pub archive_timestamp: DateTime, pub locked: bool, pub invitable: Option, - pub create_timestamp: Option, + pub create_timestamp: Option>, } #[derive(Default, Debug, Deserialize, Serialize, Clone)] @@ -172,7 +172,7 @@ pub struct ThreadMetadata { pub struct ThreadMember { pub id: Option, pub user_id: Option, - pub join_timestamp: Option, + pub join_timestamp: Option>, pub flags: Option, pub member: Option>, } diff --git a/src/types/entities/guild.rs b/src/types/entities/guild.rs index 2b7ae44..8544b0b 100644 --- a/src/types/entities/guild.rs +++ b/src/types/entities/guild.rs @@ -67,7 +67,7 @@ pub struct Guild { #[cfg_attr(feature = "sqlx", sqlx(skip))] pub invites: Option>, #[cfg_attr(feature = "sqlx", sqlx(skip))] - pub joined_at: Option, + pub joined_at: Option>, pub large: Option, pub max_members: Option, pub max_presences: Option, diff --git a/src/types/entities/guild_member.rs b/src/types/entities/guild_member.rs index 5cd5ad1..66fad99 100644 --- a/src/types/entities/guild_member.rs +++ b/src/types/entities/guild_member.rs @@ -2,6 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use crate::types::Shared; @@ -17,12 +18,12 @@ pub struct GuildMember { pub nick: Option, pub avatar: Option, pub roles: Vec, - pub joined_at: String, - pub premium_since: Option, + pub joined_at: DateTime, + pub premium_since: Option>, pub deaf: bool, pub mute: bool, pub flags: Option, pub pending: Option, pub permissions: Option, - pub communication_disabled_until: Option, + pub communication_disabled_until: Option>, } diff --git a/src/types/entities/message.rs b/src/types/entities/message.rs index e03a078..4b57e06 100644 --- a/src/types/entities/message.rs +++ b/src/types/entities/message.rs @@ -2,6 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use crate::types::{ @@ -25,8 +26,8 @@ pub struct Message { #[cfg_attr(feature = "sqlx", sqlx(skip))] pub author: Option, pub content: Option, - pub timestamp: String, - pub edited_timestamp: Option, + pub timestamp: DateTime, + pub edited_timestamp: Option>, pub tts: Option, pub mention_everyone: bool, #[cfg_attr(feature = "sqlx", sqlx(skip))] diff --git a/src/types/events/channel.rs b/src/types/events/channel.rs index 911f249..dd16754 100644 --- a/src/types/events/channel.rs +++ b/src/types/events/channel.rs @@ -96,7 +96,7 @@ pub struct ChannelUnreadUpdate { pub struct ChannelUnreadUpdateObject { pub id: Snowflake, pub last_message_id: Snowflake, - pub last_pin_timestamp: Option, + pub last_pin_timestamp: Option>, } #[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField, WebSocketEvent)] diff --git a/src/types/schema/auth.rs b/src/types/schema/auth.rs index 2796805..83c88dc 100644 --- a/src/types/schema/auth.rs +++ b/src/types/schema/auth.rs @@ -2,6 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +use chrono::NaiveDate; use serde::{Deserialize, Serialize}; #[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq)] @@ -13,7 +14,8 @@ pub struct RegisterSchema { pub email: Option, pub fingerprint: Option, pub invite: Option, - pub date_of_birth: Option, + /// The user's date of birth, serialized as an ISO8601 date + pub date_of_birth: Option, pub gift_code_sku_id: Option, pub captcha_key: Option, pub promotional_email_opt_in: Option, diff --git a/tests/auth.rs b/tests/auth.rs index 35007f1..705328a 100644 --- a/tests/auth.rs +++ b/tests/auth.rs @@ -2,12 +2,16 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +use std::str::FromStr; + use chorus::types::{LoginSchema, RegisterSchema}; #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::*; #[cfg(target_arch = "wasm32")] wasm_bindgen_test_configure!(run_in_browser); +use chrono::NaiveDate; + mod common; #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] @@ -16,7 +20,7 @@ async fn test_registration() { let mut bundle = common::setup().await; let reg = RegisterSchema { username: "Hiiii".into(), - date_of_birth: Some("2000-01-01".to_string()), + date_of_birth: Some(NaiveDate::from_str("2000-01-01").unwrap()), consent: true, ..Default::default() }; @@ -32,7 +36,7 @@ async fn test_login() { username: "Hiiii".into(), email: Some("testuser1@integrationtesting.xyz".into()), password: Some("Correct-Horse-Battery-Staple1".into()), - date_of_birth: Some("2000-01-01".to_string()), + date_of_birth: Some(NaiveDate::from_str("2000-01-01").unwrap()), consent: true, ..Default::default() }; @@ -54,7 +58,7 @@ async fn test_wrong_login() { username: "Hiiii".into(), email: Some("testuser2@integrationtesting.xyz".into()), password: Some("Correct-Horse-Battery-Staple1".into()), - date_of_birth: Some("2000-01-01".to_string()), + date_of_birth: Some(NaiveDate::from_str("2000-01-01").unwrap()), consent: true, ..Default::default() }; diff --git a/tests/common/mod.rs b/tests/common/mod.rs index a98667c..315db38 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -2,6 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +use std::str::FromStr; + use chorus::gateway::Gateway; use chorus::types::IntoShared; use chorus::{ @@ -13,6 +15,8 @@ use chorus::{ UrlBundle, }; +use chrono::NaiveDate; + #[allow(dead_code)] #[derive(Debug)] pub(crate) struct TestBundle { @@ -30,7 +34,7 @@ impl TestBundle { let register_schema = RegisterSchema { username: username.to_string(), consent: true, - date_of_birth: Some("2000-01-01".to_string()), + date_of_birth: Some(NaiveDate::from_str("2000-01-01").unwrap()), ..Default::default() }; self.instance @@ -60,7 +64,7 @@ pub(crate) async fn setup() -> TestBundle { let reg = RegisterSchema { username: "integrationtestuser".into(), consent: true, - date_of_birth: Some("2000-01-01".to_string()), + date_of_birth: Some(NaiveDate::from_str("2000-01-01").unwrap()), ..Default::default() }; let guild_create_schema = GuildCreateSchema {