-
Notifications
You must be signed in to change notification settings - Fork 1
390 lines (330 loc) · 12.4 KB
/
Copy pathtest.yml
File metadata and controls
390 lines (330 loc) · 12.4 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
name: Test Suite
on:
pull_request:
branches: [main, master]
push:
branches: [main, master]
schedule:
- cron: "17 8 * * *"
workflow_dispatch:
jobs:
# ===========================================================================
# Path detection (shared with CI)
# ===========================================================================
changes:
name: Detect changes
uses: ./.github/workflows/detect-changes.yml
permissions:
contents: read
pull-requests: read
# ===========================================================================
# Backend Python Tests
# ===========================================================================
backend-tests:
name: Backend Tests (Python ${{ matrix.python-version }})
needs: changes
if: needs.changes.outputs.backend == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Note: Python 3.10+ required due to mokkari>=3.0.0 dependency
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Set up uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y unrar
- name: Install Python dependencies
run: uv sync --locked --extra dev
- name: Run unit tests
run: |
uv run pytest tests/unit -v --cov=comicarr --cov-report=xml --cov-report=term-missing -m "not slow"
- name: Run integration tests
run: |
uv run pytest tests/integration -v --cov=comicarr --cov-append --cov-report=xml --cov-report=term-missing -m "not slow"
- name: Upload coverage report
uses: codecov/codecov-action@v7
if: matrix.python-version == '3.11' # Only upload once
with:
files: ./coverage.xml
flags: backend
name: backend-python-${{ matrix.python-version }}
fail_ci_if_error: false
migration-dialects:
name: Schema migrations (${{ matrix.dialect }})
needs: changes
if: needs.changes.outputs.backend == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- dialect: sqlite
extra: ""
database_url: sqlite:////tmp/comicarr-migrations.db
- dialect: postgresql
extra: postgres
database_url: postgresql://comicarr:comicarr@127.0.0.1:5432/comicarr
- dialect: mysql
extra: mysql-pure
database_url: mysql+pymysql://comicarr:comicarr@127.0.0.1:3306/comicarr
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: comicarr
POSTGRES_USER: comicarr
POSTGRES_PASSWORD: comicarr
ports: [5432:5432]
options: >-
--health-cmd "pg_isready -U comicarr -d comicarr"
--health-interval 10s --health-timeout 5s --health-retries 5
mysql:
image: mysql:8.4
env:
MYSQL_DATABASE: comicarr
MYSQL_USER: comicarr
MYSQL_PASSWORD: comicarr
MYSQL_ROOT_PASSWORD: root
ports: [3306:3306]
options: >-
--health-cmd "mysqladmin ping -h 127.0.0.1 -uroot -proot"
--health-interval 10s --health-timeout 5s --health-retries 10
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-python@v7
with:
python-version: "3.11"
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install migration dependencies
run: uv sync --locked --extra dev ${{ matrix.extra && format('--extra {0}', matrix.extra) || '' }}
- name: Verify application fresh and legacy migration paths
env:
DATABASE_URL: ${{ matrix.database_url }}
run: uv run pytest tests/integration/test_schema_migration_dialects.py -q
- name: Check adopted schema
env:
DATABASE_URL: ${{ matrix.database_url }}
run: |
uv run alembic current --check-heads
uv run alembic check
# ===========================================================================
# Frontend Tests
# ===========================================================================
frontend-tests:
name: Frontend Tests
needs: changes
if: needs.changes.outputs.frontend == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: 'frontend/package-lock.json'
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
- name: Run type checking
run: npm run typecheck
- name: Run unit and component tests
run: npm run test:run
- name: Run tests with coverage
run: npm run test:coverage
continue-on-error: true # Coverage may fail if no tests exist yet
- name: Upload coverage report
uses: codecov/codecov-action@v7
with:
files: ./frontend/coverage/lcov.info
flags: frontend
name: frontend
fail_ci_if_error: false
# ===========================================================================
# E2E Tests
# Runs when app surfaces change. Unit jobs that were skipped (other side of
# the monorepo) do not block; a failing unit job on a side that *did* change
# still blocks E2E.
# ===========================================================================
e2e-tests:
name: E2E Smoke Tests
runs-on: ubuntu-latest
needs: [changes, backend-tests, frontend-tests]
if: >-
always()
&& !cancelled()
&& needs.changes.result == 'success'
&& needs.changes.outputs.e2e == 'true'
&& (needs.changes.outputs.backend != 'true' || needs.backend-tests.result == 'success')
&& (needs.changes.outputs.frontend != 'true' || needs.frontend-tests.result == 'success')
steps:
- uses: actions/checkout@v7
- name: Set up Python 3.11
uses: actions/setup-python@v7
with:
python-version: "3.11"
- name: Set up uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
cache-dependency-glob: uv.lock
- uses: actions/setup-node@v7
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: 'frontend/package-lock.json'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y unrar
- name: Install Python dependencies
run: uv sync --locked
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
- name: Install Playwright browsers
working-directory: frontend
run: npx playwright install --with-deps chromium
- name: Build frontend
working-directory: frontend
run: npm run build
- name: Run smoke E2E tests
working-directory: frontend
run: npm run test:e2e:smoke
env:
COMICARR_E2E_PYTHON: ${{ github.workspace }}/.venv/bin/python
- name: Upload Playwright report
uses: actions/upload-artifact@v7
if: failure()
with:
name: playwright-smoke-report
path: frontend/playwright-report/
retention-days: 7
- name: Upload Playwright traces
uses: actions/upload-artifact@v7
if: failure()
with:
name: playwright-smoke-test-results
path: frontend/test-results/
retention-days: 7
# ===========================================================================
# Full E2E Tests
# ===========================================================================
e2e-full-tests:
name: E2E Full Tests
runs-on: ubuntu-latest
needs: [changes, backend-tests, frontend-tests]
if: >-
always()
&& !cancelled()
&& needs.changes.result == 'success'
&& (
github.event_name == 'schedule'
|| github.event_name == 'workflow_dispatch'
|| (github.event_name == 'push' && needs.changes.outputs.e2e == 'true')
)
&& (needs.changes.outputs.backend != 'true' || needs.backend-tests.result == 'success')
&& (needs.changes.outputs.frontend != 'true' || needs.frontend-tests.result == 'success')
steps:
- uses: actions/checkout@v7
- name: Set up Python 3.11
uses: actions/setup-python@v7
with:
python-version: "3.11"
- name: Set up uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
cache-dependency-glob: uv.lock
- uses: actions/setup-node@v7
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: 'frontend/package-lock.json'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y unrar
- name: Install Python dependencies
run: uv sync --locked
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
- name: Install Playwright browsers
working-directory: frontend
run: npx playwright install --with-deps chromium
- name: Build frontend
working-directory: frontend
run: npm run build
- name: Run full E2E tests
working-directory: frontend
run: npm run test:e2e:full
env:
COMICARR_E2E_PYTHON: ${{ github.workspace }}/.venv/bin/python
- name: Upload Playwright report
uses: actions/upload-artifact@v7
if: failure()
with:
name: playwright-full-report
path: frontend/playwright-report/
retention-days: 7
- name: Upload Playwright traces
uses: actions/upload-artifact@v7
if: failure()
with:
name: playwright-full-test-results
path: frontend/test-results/
retention-days: 7
# ===========================================================================
# Summary Job
# Skipped jobs (path-filtered) are treated as pass; only real failures fail CI.
# ===========================================================================
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [changes, backend-tests, frontend-tests, e2e-tests, e2e-full-tests, migration-dialects]
if: always()
steps:
- name: Check test results
run: |
echo "changes=${{ needs.changes.result }}"
echo "backend-tests=${{ needs.backend-tests.result }}"
echo "frontend-tests=${{ needs.frontend-tests.result }}"
echo "e2e-tests=${{ needs.e2e-tests.result }}"
echo "e2e-full-tests=${{ needs.e2e-full-tests.result }}"
echo "migration-dialects=${{ needs.migration-dialects.result }}"
if [ "${{ needs.changes.result }}" == "failure" ] || [ "${{ needs.changes.result }}" == "cancelled" ]; then
echo "Path detection failed!"
exit 1
fi
if [ "${{ needs.backend-tests.result }}" == "failure" ] || [ "${{ needs.frontend-tests.result }}" == "failure" ] || [ "${{ needs.e2e-tests.result }}" == "failure" ] || [ "${{ needs.e2e-full-tests.result }}" == "failure" ] || [ "${{ needs.migration-dialects.result }}" == "failure" ]; then
echo "Some tests failed!"
exit 1
fi
if [ "${{ needs.backend-tests.result }}" == "cancelled" ] || [ "${{ needs.frontend-tests.result }}" == "cancelled" ] || [ "${{ needs.e2e-tests.result }}" == "cancelled" ] || [ "${{ needs.e2e-full-tests.result }}" == "cancelled" ] || [ "${{ needs.migration-dialects.result }}" == "cancelled" ]; then
echo "Some tests were cancelled!"
exit 1
fi
echo "All required tests passed (skipped path-filtered jobs are OK)."