forked from doctly/switchboard
-
Notifications
You must be signed in to change notification settings - Fork 3
72 lines (59 loc) · 2.28 KB
/
Copy pathtest.yml
File metadata and controls
72 lines (59 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Test
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
lint:
# Separate job, not an npm pre-hook: `npm run coverage` (below) has no
# `precoverage`, so `pretest` never fired for it and lint silently never
# ran in CI. A dedicated job can't be skipped by a future script rename —
# it shows up as its own entry in the checks list.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version: [20, 22]
os: [ubuntu-latest, windows-2022]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # diff-cover needs history to compare against the base branch
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Run tests with coverage
run: npm run coverage
# Gate only NEW/changed lines (patch coverage), not the whole codebase:
# main.js (Electron IPC/native) and the DOM glue cannot be unit-tested, so
# a global threshold is meaningless. Runs once (Node 22 on ubuntu-latest)
# on PRs only — os is pinned here too, or the windows-2022 leg would run
# the same gate a second time with a different lcov path style.
- name: Patch coverage gate (changed lines >= 80%)
if: matrix.node-version == 22 && matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request'
run: |
python -m pip install --quiet diff_cover
git fetch origin "${{ github.base_ref }}" --quiet
diff-cover coverage/lcov.info \
--compare-branch "origin/${{ github.base_ref }}" \
--fail-under 80 \
--exclude 'main.js' 'preload.js' 'mcp-bridge.js' 'claude-auth.js' \
'public/codemirror-bundle.js' 'public/codemirror-setup.js' \
'public/terminal-manager.js' 'public/app.js' \
'workers/**' 'scripts/**' 'test/**'