Skip to content
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
57 changes: 57 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Format front- and backend

on:
push:
branches:
- main
- alpha
- beta
- next
paths:
- 'src/**'
- 'src-tauri/**'
- 'tests/**'
- 'bun.lockb'
- 'src-tauri/Cargo.lock'
- '.github/workflows/format.yml'
workflow_dispatch:

jobs:
format:
runs-on: 'ubuntu-24.04'
steps:
- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable

- name: install bun dependencies
run: bun i

- name: frontend checks
run: bun format

- name: format backend
working-directory: src-tauri
run: rustfmt src/**/*.rs


- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'


- name: Commit and Push Changes
run: |
git add .
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
git commit -m "chore(workflow): formatted code $TIMESTAMP"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ jobs:
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable

- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "src-tauri -> src-tauri/target"
cache-directories: "src-tauri"

- name: install dependencies
run: |
sudo apt-get update
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Test front- and backend

on:
push:
paths:
- 'src/**'
- 'src-tauri/**'
- 'tests/**'
- 'bun.lockb'
- 'src-tauri/Cargo.lock'
- '.github/workflows/test.yml'
pull_request:
workflow_dispatch:

jobs:
test-frontend:
permissions:
contents: write
runs-on: 'ubuntu-24.04'
steps:
- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: install bun dependencies
run: |
bun i


- name: frontend checks
run: bun check

- name: frontend tests
run: bun test

test-backend:
permissions:
contents: write
runs-on: 'ubuntu-24.04'
steps:
- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: install bun dependencies
run: bun i

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable

- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "src-tauri -> src-tauri/target"
cache-directories: "src-tauri"

- name: install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf

- name: bakend tests
working-directory: src-tauri
run: cargo test
5 changes: 5 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
default:
just --list

run:
bun run tauri dev
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions init.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash

git config core.hooksPath .git-hooks
bun i
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"type": "module",
"license": "MIT",
"scripts": {
"test": "vitest",
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
Expand Down Expand Up @@ -35,7 +36,8 @@
"tailwindcss": "^3.4.17",
"tailwindcss-animate": "^1.0.7",
"typescript": "^5.7.3",
"vite": "^5.4.11"
"vite": "^5.4.11",
"vitest": "^3.0.2"
},
"dependencies": {
"@tauri-apps/api": "^2.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[tauri::command]
pub fn greet(name: String) -> String {
format!("Hello, {}!", name)
}
format!("Hello, {}!", name)
}
18 changes: 17 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,21 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

fn main() {
app_lib::run();
app_lib::run();
}

#[cfg(test)]
mod tests {
fn add(a: i32, b: i32) -> i32 {
a + b
}

#[test]
fn sanity_test() {
let a = 1;
let b = 2;
let sum = 1 + 2;

assert_eq!(add(a, b), sum);
}
}
11 changes: 11 additions & 0 deletions src/lib/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { sanity_check } from './utils';
import { expect, test } from 'vitest';

test('SanityTest', () => {
let a = 1;
let b = 2;

let sum = a + b;

expect(sanity_check(a, b)).toEqual(sum);
});
4 changes: 4 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

export function sanity_check(a: number, b: number): number {
return a + b;
}
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { defineConfig } from 'vitest/config';
import path from 'path';

const host = process.env.TAURI_DEV_HOST;
Expand Down