-
Notifications
You must be signed in to change notification settings - Fork 0
362 lines (346 loc) · 13.3 KB
/
Copy pathpr.yml
File metadata and controls
362 lines (346 loc) · 13.3 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
name: PR
on:
pull_request:
branches: [main]
# Cancel in-progress runs when new commits are pushed to the same PR
# so we never waste minutes on outdated code. On main (push), github.ref is
# refs/heads/main — separate concurrency key from PR runs.
concurrency:
group: pr-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
NODE_VERSION: "24"
# Hash all workspace pyproject.toml files so cache invalidates when any
# member's deps change. uv.lock is gitignored, so this is the best key
# available; commit uv.lock to get true lockfile-based caching.
UV_CACHE_GLOB: |
pyproject.toml
framework/*/pyproject.toml
modules/*/pyproject.toml
host/pyproject.toml
jobs:
python-lint:
name: Python lint & format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
cache-dependency-glob: ${{ env.UV_CACHE_GLOB }}
- run: make install-py
- run: make ci-python-lint
python-typecheck:
name: Python typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
cache-dependency-glob: ${{ env.UV_CACHE_GLOB }}
- run: make install-py
- run: make ci-python-typecheck
python-tests:
name: Python tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
cache-dependency-glob: ${{ env.UV_CACHE_GLOB }}
- run: make install-py
- run: make test-py
js-tests:
name: JS tests (Vitest)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- run: make install-js
- run: make test-js
js-lint:
name: JS lint & format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- run: make install-js
- run: make ci-js-lint
# Catches user-visible text rendered as a literal instead of t(keys.…).
# Shipping a locales/en.json never proved a page actually read it.
- run: make ci-check-untranslated
js-typecheck:
name: JS typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
# Need uv too — pages.ts imports ./modules.generated, which is
# produced by `smpy gen-pages` from the installed Python modules.
- uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
cache-dependency-glob: ${{ env.UV_CACHE_GLOB }}
- run: make install-py
- run: make install-js
- run: make gen-pages
- run: make ci-js-typecheck
js-build:
name: JS build (Vite)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
# gen-pages needs the Python modules installed so Vite's import.meta.glob
# sees every module's pages/ dir — which is how dep-scan failures surface.
- uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
cache-dependency-glob: ${{ env.UV_CACHE_GLOB }}
- run: make install-py
- run: make install-js
- run: make gen-pages
- run: make build
# These drive a real gen-pages + vite build to prove module-shipped CSS
# and cross-module npm-name imports actually resolve. They self-skip
# without node_modules, so the `Python tests` job (make install-py only)
# silently skips them — this is the one job that can really run them.
- name: Module asset build guards
run: uv run pytest framework/cli/tests/test_module_css_build.py
e2e-smoke:
name: E2E smoke (Playwright)
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports: ["6379:6379"]
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 3s
--health-retries 10
env:
# SQLite keeps the job self-contained — no postgres service needed.
# The bootstrap vars create the admin that tests/e2e/test_smoke.py
# logs in as (admin@example.com / admin).
SM_DATABASE_URL: sqlite+aiosqlite:///./app.db
SM_ENVIRONMENT: development
SM_SECRET_KEY: ci-test-key
SM_USERS_BOOTSTRAP_EMAIL: admin@example.com
SM_USERS_BOOTSTRAP_PASSWORD: admin
# Exclude Keycloak module — SM020 prevents both users and keycloak
# from running simultaneously. E2E tests use the users module.
SM_MODULES_ENABLED: '["Auth","Users","Dashboard","Permissions","Settings","BackgroundTasks","FileStorage","FeatureFlags","AuditLog"]'
E2E_BASE_URL: http://localhost:8000
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
cache-dependency-glob: ${{ env.UV_CACHE_GLOB }}
- uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- run: make install
# Playwright's chromium download is ~150MB — cache it keyed on uv.lock so
# we only re-download when the pinned playwright version moves. OS deps
# (apt packages) aren't cacheable across runs but install-deps is fast on
# the GH runner image since most libs are preinstalled.
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v6
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('uv.lock') }}
- name: Install Playwright chromium
run: |
if [ "${{ steps.playwright-cache.outputs.cache-hit }}" = "true" ]; then
uv run --project host playwright install-deps chromium
else
uv run --project host playwright install --with-deps chromium
fi
- run: make gen-pages
- run: uv run --project host alembic -c host/alembic.ini upgrade heads
- name: Start API + Vite
run: |
uv run --project host uvicorn host.main:app --port 8000 > api.log 2>&1 &
echo $! > api.pid
npm run --workspace host/client_app dev > vite.log 2>&1 &
echo $! > vite.pid
- name: Wait for API + Vite
run: |
for i in $(seq 1 60); do
curl -sf http://localhost:8000/health > /dev/null && \
curl -sf http://localhost:5050/@vite/client > /dev/null && \
echo "services ready" && exit 0
sleep 1
done
echo "services did not come up in time"
echo "--- api.log ---"; cat api.log || true
echo "--- vite.log ---"; cat vite.log || true
exit 1
- run: make test-e2e
- name: Upload server logs on failure
if: failure()
uses: actions/upload-artifact@v7
with:
name: e2e-server-logs
path: |
api.log
vite.log
# Guards the asset-delivery wins from docs/perf/2026-08-02-baseline.md:
# response compression (~70% of transfer) and chunk grouping (55 -> 13
# requests on cold load). Both are invisible to every other job — the app
# renders identically either way, just slower, so only a browser measuring
# the built bundle catches a regression.
#
# Runs against the PRODUCTION build deliberately: chunk groups only apply to
# `vite build`, and non-dev environments are what reference the built
# manifest. Asserts on structure (request count, compression ratio), never on
# milliseconds, so shared-runner noise cannot make it flaky.
#
# The other three guards (compression headers, canonical menu URLs, dialect
# branch selection) are plain pytest and already run in `python-tests`.
perf-guards:
name: Perf guards (Playwright)
runs-on: ubuntu-latest
env:
# SQLite keeps the job self-contained — these guards measure asset
# delivery, which does not depend on row volumes.
SM_DATABASE_URL: sqlite+aiosqlite:///./app.db
PERF_BASE_URL: http://localhost:8000
PERF_BUILD: ci-prod
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
cache-dependency-glob: ${{ env.UV_CACHE_GLOB }}
- uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- run: make install
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v6
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('uv.lock') }}
- name: Install Playwright chromium
run: |
if [ "${{ steps.playwright-cache.outputs.cache-hit }}" = "true" ]; then
uv run --project host playwright install-deps chromium
else
uv run --project host playwright install --with-deps chromium
fi
- run: make gen-pages
- run: make build
- run: uv run --project host alembic -c host/alembic.ini upgrade heads
# The production config lives on THIS step only, never job-wide. Under
# SM_ENVIRONMENT=production the simple_module_test pytest plugin fails to
# import — it builds BackgroundTasksSettings() eagerly and those reject a
# localhost broker — so exporting it job-wide stops pytest from starting
# at all. The server needs it; the test process must not see it.
- name: Start API
env:
# A non-dev environment is what makes the host serve the built
# manifest instead of pointing at the Vite dev server.
SM_ENVIRONMENT: production
SM_SECRET_KEY: ci-perf-secret-key-not-a-real-secret-000000000000
SM_USERS_RESET_PASSWORD_TOKEN_SECRET: ci-perf-reset-secret-000000000000000000
SM_USERS_VERIFICATION_TOKEN_SECRET: ci-perf-verify-secret-00000000000000000
SM_USERS_BOOTSTRAP_EMAIL: admin@example.com
SM_USERS_BOOTSTRAP_PASSWORD: admin
# Keycloak excluded (SM020: one auth provider). BackgroundTasks
# excluded because its DB-hydrated settings reject a localhost broker
# under SM_ENVIRONMENT=production.
SM_MODULES_ENABLED: '["Auth","Users","Dashboard","Permissions","Settings","FileStorage","FeatureFlags","AuditLog","Branding"]'
run: |
uv run --project host uvicorn host.main:app --port 8000 > api.log 2>&1 &
echo $! > api.pid
- name: Wait for API
run: |
for i in $(seq 1 60); do
curl -sf http://localhost:8000/health > /dev/null && echo "api ready" && exit 0
sleep 1
done
echo "api did not come up in time"; cat api.log || true; exit 1
- name: Verify built assets are being served
run: |
# If this regresses to the Vite dev path the guards would measure the
# wrong bundle and pass vacuously.
curl -sf http://localhost:8000/users/login | grep -q '/static/dist/assets/' \
|| { echo "server is not serving built assets"; exit 1; }
- run: uv run pytest -m "perf and e2e" tests/perf/test_page_load.py tests/perf/test_asset_integrity.py -v -s
- name: Upload server log on failure
if: failure()
uses: actions/upload-artifact@v7
with:
name: perf-guards-api-log
path: api.log
file-size-check:
name: File size (300-line cap)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
cache-dependency-glob: ${{ env.UV_CACHE_GLOB }}
- run: make install-py
- run: make ci-check-file-size
# Dry-run the release build on every PR — same `uv build --all-packages`
# invocation the release workflow runs, so any packaging regression
# (force-include going outside the package, missing template, broken sdist→
# wheel rebuild, etc.) fails here instead of only when someone clicks
# "Run workflow" on Releases. No deps install needed: build isolation
# provisions each package's build backend on its own.
package-build:
name: Package build (release dry-run)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
cache-dependency-glob: ${{ env.UV_CACHE_GLOB }}
- run: make ci-build-packages
# Single required status check for branch protection.
# Protect `main` with this one check and every leaf job is required transitively.
pr-checks:
name: PR checks
runs-on: ubuntu-latest
needs:
- python-lint
- python-typecheck
- python-tests
- js-lint
- js-typecheck
- js-tests
- js-build
- e2e-smoke
- perf-guards
- file-size-check
- package-build
if: always()
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1