Skip to content

Commit 3ccdf77

Browse files
committed
ci: stabilize tests and add Make targets
1 parent 501d88d commit 3ccdf77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+8479
-86
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,44 @@ jobs:
1717
node-version: '22.15.1'
1818
cache: 'pnpm'
1919

20-
- run: pnpm install
20+
- run: pnpm install --frozen-lockfile
21+
22+
- name: Configure git
23+
run: |
24+
git config --global init.defaultBranch main
25+
git config --global user.email "test@example.com"
26+
git config --global user.name "Test User"
27+
2128
- run: pnpm typecheck
2229
- run: pnpm lint
30+
- run: pnpm --filter @snowtree/ui test
31+
- run: pnpm --filter @snowtree/desktop test:ci
2332

2433
- name: Setup display
2534
run: |
2635
sudo apt-get update -qq
2736
sudo apt-get install -y xvfb
2837
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
2938
30-
- run: pnpm run build
3139
- run: pnpm run electron:rebuild
3240
- run: pnpm exec playwright install --with-deps chromium
3341

34-
- name: Configure git
42+
- name: Start UI dev server
3543
run: |
36-
git config --global init.defaultBranch main
37-
git config --global user.email "test@example.com"
38-
git config --global user.name "Test User"
44+
pnpm --filter @snowtree/ui dev -- --port 4521 --strictPort &
45+
pnpm exec wait-on http://localhost:4521 -t 60000
46+
47+
- name: UI E2E (Browser)
48+
run: pnpm --filter @snowtree/ui test:e2e
49+
env:
50+
CI: true
3951

40-
- run: DISPLAY=:99 pnpm --filter @snowtree/desktop test:ci
52+
- name: UI E2E (Electron)
53+
run: DISPLAY=:99 pnpm --filter @snowtree/ui test:e2e:electron
4154
env:
4255
CI: true
4356
ELECTRON_DISABLE_SANDBOX: 1
44-
timeout-minutes: 5
57+
timeout-minutes: 10
4558

4659
build:
4760
runs-on: ${{ matrix.os }}

.github/workflows/ui-tests.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: UI Tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [dev]
7+
paths:
8+
- 'packages/ui/**'
9+
- '.github/workflows/ui-tests.yml'
10+
11+
jobs:
12+
ui:
13+
name: UI (Lint/Typecheck/Unit)
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '22.15.1'
22+
cache: 'pnpm'
23+
24+
- name: Setup pnpm
25+
uses: pnpm/action-setup@v4
26+
27+
- name: Install dependencies
28+
run: pnpm install --frozen-lockfile
29+
30+
- name: Lint
31+
run: pnpm --filter @snowtree/ui lint
32+
33+
- name: Typecheck
34+
run: pnpm --filter @snowtree/ui typecheck
35+
36+
- name: Unit tests
37+
run: pnpm --filter @snowtree/ui test
38+
39+
e2e-tests:
40+
name: E2E Tests
41+
runs-on: ubuntu-latest
42+
timeout-minutes: 10
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Setup pnpm
47+
uses: pnpm/action-setup@v4
48+
49+
- name: Setup Node.js
50+
uses: actions/setup-node@v4
51+
with:
52+
node-version: '22.15.1'
53+
cache: 'pnpm'
54+
55+
- name: Install dependencies
56+
run: pnpm install --frozen-lockfile
57+
58+
- name: Install Playwright browsers
59+
run: pnpm exec playwright install --with-deps chromium
60+
61+
- name: Start UI dev server
62+
run: |
63+
pnpm --filter @snowtree/ui dev -- --port 4521 --strictPort &
64+
pnpm exec wait-on http://localhost:4521 -t 60000
65+
66+
- name: Run E2E tests
67+
run: pnpm --filter @snowtree/ui test:e2e
68+
env:
69+
CI: true
70+
71+
- name: Upload Playwright report
72+
if: always()
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: playwright-report
76+
path: packages/ui/playwright-report/
77+
retention-days: 7
78+
79+
# Legacy jobs removed; covered by `ui` and `e2e-tests`.

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ dist-electron/
77
*.tsbuildinfo
88
tools/dev-*/
99

10+
# Test output
11+
coverage/
12+
test-results/
13+
packages/**/coverage/
14+
packages/**/test-results/
15+
packages/ui/playwright-report/
16+
17+
# Local E2E data
18+
packages/ui/.e2e-test-repo/
19+
packages/ui/.snowtree_e2e/
20+
1021
# Logs
1122
*.log
1223

