From 9a25b92e5766af0b054fd93dd0dd7f69ee26a478 Mon Sep 17 00:00:00 2001 From: Zack Fu Zi Xiang Date: Mon, 29 Apr 2024 21:25:32 +0800 Subject: [PATCH] fix: ci and use static file for template --- .github/workflows/integration_test.yml | 28 ++++++++++++-------------- deploy.env | 12 +++++------ dev.env | 1 - src/application.rs | 1 - src/config/config.rs | 2 -- src/mailer.rs | 13 +++--------- 6 files changed, 21 insertions(+), 36 deletions(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 10ae5746..e553b5db 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -62,21 +62,19 @@ jobs: - name: Run Docker-Compose run: | docker compose -f docker-compose-ci.yml up -d - sleep 5 - docker ps -a - docker compose logs appflowy_cloud + docker compose logs appflowy_cloud -f & -# - name: Run tests -# run: | -# RUST_LOG="info" DISABLE_CI_TEST_LOG="true" cargo test --workspace + - name: Run tests + run: | + RUST_LOG="info" DISABLE_CI_TEST_LOG="true" cargo test --workspace -# - name: Install Node.js -# uses: actions/setup-node@v2 -# with: -# node-version: '14' + - name: Install Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' -# - name: Run WASM tests -# working-directory: ./libs/wasm-test -# run: | -# cargo install wasm-pack -# wasm-pack test --headless --firefox + - name: Run WASM tests + working-directory: ./libs/wasm-test + run: | + cargo install wasm-pack + wasm-pack test --headless --firefox diff --git a/deploy.env b/deploy.env index 9dac3133..c9472af5 100644 --- a/deploy.env +++ b/deploy.env @@ -79,6 +79,11 @@ APPFLOWY_S3_SECRET_KEY=minioadmin APPFLOWY_S3_BUCKET=appflowy #APPFLOWY_S3_REGION=us-east-1 +# AppFlowy Cloud Mailer +APPFLOWY_MAILER_SMTP_HOST=smtp.gmail.com +APPFLOWY_MAILER_SMTP_USERNAME=email_sender@some_company.com +APPFLOWY_MAILER_SMTP_PASSWORD=email_sender_password + # Log level for the appflowy-cloud service RUST_LOG=info @@ -106,10 +111,3 @@ OPENAI_API_KEY= APPFLOWY_HISTORY_URL=http://history:50051 APPFLOWY_HISTORY_REDIS_URL=redis://redis:6379 APPFLOWY_HISTORY_DATABASE_URL=postgres://postgres:password@postgres:5432/postgres - - -# AppFlowy Cloud Mailer -APPFLOWY_MAILER_SMTP_HOST=smtp.gmail.com -APPFLOWY_MAILER_SMTP_USERNAME=email_sender@some_company.com -APPFLOWY_MAILER_SMTP_PASSWORD=email_sender_password -APPFLOWY_MAILER_WORKSPACE_INVITE_TEMPLATE_URL=https://raw.githubusercontent.com/AppFlowy-IO/Appflowy-Cloud/main/assets/mailer_templates/build_production/workspace_invitation.html diff --git a/dev.env b/dev.env index d34c533d..601ec702 100644 --- a/dev.env +++ b/dev.env @@ -79,7 +79,6 @@ APPFLOWY_S3_BUCKET=appflowy APPFLOWY_MAILER_SMTP_HOST=smtp.gmail.com APPFLOWY_MAILER_SMTP_USERNAME=notify@appflowy.io APPFLOWY_MAILER_SMTP_PASSWORD=email_sender_password -APPFLOWY_MAILER_WORKSPACE_INVITE_TEMPLATE_URL=https://raw.githubusercontent.com/AppFlowy-IO/Appflowy-Cloud/main/assets/mailer_templates/build_production/workspace_invitation.html RUST_LOG=info diff --git a/src/application.rs b/src/application.rs index c883d009..25bf7055 100644 --- a/src/application.rs +++ b/src/application.rs @@ -244,7 +244,6 @@ pub async fn init_state(config: &Config, rt_cmd_tx: RTCommandSender) -> Result, - pub workspace_invite_template_url: String, } #[derive(serde::Deserialize, Clone, Debug)] @@ -175,7 +174,6 @@ pub fn get_configuration() -> Result { smtp_host: get_env_var("APPFLOWY_MAILER_SMTP_HOST", "smtp.gmail.com"), smtp_username: get_env_var("APPFLOWY_MAILER_SMTP_USERNAME", "sender@example.com"), smtp_password: get_env_var("APPFLOWY_MAILER_SMTP_PASSWORD", "password").into(), - workspace_invite_template_url: get_env_var("APPFLOWY_MAILER_WORKSPACE_INVITE_TEMPLATE_URL", "https://raw.githubusercontent.com/AppFlowy-IO/Appflowy-Cloud/main/assets/mailer_templates/build_production/workspace_invitation.html"), }, }; Ok(config) diff --git a/src/mailer.rs b/src/mailer.rs index 47613f07..88bf974e 100644 --- a/src/mailer.rs +++ b/src/mailer.rs @@ -21,26 +21,19 @@ impl Mailer { smtp_username: String, smtp_password: String, smtp_host: &str, - workspace_invite_template_url: &str, ) -> Result { let creds = Credentials::new(smtp_username, smtp_password); let smtp_transport = AsyncSmtpTransport::::relay(smtp_host)? .credentials(creds) .build(); - let http_client = reqwest::Client::new(); - let workspace_invite_template = http_client - .get(workspace_invite_template_url) - .send() - .await? - .error_for_status()? - .text() - .await?; + let workspace_invite_template = + include_str!("../assets/mailer_templates/build_production/workspace_invitation.html"); HANDLEBARS .write() .unwrap() - .register_template_string("workspace_invite", &workspace_invite_template) + .register_template_string("workspace_invite", workspace_invite_template) .unwrap(); Ok(Self { smtp_transport })