-
-
Notifications
You must be signed in to change notification settings - Fork 72
225 lines (196 loc) · 6.57 KB
/
Copy pathpr-tests.yml
File metadata and controls
225 lines (196 loc) · 6.57 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: PR Tests
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- '**.ts'
- '**.tsx'
- '**.js'
- '**.jsx'
- '**.json'
- '**.md'
- 'docs/**'
- '.github/workflows/pr-tests.yml'
# Cancel in-progress runs for the same PR
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
quick-test:
name: Quick Tests
runs-on: ubuntu-latest
# The full unit suite (npm run test:run) keeps growing: ~10 min when the
# cap was first raised (#3385), ~14 min by 2026-07 — so the 15-min cap
# started timing the job out at the boundary again (GitHub reports the
# timeout as "cancelled"). Keep real headroom above the observed runtime.
timeout-minutes: 25
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: meshmonitor_test
ports:
- 5433:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: test
MYSQL_PASSWORD: test
MYSQL_DATABASE: meshmonitor_test
ports:
- 3307:3306
options: >-
--health-cmd "mysqladmin ping -h localhost"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0 # Fetch all history for better diffing
submodules: recursive # Initialize protobufs submodule for tests
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '24.x'
cache: 'npm'
- name: Install dependencies
run: |
npm install --prefer-offline --no-audit --legacy-peer-deps
- name: Check formatting
run: |
echo "Checking code formatting..."
# Add prettier check when configured
# npm run format:check
- name: Run lint ratchet
run: |
echo "Running ESLint ratchet..."
# BLOCKING: fails only on new violations above the checked-in baseline.
# Existing debt is frozen in eslint-baseline.json and burns down over time.
# Regenerate baseline: npm run lint:baseline. Tracking: #3962 Task 1.4.
npm run lint:ci
- name: Type check
run: |
echo "Running TypeScript compiler..."
npm run typecheck
- name: Type-check tests (non-blocking)
run: npm run typecheck:tests
# NON-BLOCKING: ~283 pre-existing test-type errors. Flip to blocking (drop continue-on-error)
# when `npm run typecheck:tests` reports 0. Tracking: #3962 Task 1.2.
continue-on-error: true
- name: Run unit tests
run: |
echo "Running test suite..."
npm run test:run
- name: Generate test summary
if: always()
run: |
echo "## Test Results Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ $? -eq 0 ]; then
echo "✅ All tests passed!" >> $GITHUB_STEP_SUMMARY
else
echo "❌ Some tests failed. Please check the logs." >> $GITHUB_STEP_SUMMARY
fi
changed-files:
name: Detect Changed Files
runs-on: ubuntu-latest
outputs:
backend: ${{ steps.changes.outputs.backend }}
frontend: ${{ steps.changes.outputs.frontend }}
docker: ${{ steps.changes.outputs.docker }}
docs: ${{ steps.changes.outputs.docs }}
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Check for changes
uses: dorny/paths-filter@v4
id: changes
with:
filters: |
backend:
- 'src/server/**'
- 'src/services/**'
- 'package.json'
- 'tsconfig.server.json'
frontend:
- 'src/**'
- '!src/server/**'
- '!src/services/**'
- 'index.html'
- 'vite.config.ts'
docker:
- 'Dockerfile'
- '.dockerignore'
docs:
- 'docs/**'
- '**.md'
focused-tests:
name: Focused Tests
runs-on: ubuntu-latest
needs: changed-files
if: needs.changed-files.outputs.backend == 'true' || needs.changed-files.outputs.frontend == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
submodules: recursive # Initialize protobufs submodule for tests
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '24.x'
cache: 'npm'
- name: Install dependencies
run: npm install --prefer-offline --no-audit --legacy-peer-deps
- name: Test backend changes
if: needs.changed-files.outputs.backend == 'true'
run: |
echo "Testing backend changes..."
npm run test:run -- src/services/database.test.ts src/server/server.simple.test.ts
- name: Test frontend changes
if: needs.changed-files.outputs.frontend == 'true'
run: |
echo "Testing frontend changes..."
npm run test:run -- src/components/
- name: Build check
run: |
if [[ "${{ needs.changed-files.outputs.backend }}" == "true" ]]; then
echo "Building server..."
npm run build:server
fi
if [[ "${{ needs.changed-files.outputs.frontend }}" == "true" ]]; then
echo "Building frontend..."
npm run build
fi
docs-build:
name: Documentation Build
runs-on: ubuntu-latest
needs: changed-files
if: needs.changed-files.outputs.docs == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '24.x'
cache: 'npm'
- name: Install dependencies
run: npm install --prefer-offline --no-audit --legacy-peer-deps
- name: Build documentation
run: |
echo "Building VitePress documentation..."
npm run docs:build
# The PR Status Check job has been removed as GitHub Actions
# automatically provides its own status checks for each job.
# Attempting to create additional commit statuses requires
# special permissions that are not available by default.