forked from huangruiteng/loopx
-
Notifications
You must be signed in to change notification settings - Fork 0
307 lines (284 loc) · 10.2 KB
/
Copy pathpython-tests.yml
File metadata and controls
307 lines (284 loc) · 10.2 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
name: Python Tests
on:
pull_request:
paths:
- ".github/workflows/python-tests.yml"
- ".github/workflows/sonarcloud.yml"
- "sonar-project.properties"
- "apps/**"
- "loopx/**"
- "scripts/**"
- "tests/**"
- "examples/**"
- "package.json"
- "package-lock.json"
- "pyproject.toml"
- "tsconfig.control-plane.json"
push:
branches:
- main
paths:
- ".github/workflows/python-tests.yml"
- ".github/workflows/sonarcloud.yml"
- "sonar-project.properties"
- "apps/**"
- "loopx/**"
- "scripts/**"
- "tests/**"
- "examples/**"
- "package.json"
- "package-lock.json"
- "pyproject.toml"
- "tsconfig.control-plane.json"
permissions:
contents: read
concurrency:
group: python-tests-${{ github.ref }}
cancel-in-progress: true
jobs:
checks:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- name: Set up the TypeScript Effect runtime
uses: actions/setup-node@v6
with:
node-version: "22.6"
cache: npm
cache-dependency-path: package-lock.json
- name: Install test dependencies
run: python -m pip install --disable-pip-version-check -e ".[test]"
- name: Qualify the TypeScript Effect core
run: |
npm ci --ignore-scripts
npm run typecheck:control-plane
npm run test:control-plane
- name: Lint test suite
run: >-
python -m ruff check
tests
loopx/canary
loopx/control_plane
loopx/domain_packs
loopx/presentation
- name: Type-check kernel contracts
run: python -m mypy
- name: Qualify agent-facing CLI output
env:
LOOPX_CLI_OUTPUT_BASE_REF: origin/${{ github.event.pull_request.base.ref || 'main' }}
run: python examples/control_plane/cli-output-budget-regression-smoke.py
test-shard:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
shard: [1, 2]
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- uses: actions/setup-node@v6
with:
node-version: "22.6"
cache: npm
cache-dependency-path: package-lock.json
- name: Install test dependencies
run: |
python -m pip install --disable-pip-version-check -e ".[test]"
npm ci --ignore-scripts
- name: Run test shard
# Split the whole collection, not a hand-maintained list of directories.
# Without timing history least_duration alternates equal-weight tests.
# Each runner retains the measured two-worker pool.
run: >-
python -m pytest -q -n 2 -m "not stage2c_e2e"
--splits 2 --group ${{ matrix.shard }}
--splitting-algorithm least_duration
--durations=25 --durations-min=1
--cov=loopx
--cov-report=term
- name: Upload shard coverage
uses: actions/upload-artifact@v7
with:
name: python-coverage-${{ matrix.shard }}
path: .coverage
include-hidden-files: true
if-no-files-found: error
retention-days: 3
pytest:
# Keep the required check name; a skipped/failed shard must not turn it green.
if: always()
needs: [checks, test-shard]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Require every upstream check
env:
CHECKS_RESULT: ${{ needs.checks.result }}
SHARDS_RESULT: ${{ needs.test-shard.result }}
run: |
test "$CHECKS_RESULT" = success
test "$SHARDS_RESULT" = success
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- run: python -m pip install --disable-pip-version-check -e ".[test]"
- uses: actions/download-artifact@v7
with:
pattern: python-coverage-*
path: coverage-shards
- name: Combine complete coverage and enforce the existing floor
run: |
test -s coverage-shards/python-coverage-1/.coverage
test -s coverage-shards/python-coverage-2/.coverage
python -m coverage combine coverage-shards/python-coverage-1/.coverage coverage-shards/python-coverage-2/.coverage
python -m coverage report --fail-under=19.6
python -m coverage xml -o coverage.xml
- uses: actions/upload-artifact@v7
with:
name: python-coverage-xml
path: coverage.xml
if-no-files-found: error
retention-days: 3
sonar:
needs: pytest
uses: ./.github/workflows/sonarcloud.yml
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
stage2c-suite:
name: stage2c (${{ matrix.suite }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
suite: [e2e, mutants, installed]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
cache-dependency-path: tests/requirements-stage2c-linux-py311.txt
- uses: actions/setup-node@v6
with:
node-version: "22.6"
cache: npm
- name: Install locked test and package build tools
run: |
python -m pip install --disable-pip-version-check --require-hashes --only-binary=:all: -r tests/requirements-stage2c-linux-py311.txt
npm ci --ignore-scripts
- name: Build and verify the checked-out source package
run: |
python -m build --no-isolation --wheel --outdir .local/stage2c-source-install
python - <<'PYTHON'
import hashlib
from pathlib import Path
directory = Path(".local/stage2c-source-install").resolve()
wheels = list(directory.glob("*.whl"))
if len(wheels) != 1:
raise SystemExit("Expected exactly one wheel from the checked-out source")
wheel = wheels[0]
digest = hashlib.sha256(wheel.read_bytes()).hexdigest()
(directory / "requirements.txt").write_text(
f"loopx @ {wheel.as_uri()} --hash=sha256:{digest}\n", encoding="utf-8"
)
PYTHON
python -m pip install --disable-pip-version-check --require-hashes --no-deps --no-index -r .local/stage2c-source-install/requirements.txt
python -m pip check
# Remove the generated source copy before pytest's normal discovery.
python -c "import shutil; shutil.rmtree('build')"
- name: Qualify real CLI, mixed writers, process death, and recovery
if: matrix.suite == 'e2e'
env:
LOOPX_SHADOW_COMPARISON_OUTPUT: .local/stage2c-observables
# Keep each module's shared workspace and ordered parity rows on one worker.
run: python -m pytest -q -n 2 --dist loadfile -m stage2c_e2e --durations=20 --junitxml=stage2c-e2e.xml
- name: Reject deliberate correctness regressions
if: matrix.suite == 'mutants'
run: python examples/shared-goal-authority-e2e/mutants.py --output .local/stage2c-mutants
- name: Build independently installed distributions
if: matrix.suite == 'installed'
run: python -m build --no-isolation
- name: Qualify wheel outside the repository
if: matrix.suite == 'installed'
run: python examples/shared-goal-authority-e2e/installed.py --artifact dist/*.whl --report-json installed-wheel.json
- name: Qualify sdist outside the repository
if: matrix.suite == 'installed'
run: python examples/shared-goal-authority-e2e/installed.py --artifact dist/*.tar.gz --report-json installed-sdist.json
- name: Retain bounded acceptance evidence
if: always()
uses: actions/upload-artifact@v7
with:
name: stage2c-correctness-evidence-${{ matrix.suite }}
include-hidden-files: true
if-no-files-found: error
path: |
stage2c-e2e.xml
.local/stage2c-observables/
installed-wheel.json
installed-sdist.json
.local/stage2c-mutants/
stage2c-correctness-e2e:
# Preserve the public check name and reject failed, cancelled or skipped lanes.
if: always()
needs: [stage2c-suite]
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Require every Stage 2C lane
env:
STAGE2C_RESULT: ${{ needs.stage2c-suite.result }}
run: test "$STAGE2C_RESULT" = success
windows-powershell:
runs-on: windows-latest
timeout-minutes: 20
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- name: Set up the TypeScript Effect runtime
uses: actions/setup-node@v6
with:
node-version: "22.6"
- name: Install test dependencies
run: python -m pip install --disable-pip-version-check -e ".[test]"
- name: Run native Windows lifecycle tests
run: >-
python -m pytest -q
tests/test_command_invocation.py
tests/test_doctor_install_freshness.py
tests/test_file_lock.py
tests/test_file_lock_cross_process.py
tests/control_plane/test_coordination_file_provider.py
tests/control_plane/test_effect_runtime_integration.py
tests/control_plane/test_local_authority_shadow_outbox.py
tests/test_self_update_runtime_activation.py
tests/test_windows_install.py
- name: Run native scheduler facade tests
run: >-
node --no-warnings --experimental-strip-types --test
tests/control_plane_ts/scheduler_heartbeat_commit.test.ts
tests/control_plane_ts/scheduler_heartbeat_commit_cli.test.ts