feature/actions #6
@@ -2,6 +2,11 @@
|
||||
"name": "Finwise — Tauri Devcontainer",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile"
|
||||
},"features": {
|
||||
// Add Docker-in-Docker to allow act to run containers
|
||||
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
|
||||
// Add act
|
||||
"ghcr.io/devcontainers-extra/features/act:1": {}
|
||||
},
|
||||
"customizations": {
|
||||
"settings": {
|
||||
|
||||
27
.devcontainer/novnc/vnc-wrapper.html
Normal file
27
.devcontainer/novnc/vnc-wrapper.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>noVNC (local-scaling wrapper)</title>
|
||||
<script>
|
||||
// Try several possible setting keys used by different noVNC versions
|
||||
try {
|
||||
localStorage.setItem('resize', 'scale');
|
||||
localStorage.setItem('scaleViewport', 'true');
|
||||
localStorage.setItem('scalingMode', 'local');
|
||||
localStorage.setItem('preferLocalScaling', 'true');
|
||||
localStorage.setItem('viewOnly', localStorage.getItem('viewOnly') || 'false');
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
// Load the original noVNC UI (we will rename the original to vnc.orig.html)
|
||||
var orig = 'vnc.orig.html' + window.location.search + window.location.hash;
|
||||
// Use replace so back button doesn't loop
|
||||
window.location.replace(orig);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p>Applying local-scaling defaults and loading noVNC...</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -22,7 +22,15 @@ if [ "${USE_EXISTING_DISPLAY:-}" = "true" ] || { [ -n "${DISPLAY:-}" ] && [ -d "
|
||||
else
|
||||
echo "Prefer Xvfb — starting Xvfb :1"
|
||||
if command -v Xvfb >/dev/null 2>&1; then
|
||||
Xvfb :1 -screen 0 1280x720x24 >/tmp/xvfb.log 2>&1 &
|
||||
# Define virtual screen size once; will try to confirm at runtime
|
||||
# using xdpyinfo and fall back to these values if xdpyinfo isn't available.
|
||||
SCREEN_W=1280
|
||||
SCREEN_H=800
|
||||
# Use a slightly taller virtual screen so desktop panels/toolbars
|
||||
# don't cause the noVNC client to show an unexpected area below
|
||||
# the visible display; use variables so we can clip x11vnc to
|
||||
# exactly the same region and avoid framebuffer artifacts.
|
||||
Xvfb :1 -screen 0 "${SCREEN_W}x${SCREEN_H}x24" >/tmp/xvfb.log 2>&1 &
|
||||
export DISPLAY=:1
|
||||
else
|
||||
echo "Warning: Xvfb not available; expecting an X server on DISPLAY"
|
||||
@@ -44,9 +52,24 @@ fi
|
||||
sleep 1
|
||||
|
||||
echo "Starting x11vnc on ${DISPLAY:-:1}"
|
||||
if [ "${USE_EXISTING_DISPLAY:-}" != "true" ]; then
|
||||
# enable client-side caching for viewers that support it
|
||||
x11vnc -display "${DISPLAY:-:1}" -rfbauth "$VNC_DIR/passwd" -forever -shared -rfbport 5900 -ncache 10 -ncache_cr -bg || true
|
||||
if [ "${USE_EXISTING_DISPLAY:-}" != "true" ]; then
|
||||
# Query the actual display size (xdpyinfo) to compute a precise clip region
|
||||
# and avoid sending framebuffer rows outside the visible desktop. Disable
|
||||
# client-side caching which can sometimes produce visual artifacts.
|
||||
GEOM=""
|
||||
if command -v xdpyinfo >/dev/null 2>&1; then
|
||||
GEOM=$(xdpyinfo -display "${DISPLAY:-:1}" 2>/dev/null | awk '/dimensions:/ {print $2}') || true
|
||||
fi
|
||||
if [ -n "$GEOM" ]; then
|
||||
# GEOM looks like WxH (e.g. 1280x800)
|
||||
W=${GEOM%x*}
|
||||
H=${GEOM#*x}
|
||||
else
|
||||
W=${SCREEN_W}
|
||||
H=${SCREEN_H}
|
||||
fi
|
||||
echo "Starting x11vnc with clip ${W}x${H}+0+0 (display ${DISPLAY:-:1})"
|
||||
x11vnc -display "${DISPLAY:-:1}" -rfbauth "$VNC_DIR/passwd" -forever -shared -rfbport 5900 -clip ${W}x${H}+0+0 -bg || true
|
||||
else
|
||||
echo "USE_EXISTING_DISPLAY=true — skipping x11vnc (display forwarded to host)"
|
||||
fi
|
||||
@@ -69,6 +92,17 @@ fi
|
||||
# Start the noVNC proxy only when we are running an internal VNC server on port 5900
|
||||
if [ -n "$NOVNC_DIR" ] && [ "${USE_EXISTING_DISPLAY:-}" != "true" ]; then
|
||||
echo "Found noVNC at $NOVNC_DIR"
|
||||
# If a wrapper exists in the devcontainer, install it into the noVNC web
|
||||
# root so we can set localStorage defaults (e.g. prefer local scaling)
|
||||
WRAPPER="${SCRIPT_DIR:-$(pwd)}/novnc/vnc-wrapper.html"
|
||||
if [ -f "$WRAPPER" ]; then
|
||||
# Backup original vnc.html once and replace with wrapper
|
||||
if [ -f "$NOVNC_DIR/vnc.html" ] && [ ! -f "$NOVNC_DIR/vnc.orig.html" ]; then
|
||||
echo "Backing up original noVNC vnc.html to vnc.orig.html and installing wrapper"
|
||||
cp "$NOVNC_DIR/vnc.html" "$NOVNC_DIR/vnc.orig.html" || true
|
||||
cp "$WRAPPER" "$NOVNC_DIR/vnc.html" || true
|
||||
fi
|
||||
fi
|
||||
echo "Waiting for VNC server on localhost:5900..."
|
||||
ATTEMPTS=0
|
||||
until ss -ltnp | grep -q ':5900' || [ $ATTEMPTS -ge 10 ]; do
|
||||
|
||||
37
.github/Dockerfile
vendored
Normal file
37
.github/Dockerfile
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# This Dockerfile sets up the environment for ci.
|
||||
# requires at least bookworm for the required versions of webkit2gtk and gtk3
|
||||
FROM node:24-bookworm-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
git \
|
||||
ca-certificates \
|
||||
pkg-config \
|
||||
libgtk-3-dev \
|
||||
libgdk-pixbuf2.0-dev \
|
||||
libwebkit2gtk-4.1-dev \
|
||||
build-essential \
|
||||
curl \
|
||||
wget \
|
||||
file \
|
||||
libxdo-dev \
|
||||
libssl-dev \
|
||||
libayatana-appindicator3-dev \
|
||||
librsvg2-dev \
|
||||
libgdk-pixbuf2.0-dev \
|
||||
xfce4 \
|
||||
xfce4-goodies \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install rustup and the stable toolchain
|
||||
ENV RUSTUP_HOME=/root/.rustup \
|
||||
CARGO_HOME=/root/.cargo \
|
||||
PATH=/root/.cargo/bin:/usr/local/cargo/bin:$PATH
|
||||
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup-init.sh \
|
||||
&& chmod +x /tmp/rustup-init.sh \
|
||||
&& /tmp/rustup-init.sh -y \
|
||||
&& rm /tmp/rustup-init.sh
|
||||
|
||||
# Enable Corepack (for pnpm) and install latest pnpm shim
|
||||
RUN corepack enable \
|
||||
&& corepack prepare pnpm@latest --activate
|
||||
66
.github/actions/setup-rust/action.yml
vendored
Normal file
66
.github/actions/setup-rust/action.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
name: 'Setup Rust environment'
|
||||
description: 'Composite action to checkout the repo, restore cargo caches and set up the Rust toolchain. Use this from job steps to keep setup DRY across jobs.'
|
||||
inputs:
|
||||
toolchain:
|
||||
description: 'Rust toolchain to install'
|
||||
required: false
|
||||
default: 'stable'
|
||||
override:
|
||||
description: 'Whether to override the default toolchain'
|
||||
required: false
|
||||
default: 'true'
|
||||
components:
|
||||
description: 'Comma-separated list of additional rust components to install'
|
||||
required: false
|
||||
default: 'clippy, rustfmt'
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cargo/index
|
||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Sanitize components input
|
||||
shell: bash
|
||||
run: echo "SANITIZED_COMPONENTS=${{ inputs.components }}" | sed -E 's/, ?| /-/g' >> $GITHUB_ENV
|
||||
|
||||
- name: Cache Rust toolchain
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.rustup
|
||||
# Key includes the OS and the toolchain version (e.g., 'stable')
|
||||
key: ${{ runner.os }}-rustup-${{ hashFiles('rust-toolchain.toml') }}-v1-${{ inputs.toolchain }}-${{ env.SANITIZED_COMPONENTS }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-rustup-
|
||||
|
||||
- name: Cache cargo build (target)
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: target
|
||||
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Set up rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: ${{ inputs.toolchain }}
|
||||
override: ${{ inputs.override }}
|
||||
components: ${{ inputs.components }}
|
||||
61
.github/workflows/lint.yml
vendored
Normal file
61
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
lint-crates:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: gitea.gwmc.dev/finwise/finwise-ci:latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Rust, checkout and restore caches
|
||||
uses: ./.github/actions/setup-rust
|
||||
with:
|
||||
components: clippy, rustfmt
|
||||
|
||||
- name: Run clippy
|
||||
run: cargo clippy --all-features
|
||||
|
||||
- name: Check code formatting
|
||||
run: |
|
||||
cd src-tauri
|
||||
cargo fmt -- --check
|
||||
|
||||
lint-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
cache: 'pnpm'
|
||||
cache-dependency-path: pnpm-lock.yaml
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pnpm install
|
||||
|
||||
- name: Run frontend linter
|
||||
run: |
|
||||
pnpm lint
|
||||
|
||||
17
justfile
17
justfile
@@ -1,6 +1,9 @@
|
||||
default:
|
||||
@just --list
|
||||
|
||||
act:
|
||||
act --pull=false
|
||||
|
||||
init:
|
||||
cargo install sea-orm-cli@^2.0.0-rc
|
||||
|
||||
@@ -33,3 +36,17 @@ dev DISPLAY='1':
|
||||
# Note: this assumes that the VNC server is running and accessible at DISPLAY=:1
|
||||
# Check the start-vnc output for the correct DISPLAY value if you have multiple VNC sessions running
|
||||
DISPLAY=:{{DISPLAY}} pnpm tauri dev
|
||||
|
||||
# docker images for ci
|
||||
DOCKER_IMAGE_NAME := 'gitea.gwmc.dev/finwise/finwise-ci:latest'
|
||||
|
||||
build-ci-image:
|
||||
docker build -t {{DOCKER_IMAGE_NAME}} -f .github/Dockerfile .
|
||||
|
||||
push-ci-image:
|
||||
docker push {{DOCKER_IMAGE_NAME}}
|
||||
|
||||
update-ci-image: build-ci-image push-ci-image
|
||||
|
||||
pull-ci-image:
|
||||
docker pull {{DOCKER_IMAGE_NAME}}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview",
|
||||
"tauri": "tauri"
|
||||
"tauri": "tauri",
|
||||
"lint": "echo 'No linting configured for frontend yet'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2",
|
||||
|
||||
@@ -1,28 +1,18 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
db::service::DbService,
|
||||
services::{
|
||||
ServiceFactory
|
||||
},
|
||||
};
|
||||
use crate::{db::service::DbService, services::ServiceFactory};
|
||||
pub struct AppState {
|
||||
db: DbService,
|
||||
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
/// Create a new AppState with all services initialized
|
||||
pub async fn new(db: DbService) -> Self {
|
||||
let (
|
||||
) = ServiceFactory::create_services(db.get_connection().clone());
|
||||
Self {
|
||||
db,
|
||||
}
|
||||
let () = ServiceFactory::create_services(db.get_connection().clone());
|
||||
Self { db }
|
||||
}
|
||||
/// Get the database service
|
||||
pub fn db(&self) -> &DbService {
|
||||
&self.db
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,16 @@ export default defineConfig(async () => ({
|
||||
: undefined,
|
||||
watch: {
|
||||
// 3. tell Vite to ignore watching `src-tauri`
|
||||
ignored: ["**/src-tauri/**"],
|
||||
ignored: [
|
||||
"**/src-tauri/**",
|
||||
"**/target/**",
|
||||
"**/.pnpm-store/**",
|
||||
"**/.vscode/**",
|
||||
"**/.devcontainer/**",
|
||||
"**/crates/**",
|
||||
"**/doc/**",
|
||||
"**/*.md",
|
||||
],
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user