Skip to content
Open
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
80 changes: 78 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ on:
branches: [main]
pull_request:
branches: [main]
schedule:
# Run twice daily at 00:00 and 12:00 UTC
- cron: "0 0,12 * * *"

jobs:
test:
unit-test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
Expand Down Expand Up @@ -43,8 +46,81 @@ jobs:
- name: Type check
run: pnpm run build:check

- name: Test
- name: Test with coverage
if: runner.os == 'Linux'
run: pnpm run test:coverage:ci

- name: Test (no coverage)
if: runner.os != 'Linux'
run: pnpm test

- name: Upload coverage report
if: runner.os == 'Linux' && always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
retention-days: 14

e2e-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- run: pnpm install

- name: Install Playwright browsers
run: pnpm run test:e2e:install

- name: Build web assets
run: pnpm run build

- name: Run E2E tests
run: pnpm run test:e2e

- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
retention-days: 14

- name: Upload Playwright traces
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-traces
path: test-results/
retention-days: 7

build:
runs-on: ubuntu-latest
needs: [unit-test]

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- run: pnpm install

- name: Build
run: pnpm run build
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ tmp/
dist/
release/
.playwright-cli/
coverage/
playwright-report/
test-results/
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"build": "tsc -p tsconfig.json && vite build --config web/vite.config.ts && node -e \"require('fs').copyFileSync('viewer/index.html','dist/viewer/index.html')\"",
"build:check": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p web/tsconfig.json",
"test": "node scripts/run-tests.mjs",
"test:coverage": "npx c8 --include='lib/**' --include='viewer/**' --include='web/src/hooks/url-state-core.ts' --exclude='test/**' --exclude='lib/settings-merge-cli.ts' --exclude='viewer/start.ts' node scripts/run-tests.mjs",
"test:coverage": "npx c8 --include='lib/**' --include='viewer/**' --include='web/src/hooks/url-state-core.ts' --exclude='test/**' --exclude='lib/settings-merge-cli.ts' --exclude='viewer/start.ts' --reporter=text --reporter=text-summary node scripts/run-tests.mjs",
"test:coverage:ci": "npx c8 --include='lib/**' --include='viewer/**' --include='web/src/hooks/url-state-core.ts' --exclude='test/**' --exclude='lib/settings-merge-cli.ts' --exclude='viewer/start.ts' --reporter=text --reporter=text-summary --reporter=json --reports-dir=coverage node scripts/run-tests.mjs",
"test:e2e": "npx playwright test",
"test:e2e:install": "npx playwright install chromium --with-deps",
"electron:build:ts": "tsc -p electron/tsconfig.json",
"electron:dev": "ELECTRON_DEV=1 electron dist/electron/main.cjs",
"electron:start": "electron dist/electron/main.cjs",
Expand Down
22 changes: 20 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import { defineConfig } from "@playwright/test";
import { defineConfig, devices } from "@playwright/test";

const isCI = !!process.env.CI;

export default defineConfig({
testDir: "./e2e",
timeout: 30000,
retries: 0,
retries: isCI ? 2 : 0,
workers: isCI ? 1 : undefined,
reporter: isCI ? [["html", { open: "never" }], ["github"]] : [["list"]],
use: {
baseURL: "http://localhost:7777",
headless: true,
screenshot: "only-on-failure",
trace: "on-first-retry",
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
webServer: {
command: "npx tsx viewer/start.ts",
url: "http://localhost:7777",
reuseExistingServer: !isCI,
timeout: 15000,
},
});
Loading