diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e718c423..755396df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,9 @@ jobs: - name: Lint run: npm run lint + - name: Frontend JS syntax check + run: npm run check:frontend-syntax + - name: Format check run: npm run format:check @@ -60,6 +63,34 @@ jobs: cat /tmp/boot.log exit 1 -# Note: The test suite is intentionally excluded from CI. -# Tests spawn real tmux sessions and require a full system environment. -# Run tests locally with: npx vitest run test/.test.ts + test: + name: Unit & integration tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: 22 + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Install tmux + run: | + if ! command -v tmux >/dev/null; then + sudo apt-get update -qq + sudo apt-get install -y tmux + fi + + - name: Run unit & integration tests + # Excludes the browser-driven mobile suite (test/mobile/**); see config/vitest.ci.config.ts. + # Safe in CI: TmuxManager no-ops all shell commands under VITEST (test/setup.ts). + run: npm run test:ci + +# Note: The browser-driven mobile suite (test/mobile/**) is excluded from CI — +# it needs a live server + chromium + environment-specific PNG baselines. +# Run it locally/manually. All other tests run via the `test` job above. diff --git a/config/vitest.ci.config.ts b/config/vitest.ci.config.ts new file mode 100644 index 00000000..24e06052 --- /dev/null +++ b/config/vitest.ci.config.ts @@ -0,0 +1,33 @@ +import { resolve } from 'node:path'; +import { defineConfig, configDefaults } from 'vitest/config'; + +const root = resolve(import.meta.dirname, '..'); + +/** + * CI test config — same as vitest.config.ts but EXCLUDES the browser-driven + * mobile suite (test/mobile/**). Those are Playwright visual-regression tests + * that need a live server + chromium + environment-specific PNG baselines, so + * they are run/maintained separately and are not part of the CI gate. + * + * Keep the rest in sync with config/vitest.config.ts. + */ +export default defineConfig({ + test: { + root, + globals: true, + environment: 'node', + include: ['test/**/*.test.ts'], + exclude: [ + ...configDefaults.exclude, + 'test/mobile/**', // browser/visual (Playwright + chromium) + 'test/perf-*.test.ts', // timing-sensitive perf benchmarks (flaky in CI) + 'test/inline-rename.test.ts', // browser (Playwright) + 'test/opencode-resize.test.ts', // browser (Playwright) + 'test/webgl-fallback.test.ts', // browser (Playwright) + ], + setupFiles: ['./test/setup.ts'], + fileParallelism: false, + testTimeout: 30000, + teardownTimeout: 60000, + }, +}); diff --git a/package.json b/package.json index ac066a69..d4dc5243 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,8 @@ "test": "vitest run --config config/vitest.config.ts", "test:watch": "vitest --config config/vitest.config.ts", "test:coverage": "vitest run --config config/vitest.config.ts --coverage", + "test:ci": "vitest run --config config/vitest.ci.config.ts", + "check:frontend-syntax": "node scripts/check-frontend-syntax.mjs", "typecheck": "tsc --noEmit", "lint": "eslint --config config/eslint.config.js 'src/**/*.ts'", "lint:fix": "eslint --config config/eslint.config.js 'src/**/*.ts' --fix", diff --git a/scripts/check-frontend-syntax.mjs b/scripts/check-frontend-syntax.mjs new file mode 100644 index 00000000..40c9ba00 --- /dev/null +++ b/scripts/check-frontend-syntax.mjs @@ -0,0 +1,40 @@ +#!/usr/bin/env node +/** + * Frontend JS syntax check. + * + * CI's `npm run lint` only lints TypeScript under src/, and `tsc` excludes the + * frontend — so a plain SyntaxError in a shipped `src/web/public` script (loaded + * as a bare