Skip to content

Commit

Permalink
feat: Rewrite using askama and htmx (#179)
Browse files Browse the repository at this point in the history
Combine workspace into a single project and use a combination of askama,
htmx and hyperfine to render the webpage. Drop sycamore and the whole
web assembly bit. I believe this will simplify the project and make it
easier to maintain and add features.
  • Loading branch information
gbbirkisson committed Jun 4, 2024
1 parent f649d25 commit c8aa488
Show file tree
Hide file tree
Showing 100 changed files with 2,135 additions and 2,962 deletions.
4 changes: 0 additions & 4 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[advisories]
ignore = [
"RUSTSEC-2024-0003", # Resource exhaustion vulnerability in h2 may lead to Denial of Service
"RUSTSEC-2023-0074", # zerocopy: Some Ref methods are unsound with some type parameters
"RUSTSEC-2023-0071", # Marvin Attack: potential key recovery through timing sidechannels
"RUSTSEC-2023-0061", # libwebp: OOB write in BuildHuffmanTable
"RUSTSEC-2020-0071", # Potential segfault in the time crate
]
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Ignore everything
*

# Except these
!docker
!release
!release
9 changes: 0 additions & 9 deletions .env

This file was deleted.

21 changes: 19 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# direnv will read this file
#!/usr/bin/env bash

export RUST_LOG=warning,spis_server=info
export RUST_LOG=warning,spis=info

export NGINX_PORT=8080

export DATABASE_URL=sqlite:data/spis.db

export SPIS_MEDIA_DIR=${PWD}/data/media
export SPIS_DATA_DIR=${PWD}/data

export SPIS_PROCESSING_RUN_ON_START=true
export SPIS_PROCESSING_SCHEDULE="0 0 2 * * *"

export SPIS_API_MEDIA_PATH=/assets/media
export SPIS_API_THUMBNAIL_PATH=/assets/thumbnails
export SPIS_SERVER_SOCKET=/tmp/spis.sock

export SPIS_FEATURE_FAVORITE="true"
export SPIS_FEATURE_ARCHIVE="true"
31 changes: 24 additions & 7 deletions .github/actions/toolchain/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: rustup
description: "Install Rust toolchain"
name: toolchain
description: "Install toolchain"

inputs:
bin-cache:
Expand All @@ -11,7 +11,15 @@ inputs:
runs:
using: "composite"
steps:
- name: Setup caching
- name: Setup mise
uses: jdx/mise-action@v2
with:
# version: TODO:
install: true
cache: true
experimental: true

- name: Setup rust caching
uses: Swatinem/rust-cache@v2
with:
shared-key: toolchain
Expand All @@ -25,6 +33,7 @@ runs:
shell: bash

- name: "Install rust toolchain"
shell: bash
run: |
# Make sure bin-cache dir exists with something in it
mkdir -p ${{ inputs.bin-cache }}
Expand All @@ -33,10 +42,18 @@ runs:
cp ${{ inputs.bin-cache }}/* /home/runner/.cargo/bin
# Install everything needed
make setup-toolchain
mise run setup:toolchain
# Move bins to bin_cache
cat rust-toolchain.toml | grep '# bin' | sed 's/sqlx-cli/sqlx/g' | xargs -n 4 sh -c 'cp -f /home/runner/.cargo/bin/$2 ${{ inputs.bin-cache }}'
# Install dependencies
cargo install sqlx-cli@0.7.1 # TODO:
cargo install cargo-tarpaulin@0.27.3 # TODO:
rustc --version --verbose
# Cache these binaries
for f in sqlx cargo-tarpaulin; do
cp -f "/home/runner/.cargo/bin/$f" "${{ inputs.bin-cache }}"
done
- name: "Setup DB"
shell: bash
run: |
mise run setup:db
14 changes: 4 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ name: CI
on:
workflow_call:
pull_request:
paths:
- 'spis-gui/**'
- 'spis-model/**'
- 'spis-server/**'
- 'Cargo.lock'
- 'Cargo.toml'
- 'rust-toolchain.toml'
push:
branches: main
branches:
- main

jobs:
ci:
Expand All @@ -22,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [fmt, lint, audit, test]
target: ["lint:fmt", "lint:clippy", "test"]

steps:
- name: Checkout
Expand All @@ -35,7 +29,7 @@ jobs:
uses: ./.github/actions/toolchain

- name: Run ${{ matrix.target }}
run: make ${{ matrix.target }}
run: mise run ${{ matrix.target }}

- name: Upload test coverage
uses: codecov/codecov-action@v4
Expand Down
94 changes: 32 additions & 62 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,17 @@ jobs:
name: Run CI
uses: ./.github/workflows/ci.yml

build-gui:
name: Build GUI
build-bins:
name: Build binary ${{ matrix.target }}
runs-on: ubuntu-latest
needs: ci

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install rust toolchain
uses: ./.github/actions/toolchain

- name: Build gui
run: make release-gui

- name: Store GUI artifacts
uses: actions/upload-artifact@v4
with:
name: gui-artifacts
path: spis-gui/dist

build-server:
name: Build ${{ matrix.target }}
runs-on: ubuntu-latest
needs:
- build-gui

strategy:
fail-fast: true
matrix:
target:
- spis-server-x86_64-unknown-linux-gnu
- spis-server-armv7-unknown-linux-gnueabihf
- spis-server-aarch64-unknown-linux-gnu
- x86_64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- aarch64-unknown-linux-gnu

steps:
- name: Checkout
Expand All @@ -57,52 +34,44 @@ jobs:
- name: Install rust toolchain
uses: ./.github/actions/toolchain

- name: Get GUI artifacts
uses: actions/download-artifact@v4
- name: Docker pulls images.
uses: ScribeMD/docker-cache@0.3.7
with:
name: gui-artifacts
path: spis-gui/dist
key: docker-${{ runner.os }}

- name: Compile server
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
target: ${{ matrix.target }}
args: "--locked --release"
cross-version: v0.2.5

- name: Move to release dir
run: |
make release/${{ matrix.target }}
mkdir release
mv target/${{ matrix.target }}/release/spis release/spis-${{ matrix.target }}
- name: Store server artifact
- name: Store artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: release/${{ matrix.target }}
name: spis-${{ matrix.target }}
path: release/spis-${{ matrix.target }}

release-assets:
name: Create release assets
release-bins:
name: Release binaries
runs-on: ubuntu-latest
needs: build-server
needs: build-bins

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create release dir
run: |
mkdir release
- name: Get x86_64 server artifact
uses: actions/download-artifact@v4
with:
name: spis-server-x86_64-unknown-linux-gnu
path: release

- name: Get armv7 server artifact
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: spis-server-armv7-unknown-linux-gnueabihf
path: release

- name: Get aarch64 server artifact
uses: actions/download-artifact@v4
with:
name: spis-server-aarch64-unknown-linux-gnu
path: release
pattern: spis-*
merge-multiple: true

- name: Setup QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -120,17 +89,18 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set Docker Tag
run: echo "DOCKER_TAG=$(echo $VERSION | awk -F- '{print $2}')" >> $GITHUB_ENV

- name: Docker build and push
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Upload artifacts to release
uses: AButler/upload-release-assets@v3.0
Expand Down
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.vscode
dev/api
dist
release
data
target

cobertura.xml
release
Loading

0 comments on commit c8aa488

Please sign in to comment.