-
Notifications
You must be signed in to change notification settings - Fork 0
242 lines (199 loc) · 7.55 KB
/
Copy path_python-react-tests.yml
File metadata and controls
242 lines (199 loc) · 7.55 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
name: Reusable Python+React Test Suite
# Internal building block: the backend/frontend/e2e/api-freshness matrix
# shared by python-react-ci.yml and python-react-publish.yml. Consumers
# don't call this directly — the CI and publish workflows wrap it. The
# leading underscore marks it internal.
#
# python-react-ci.yml and python-react-publish.yml call this with a full
# owner/repo path pinned to their own release tag, NOT a `./` local path:
# a `./` reference inside a cross-repo-called reusable workflow resolves
# against the CONSUMER's repository (no such file) and 0s startup_failures.
# That @ref must be bumped on every release to stay in lockstep.
on:
workflow_call:
inputs:
python-version:
type: string
default: "3.14"
bun-version-file:
type: string
default: ".bun-version"
bun-version:
# Escape hatch — leave empty to use bun-version-file.
type: string
default: ""
enable-e2e:
type: boolean
default: true
enable-translations:
type: boolean
default: false
enable-bootstrap-token:
type: boolean
default: false
enable-api-freshness-check:
type: boolean
default: true
runner-os:
type: string
default: ubuntu-latest
security-tripwire-script:
type: string
default: ""
permissions:
contents: read
jobs:
test-backend:
name: Backend Tests
runs-on: ${{ inputs.runner-os }}
timeout-minutes: 25
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: ${{ inputs.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8
with:
enable-cache: true
cache-dependency-glob: 'backend/uv.lock'
- name: Install dependencies
run: |
cd backend
uv sync --frozen --all-extras
- name: Run ruff linter
run: cd backend && uv run ruff check .
- name: Run ruff formatter check
run: cd backend && uv run ruff format --check .
- name: Run pyright type checking
run: cd backend && PYTHONPATH=. uv run pyright
- name: Security tripwire
if: inputs.security-tripwire-script != ''
run: bash "${{ inputs.security-tripwire-script }}"
- name: Run pytest
run: |
cd backend
timeout 20m uv run pytest tests/ -v --tb=short
test-frontend:
name: Frontend Tests
runs-on: ${{ inputs.runner-os }}
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Set up Bun (from version-file)
if: inputs.bun-version == ''
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: ${{ inputs.bun-version-file }}
- name: Set up Bun (from explicit override)
if: inputs.bun-version != ''
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: ${{ inputs.bun-version }}
- name: Install dependencies
run: |
cd frontend
if [ "$GITHUB_ACTOR" = "dependabot[bot]" ]; then bun install; else bun install --frozen-lockfile; fi
- name: Run TypeScript type checking
run: cd frontend && bun run type-check
- name: Run linter
run: cd frontend && bun run lint
- name: Validate translation keys
if: inputs.enable-translations
run: cd frontend && bun run validate:translations
- name: Run tests
run: cd frontend && bun run test:run
test-e2e:
name: E2E Tests
if: inputs.enable-e2e
runs-on: ${{ inputs.runner-os }}
timeout-minutes: 20
needs: [test-backend, test-frontend]
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: ${{ inputs.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8
with:
enable-cache: true
cache-dependency-glob: 'backend/uv.lock'
- name: Install backend dependencies
run: cd backend && uv sync --frozen --all-extras
- name: Set up Bun (from version-file)
if: inputs.bun-version == ''
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: ${{ inputs.bun-version-file }}
- name: Set up Bun (from explicit override)
if: inputs.bun-version != ''
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: ${{ inputs.bun-version }}
- name: Install frontend dependencies
run: |
cd frontend
if [ "$GITHUB_ACTOR" = "dependabot[bot]" ]; then bun install; else bun install --frozen-lockfile; fi
- name: Install Playwright browsers
run: cd frontend && bunx playwright install chromium --with-deps
- name: Run E2E tests
run: cd frontend && bun run e2e
env:
CI: true
VULNFORGE_BOOTSTRAP_TOKEN: ${{ inputs.enable-bootstrap-token && 'e2e-ci-test-token' || '' }}
- name: Upload Playwright report
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: ${{ !cancelled() }}
with:
name: playwright-report
path: frontend/playwright-report/
retention-days: 14
- name: Upload test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: ${{ !cancelled() }}
with:
name: playwright-results
path: frontend/test-results/
retention-days: 7
api-types-freshness:
name: API Types Freshness
if: inputs.enable-api-freshness-check
runs-on: ${{ inputs.runner-os }}
timeout-minutes: 15
needs: [test-backend]
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: ${{ inputs.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8
with:
enable-cache: true
cache-dependency-glob: 'backend/uv.lock'
- name: Install backend dependencies
run: cd backend && uv sync --frozen --all-extras
- name: Set up Bun (from version-file)
if: inputs.bun-version == ''
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: ${{ inputs.bun-version-file }}
- name: Set up Bun (from explicit override)
if: inputs.bun-version != ''
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: ${{ inputs.bun-version }}
- name: Install frontend dependencies
run: |
cd frontend
if [ "$GITHUB_ACTOR" = "dependabot[bot]" ]; then bun install; else bun install --frozen-lockfile; fi
- name: Check API types freshness
run: cd frontend && bun run check:api-freshness