Makefile

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
.DEFAULT_GOAL := help
2+
3+
.PHONY: help install run dev dev-ui dev-desktop
4+
.PHONY: typecheck lint check test test-ui test-desktop
5+
.PHONY: e2e e2e-electron build ci rebuild-electron
6+
7+
help:
8+
@echo "Snowtree (from source)"
9+
@echo ""
10+
@echo "Run:"
11+
@echo " make install Install dependencies"
12+
@echo " make run Start dev app (UI + desktop + Electron)"
13+
@echo " make dev-ui Start UI only (Vite)"
14+
@echo " make dev-desktop Watch-build desktop only (tsc -w)"
15+
@echo ""
16+
@echo "Test:"
17+
@echo " make check typecheck + lint + unit tests"
18+
@echo " make test Unit tests (UI + desktop)"
19+
@echo " make e2e Playwright E2E (browser)"
20+
@echo " make e2e-electron Playwright E2E (Electron; needs a display on Linux)"
21+
@echo ""
22+
@echo "Build:"
23+
@echo " make build Build all packages (core/desktop/ui)"
24+
@echo ""
25+
@echo "Troubleshooting:"
26+
@echo " make rebuild-electron Rebuild native deps (e.g. better-sqlite3 ABI)"
27+
28+
install:
29+
pnpm install
30+
31+
typecheck:
32+
pnpm typecheck
33+
34+
lint:
35+
pnpm lint
36+
37+
check: typecheck lint test
38+
39+
run:
40+
pnpm dev
41+
42+
dev: run
43+
44+
dev-ui:
45+
pnpm --filter @snowtree/ui dev
46+
47+
dev-desktop:
48+
pnpm --filter @snowtree/desktop dev
49+
50+
rebuild-electron:
51+
pnpm run electron:rebuild
52+
53+
test: test-ui test-desktop
54+
55+
test-ui:
56+
pnpm --filter @snowtree/ui test
57+
58+
test-desktop:
59+
pnpm --filter @snowtree/desktop test:ci
60+
61+
e2e:
62+
pnpm --filter @snowtree/ui test:e2e
63+
64+
e2e-electron:
65+
pnpm --filter @snowtree/ui test:e2e:electron
66+
67+
build:
68+
pnpm --filter @snowtree/core build
69+
pnpm --filter @snowtree/desktop build
70+
pnpm --filter @snowtree/ui build
71+
72+
ci: typecheck lint test e2e e2e-electron build

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,20 @@
1717
## Quick Start
1818

1919
```bash
20-
pnpm install
21-
pnpm dev
20+
make install
21+
make run
2222
```
2323

24+
## Testing
25+
26+
```bash
27+
make check # typecheck + lint + unit tests
28+
make e2e # Playwright (browser)
29+
make e2e-electron # Playwright (Electron; needs a display on Linux)
30+
```
31+
32+
Run `make` to see all available targets.
33+
2434
## License
2535

2636
Apache-2.0 © 2026 BohuTANG

eslint.config.mjs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import tsParser from '@typescript-eslint/parser';
4+
import tsPlugin from '@typescript-eslint/eslint-plugin';
5+
import reactHooks from 'eslint-plugin-react-hooks';
6+
import reactRefresh from 'eslint-plugin-react-refresh';
7+
8+
const vitestGlobals = {
9+
describe: 'readonly',
10+
it: 'readonly',
11+
test: 'readonly',
12+
expect: 'readonly',
13+
vi: 'readonly',
14+
beforeEach: 'readonly',
15+
afterEach: 'readonly',
16+
beforeAll: 'readonly',
17+
afterAll: 'readonly',
18+
};
19+
20+
export default [
21+
{
22+
ignores: [
23+
'**/node_modules/**',
24+
'**/dist/**',
25+
'dist-electron/**',
26+
'**/*.min.js',
27+
'**/*.config.js',
28+
'**/*.config.cjs',
29+
'**/*.config.mjs',
30+
'packages/ui/playwright-report/**',
31+
'test-results/**',
32+
'frontend/public/**',
33+
'main/dist/**',
34+
'backend/**',
35+
],
36+
},
37+
38+
{
39+
files: ['**/*.{js,cjs,mjs}'],
40+
...js.configs.recommended,
41+
},
42+
43+
{
44+
files: ['**/*.{ts,tsx}'],
45+
languageOptions: {
46+
parser: tsParser,
47+
parserOptions: {
48+
ecmaVersion: 'latest',
49+
sourceType: 'module',
50+
ecmaFeatures: { jsx: true },
51+
},
52+
globals: {
53+
...globals.browser,
54+
...globals.node,
55+
},
56+
},
57+
plugins: {
58+
'@typescript-eslint': tsPlugin,
59+
},
60+
rules: {
61+
// Prefer TypeScript's analysis for these.
62+
'no-undef': 'off',
63+
'no-unused-vars': 'off',
64+
65+
// Keep TS-focused rules permissive until the codebase is cleaned up.
66+
'@typescript-eslint/ban-ts-comment': 'off',
67+
'@typescript-eslint/no-explicit-any': 'off',
68+
'@typescript-eslint/no-unused-vars': 'off',
69+
},
70+
},
71+
72+
{
73+
files: ['**/*.test.{ts,tsx}', '**/__tests__/**/*.{ts,tsx}'],
74+
languageOptions: {
75+
globals: {
76+
...vitestGlobals,
77+
},
78+
},
79+
},
80+
81+
{
82+
files: ['packages/ui/**/*.{ts,tsx}'],
83+
plugins: {
84+
'react-hooks': reactHooks,
85+
'react-refresh': reactRefresh,
86+
},
87+
rules: {
88+
...reactHooks.configs.recommended.rules,
89+
...reactRefresh.configs.recommended.rules,
90+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
91+
},
92+
},
93+
];

0 commit comments

Comments
 (0)