Skip to content

Commit 02966a6

Browse files
ops: ci improvements
* ops: add format and test workflow * test: add sanity test checks * chore: add workflow debug * chore: add more debug * chore: add checkout step * ops: add rust-cache for test action * chore: add rust-cache for test-build workflow * chore: change rust-cache config
1 parent 2d4aa2e commit 02966a6

12 files changed

Lines changed: 177 additions & 5 deletions

File tree

.github/workflows/format.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Format front- and backend
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- alpha
8+
- beta
9+
- next
10+
paths:
11+
- 'src/**'
12+
- 'src-tauri/**'
13+
- 'tests/**'
14+
- 'bun.lockb'
15+
- 'src-tauri/Cargo.lock'
16+
- '.github/workflows/format.yml'
17+
workflow_dispatch:
18+
19+
jobs:
20+
format:
21+
runs-on: 'ubuntu-24.04'
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Setup Bun
26+
uses: oven-sh/setup-bun@v2
27+
with:
28+
bun-version: latest
29+
30+
- name: install Rust stable
31+
uses: dtolnay/rust-toolchain@stable
32+
33+
- name: install bun dependencies
34+
run: bun i
35+
36+
- name: frontend checks
37+
run: bun format
38+
39+
- name: format backend
40+
working-directory: src-tauri
41+
run: rustfmt src/**/*.rs
42+
43+
44+
- name: Configure Git
45+
run: |
46+
git config --global user.name 'github-actions[bot]'
47+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
48+
49+
50+
- name: Commit and Push Changes
51+
run: |
52+
git add .
53+
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
54+
git commit -m "chore(workflow): formatted code $TIMESTAMP"
55+
git push
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test-build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ jobs:
4141
- name: install Rust stable
4242
uses: dtolnay/rust-toolchain@stable
4343

44+
- name: Rust Cache
45+
uses: Swatinem/rust-cache@v2
46+
with:
47+
workspaces: "src-tauri -> src-tauri/target"
48+
cache-directories: "src-tauri"
49+
4450
- name: install dependencies
4551
run: |
4652
sudo apt-get update

.github/workflows/test.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Test front- and backend
2+
3+
on:
4+
push:
5+
paths:
6+
- 'src/**'
7+
- 'src-tauri/**'
8+
- 'tests/**'
9+
- 'bun.lockb'
10+
- 'src-tauri/Cargo.lock'
11+
- '.github/workflows/test.yml'
12+
pull_request:
13+
workflow_dispatch:
14+
15+
jobs:
16+
test-frontend:
17+
permissions:
18+
contents: write
19+
runs-on: 'ubuntu-24.04'
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup Bun
24+
uses: oven-sh/setup-bun@v2
25+
with:
26+
bun-version: latest
27+
28+
- name: install bun dependencies
29+
run: |
30+
bun i
31+
32+
33+
- name: frontend checks
34+
run: bun check
35+
36+
- name: frontend tests
37+
run: bun test
38+
39+
test-backend:
40+
permissions:
41+
contents: write
42+
runs-on: 'ubuntu-24.04'
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Setup Bun
47+
uses: oven-sh/setup-bun@v2
48+
with:
49+
bun-version: latest
50+
51+
- name: install bun dependencies
52+
run: bun i
53+
54+
- name: install Rust stable
55+
uses: dtolnay/rust-toolchain@stable
56+
57+
- name: Rust Cache
58+
uses: Swatinem/rust-cache@v2
59+
with:
60+
workspaces: "src-tauri -> src-tauri/target"
61+
cache-directories: "src-tauri"
62+
63+
- name: install system dependencies
64+
run: |
65+
sudo apt-get update
66+
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
67+
68+
- name: bakend tests
69+
working-directory: src-tauri
70+
run: cargo test

Justfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
default:
2+
just --list
3+
4+
run:
5+
bun run tauri dev

bun.lockb

11.8 KB
Binary file not shown.

init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/usr/bin/env bash
22

33
git config core.hooksPath .git-hooks
4+
bun i

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"type": "module",
55
"license": "MIT",
66
"scripts": {
7+
"test": "vitest",
78
"dev": "vite dev",
89
"build": "vite build",
910
"preview": "vite preview",
@@ -35,7 +36,8 @@
3536
"tailwindcss": "^3.4.17",
3637
"tailwindcss-animate": "^1.0.7",
3738
"typescript": "^5.7.3",
38-
"vite": "^5.4.11"
39+
"vite": "^5.4.11",
40+
"vitest": "^3.0.2"
3941
},
4042
"dependencies": {
4143
"@tauri-apps/api": "^2.2.0",

src-tauri/src/commands.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#[tauri::command]
22
pub fn greet(name: String) -> String {
3-
format!("Hello, {}!", name)
4-
}
3+
format!("Hello, {}!", name)
4+
}

src-tauri/src/main.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,21 @@
22
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
33

44
fn main() {
5-
app_lib::run();
5+
app_lib::run();
6+
}
7+
8+
#[cfg(test)]
9+
mod tests {
10+
fn add(a: i32, b: i32) -> i32 {
11+
a + b
12+
}
13+
14+
#[test]
15+
fn sanity_test() {
16+
let a = 1;
17+
let b = 2;
18+
let sum = 1 + 2;
19+
20+
assert_eq!(add(a, b), sum);
21+
}
622
}

src/lib/utils.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { sanity_check } from './utils';
2+
import { expect, test } from 'vitest';
3+
4+
test('SanityTest', () => {
5+
let a = 1;
6+
let b = 2;
7+
8+
let sum = a + b;
9+
10+
expect(sanity_check(a, b)).toEqual(sum);
11+
});

0 commit comments

Comments
 (0)