Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: lint check and build check before merge #29

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and Check linting

on:
workflow_call:
inputs:
publish-artifact:
default: false
required: false
type: boolean
workflow_dispatch:
pull_request:
branches:
- main

jobs:
build_check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Install Nix packages
uses: DeterminateSystems/nix-installer-action@main
- name: Cache Nix packages
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Cache rust dependencies and build output
uses: actions/cache@v3
with:
path: |
~/.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'
nix-shell --run "rustup component add rustfmt"
nix-shell --run "rustup component add clippy"
- name: lint check
run: |
nix-shell --run "cargo fmt --check"
nix-shell --run "cargo clippy --no-deps --all-features --release -- -Dwarnings"
- 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
- run: touch .empty
- name: Archive production artifacts
uses: actions/upload-artifact@v3
if: ${{ inputs.publish-artifact }}
with:
name: build-musl
path: |
target/x86_64-unknown-linux-musl/release/hot-or-not-web-leptos-ssr
target/site
.empty
35 changes: 13 additions & 22 deletions .github/workflows/deploy-to-production-on-merge-to-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,24 @@ on:
- main

jobs:
build_check:
uses: ./.github/workflows/build-check.yml
with:
publish-artifact: true

deploy:
name: Deploy
needs: build_check
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Install Nix packages
uses: DeterminateSystems/nix-installer-action@main
- name: Cache Nix packages
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Cache rust dependencies and build output
uses: actions/cache@v3
- uses: actions/checkout@v3
- name: Download build
uses: actions/download-artifact@v3
with:
path: |
~/.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: build-musl
- run: chmod +x target/x86_64-unknown-linux-musl/release/hot-or-not-web-leptos-ssr
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy a docker container to Fly.io
run: nix-shell --run 'fly deploy'
run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ leptos-use = "0.9.0"
reqwest = { version = "0.11.23", default-features = false }
serde_bytes = "0.11.14"
hex = "0.4.3"
leptos_icons = "0.2.0"
leptos_icons = "0.2.1"
icondata = "0.3.0"

[build-dependencies]
Expand Down
2 changes: 2 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ pkgs.mkShell {
nodejs_21
nodePackages_latest.tailwindcss
rustup
# only used for clippy
openssl
];
}
7 changes: 6 additions & 1 deletion src/canister/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//! Auto generated bindings for canisters
include!(concat!(env!("OUT_DIR"), "/did/mod.rs"));
#[allow(clippy::all)]
mod generated {
include!(concat!(env!("OUT_DIR"), "/did/mod.rs"));
}

pub mod utils;
pub use generated::*;

pub const AGENT_URL: &str = "https://ic0.app";
12 changes: 6 additions & 6 deletions src/page/err.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use leptos::*;
use leptos_router::*;

#[derive(Params, PartialEq)]
#[derive(Clone, Params, PartialEq)]
struct ServerErrParams {
err: String,
}
Expand All @@ -10,12 +10,12 @@ struct ServerErrParams {
pub fn ServerErrorPage() -> impl IntoView {
let params = use_query::<ServerErrParams>();
let error = move || {
params.with(|p| {
p.as_ref()
.map(|p| p.err.clone())
.unwrap_or("Server Error".to_string())
})
params
.get()
.map(|p| p.err)
.unwrap_or_else(|_| "Server Error".to_string())
};

view! {
<div>
<h1>Server Error</h1>
Expand Down