Repository navigation
258 lines (215 loc) · 7.51 KB
/
Copy pathci.yaml
File metadata and controls
258 lines (215 loc) · 7.51 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
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # hatch-vcs derives the version from tags
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
run: uv python install 3.10
- name: Install dependencies
run: uv sync --dev
- name: Run ruff check
run: uv run ruff check src/srtctl/
- name: Run ruff format check
run: uv run ruff format --check src/srtctl/
- name: Check generated docs (schema reference, JSON Schemas, CLI reference) are regenerated
run: uv run srtctl schema-docs --check
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- run: pip install mkdocs-material
- name: Build the docs site (strict, fails on broken links and unlisted pages)
run: mkdocs build --strict
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # hatch-vcs derives the version from tags
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
run: uv python install 3.10
- name: Install dependencies
run: uv sync --dev
- name: Run ty
run: uv run ty check src/srtctl/
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # hatch-vcs derives the version from tags
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
run: uv python install 3.10
- name: Install dependencies
run: uv sync --dev
- name: Run tests
run: uv run pytest tests/ -v --tb=short
- name: Run tests with coverage
run: uv run pytest tests/ --cov=srtctl --cov-report=xml --cov-report=term-missing
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: coverage.xml
fail_ci_if_error: false
continue-on-error: true
# Exercise the new mock + status-server surfaces end-to-end. These are
# covered by `pytest tests/` via the main `test` job, but we call them
# out here so a failure of the mock harness or the status-contract
# integration shows up as its own CI signal, and we run the full
# `srtctl apply --mock` CLI as a real subprocess to catch packaging or
# entry-point regressions that in-process tests can't.
mock-and-server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # hatch-vcs derives the version from tags
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
run: uv python install 3.10
- name: Install dependencies
run: uv sync --dev
- name: Run mock + status-server tests
run: |
uv run pytest -v \
tests/test_apply_json.py \
tests/test_apply_mock.py \
tests/test_mock_sweep.py \
tests/test_integration_status.py
- name: Smoke — srtctl apply --mock --json as a real CLI
run: |
set -euo pipefail
cat > /tmp/smoke.yaml <<'EOF'
schema: 2
name: ci-smoke
model:
path: hf:fake/mock-model
container: nvcr.io/fake:latest
precision: fp8
resources:
gpu_type: h100
gpus_per_node: 8
engine: sglang
roles:
agg:
nodes: 1
workers: 1
benchmark:
type: custom
command: echo ci-smoke
EOF
mkdir -p /tmp/ci-outputs
uv run srtctl apply \
-f /tmp/smoke.yaml \
-o /tmp/ci-outputs \
--mock \
--mock-tick-s 0.1 \
--json \
> /tmp/submission.json
cat /tmp/submission.json
uv run python - <<'PY'
import json, pathlib, time
sub = json.loads(pathlib.Path("/tmp/submission.json").read_text().strip())
assert sub["status"] == "submitted", sub
output_dir = pathlib.Path(sub["output_dir"])
result_path = output_dir / "result.json"
# The detached mock worker keeps ticking in the background after
# apply returns. Give it a generous window to land result.json.
deadline = time.monotonic() + 45
while time.monotonic() < deadline:
if result_path.exists():
break
time.sleep(0.25)
assert result_path.exists(), (
f"mock worker did not finish within window. output_dir contents: "
f"{sorted(p.name for p in output_dir.iterdir()) if output_dir.exists() else 'MISSING'}"
)
result = json.loads(result_path.read_text())
assert result["status"] == "completed", result
assert result["exit_code"] == 0, result
assert (output_dir / "status.json").exists()
assert (output_dir / "status_events.jsonl").exists()
assert (output_dir / "recipe.lock.yaml").exists()
print("CLI smoke passed:", {k: result.get(k) for k in ("job_id", "status", "score")})
PY
- name: Smoke — python -m srtctl.cli.mock_worker standalone
run: |
set -euo pipefail
mkdir -p /tmp/worker-out/54321
uv run python -m srtctl.cli.mock_worker \
--config /tmp/smoke.yaml \
--output-dir /tmp/worker-out/54321 \
--job-id 54321 \
--tick-s 0.1
test -f /tmp/worker-out/54321/result.json
uv run python -c "
import json
r = json.loads(open('/tmp/worker-out/54321/result.json').read())
assert r['status'] == 'completed' and r['exit_code'] == 0, r
print('worker standalone:', r)
"
# Quick sanity check that curated examples are valid
validate-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # hatch-vcs derives the version from tags
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
run: uv python install 3.10
- name: Install dependencies
run: uv sync --dev
- name: Validate every example (sweep and override files are expanded)
run: |
uv run python -c "
from pathlib import Path
from srtctl.core.config import validate_config_file
examples = sorted(Path('examples').rglob('*.yaml'))
print(f'Found {len(examples)} examples')
if not examples:
print('No examples found')
exit(1)
all_errors = []
for example in examples:
errors = validate_config_file(example)
if errors:
for e in errors:
print(f'✗ {e}')
all_errors.extend(errors)
else:
print(f'✓ {example.name}')
if all_errors:
print(f'\n{len(all_errors)} validation error(s)')
exit(1)
print(f'\nAll {len(examples)} examples valid')
"