From 13ab0a1d821ac9e6761f0e3e782856d4b5d419b7 Mon Sep 17 00:00:00 2001 From: rupansh-gob <155418402+rupansh-gob@users.noreply.github.com> Date: Thu, 11 Jan 2024 10:03:48 +0530 Subject: [PATCH] fix(CI/CD): fix CI builds (#24) Co-authored-by: rupansh --- .dockerignore | 18 ++++++ ...deploy-to-production-on-merge-to-main.yaml | 8 +++ Cargo.lock | 60 +++++++++---------- Cargo.toml | 4 +- default.nix | 2 +- src/app.rs | 2 +- src/main.rs | 10 ++-- 7 files changed, 65 insertions(+), 39 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..9145c218 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,18 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +!/target/x86_64-unknown-linux-musl +!/target/site + +# These are backup files generated by rustfmt +**/**/*.rs.bk + +# node e2e test tools and outputs +**/node_modules +**/test-results +**/end2end/playwright-report +**/playwright/.cache + +# flyctl launch added from node_modules/.pnpm/tailwindcss@3.4.0/node_modules/tailwindcss/stubs/.gitignore +!node_modules/.pnpm/tailwindcss@3.4.0/node_modules/tailwindcss/stubs/**/* +fly.toml diff --git a/.github/workflows/deploy-to-production-on-merge-to-main.yaml b/.github/workflows/deploy-to-production-on-merge-to-main.yaml index cfef41dd..26385727 100644 --- a/.github/workflows/deploy-to-production-on-merge-to-main.yaml +++ b/.github/workflows/deploy-to-production-on-merge-to-main.yaml @@ -1,5 +1,6 @@ name: Deploy to Fly on push to main on: + workflow_dispatch: push: branches: - main @@ -22,8 +23,15 @@ jobs: ~/.cargo/ target/ key: cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Rust Setup + run: | + nix-shell --run "rustup default nightly" + nix-shell --run "rustup target add x86_64-unknown-linux-musl" + nix-shell --run 'rustup target add wasm32-unknown-unknown' - name: Build the Leptos project to `musl` output run: nix-shell --run 'cargo leptos build --release' + env: + LEPTOS_BIN_TARGET_TRIPLE: x86_64-unknown-linux-musl - name: Deploy a docker container to Fly.io run: nix-shell --run 'fly deploy' env: diff --git a/Cargo.lock b/Cargo.lock index 9eb8edea..49bbd320 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1215,6 +1215,36 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "hot-or-not-web-leptos-ssr" +version = "0.1.0" +dependencies = [ + "axum", + "candid", + "candid_parser", + "cfg-if", + "console_error_panic_hook", + "console_log", + "convert_case", + "http", + "ic-agent", + "leptos", + "leptos_axum", + "leptos_meta", + "leptos_router", + "log", + "serde", + "serde-wasm-bindgen 0.6.3", + "serde_json", + "simple_logger", + "thiserror", + "tokio", + "tower", + "tower-http", + "tracing", + "wasm-bindgen", +] + [[package]] name = "html-escape" version = "0.2.13" @@ -1579,36 +1609,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "leptos-ssr" -version = "0.1.0" -dependencies = [ - "axum", - "candid", - "candid_parser", - "cfg-if", - "console_error_panic_hook", - "console_log", - "convert_case", - "http", - "ic-agent", - "leptos", - "leptos_axum", - "leptos_meta", - "leptos_router", - "log", - "serde", - "serde-wasm-bindgen 0.6.3", - "serde_json", - "simple_logger", - "thiserror", - "tokio", - "tower", - "tower-http", - "tracing", - "wasm-bindgen", -] - [[package]] name = "leptos_axum" version = "0.5.4" diff --git a/Cargo.toml b/Cargo.toml index 379b5983..08913ebd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "leptos-ssr" +name = "hot-or-not-web-leptos-ssr" version = "0.1.0" edition = "2021" @@ -59,7 +59,7 @@ panic = "abort" [package.metadata.leptos] # The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name -output-name = "leptos-ssr" +output-name = "hot-or-not-leptos-ssr" # The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup. site-root = "target/site" diff --git a/default.nix b/default.nix index 2a27ee99..15167111 100644 --- a/default.nix +++ b/default.nix @@ -12,7 +12,7 @@ pkgs.mkShell { flyctl leptosfmt nodejs_21 - nodePackages_latest.postcss-cli + nodePackages_latest.tailwindcss rustup ]; } diff --git a/src/app.rs b/src/app.rs index 9c6f9b29..3a6d084d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -14,7 +14,7 @@ pub fn App() -> impl IntoView { provide_context(Canisters::default()); view! { - + // sets the document title diff --git a/src/main.rs b/src/main.rs index a6ab3151..eddfaea7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ mod handlers { }; use leptos::provide_context; use leptos_axum::handle_server_fns_with_context; - use leptos_ssr::{app::App, state::server::AppState}; + use hot_or_not_web_leptos_ssr::{app::App, state::server::AppState}; pub async fn server_fn_handler( State(app_state): State<AppState>, @@ -55,10 +55,10 @@ async fn main() { use handlers::*; use leptos::*; use leptos_axum::{generate_route_list, LeptosRoutes}; - use leptos_ssr::app::*; - use leptos_ssr::fileserv::file_and_error_handler; - use leptos_ssr::state::canisters::Canisters; - use leptos_ssr::state::server::AppState; + use hot_or_not_web_leptos_ssr::app::*; + use hot_or_not_web_leptos_ssr::fileserv::file_and_error_handler; + use hot_or_not_web_leptos_ssr::state::canisters::Canisters; + use hot_or_not_web_leptos_ssr::state::server::AppState; simple_logger::init_with_level(log::Level::Debug).expect("couldn't initialize logging");