-
Notifications
You must be signed in to change notification settings - Fork 20
291 lines (235 loc) · 9.49 KB
/
Copy pathci.yml
File metadata and controls
291 lines (235 loc) · 9.49 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Restrict permissions to minimum required (least privilege)
permissions:
contents: read
env:
PYTHON_VERSION: "3.11"
UV_VERSION: "0.5.0"
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v4
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras
- name: Run unit tests
run: uv run pytest tests/ -m unit -v --tb=short
- name: Run integration tests
run: uv run pytest tests/ -m integration -v --tb=short
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v4
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras
# Ruff linting - catches unused imports, variables, and common issues
- name: Run ruff linter
run: uv run ruff check . --output-format=github
- name: Run ruff formatter check
run: uv run ruff format --check --diff .
continue-on-error: true # Don't fail CI on formatting yet
- name: Check Python syntax
run: |
uv run python -m py_compile packages/darnit/src/darnit/__init__.py
uv run python -m py_compile packages/darnit-baseline/src/darnit_baseline/__init__.py
- name: Verify imports work
run: |
uv run python -c "from darnit.core.discovery import discover_implementations; print(discover_implementations())"
uv run python -c "from darnit_baseline import register; print(register())"
type-check:
name: Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v4
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras
- name: Install mypy
run: uv pip install mypy
- name: Run mypy on core modules
run: |
uv run mypy packages/darnit/src/darnit/core/models.py --ignore-missing-imports || true
uv run mypy packages/darnit/src/darnit/core/plugin.py --ignore-missing-imports || true
continue-on-error: true # Don't fail CI on type errors yet
# Critical: Check for parameter name mismatches in tool wrappers
# This catches bugs like passing 'repo_path' when function expects 'local_path'
- name: Check tools.py for call-arg errors
run: |
uv run mypy packages/darnit-baseline/src/darnit_baseline/tools.py \
--ignore-missing-imports \
--no-error-summary \
--show-error-codes 2>&1 | grep -E "call-arg|arg-type" && exit 1 || exit 0
coverage:
name: Coverage
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v4
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras
- name: Install coverage
run: uv pip install pytest-cov
- name: Run tests with coverage
run: uv run pytest tests/ -m unit --cov=packages/darnit/src --cov=packages/darnit-baseline/src --cov-report=term-missing --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v4
with:
file: ./coverage.xml
fail_ci_if_error: false
continue-on-error: true
build:
name: Build
runs-on: ubuntu-latest
needs: [test, lint]
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v4
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Build packages
run: |
uv build --package darnit-core
uv build --package darnit-baseline
- name: Verify package contents
run: |
ls -la dist/
ls dist/*.whl dist/*.tar.gz
sync-check:
name: Spec-Implementation Sync
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v4
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras
- name: Validate spec-implementation sync
run: uv run python scripts/validate_sync.py --verbose
# T065: integration check for the third-party plugin packaging story.
# darnit-hello is the worked example referenced by docs/packaging-plugins.md;
# if this job ever fails, the documented packaging path is broken.
plugin_discovery_smoke:
name: Plugin discovery smoke (darnit-hello)
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v4
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install workspace (includes darnit-hello)
run: uv sync --all-extras
- name: darnit-hello is discoverable on the darnit.implementations entry point
run: |
uv run python <<'PY'
import sys
from importlib.metadata import entry_points
eps = list(entry_points(group="darnit.implementations"))
names = sorted(ep.name for ep in eps)
print(f"Discovered implementations: {names}")
assert "hello" in names, (
"darnit-hello is not discoverable — the third-party plugin "
"packaging guide (docs/packaging-plugins.md) is broken. "
f"Found: {names}"
)
PY
- name: HelloImplementation satisfies the ComplianceImplementation protocol
run: |
uv run python <<'PY'
from darnit.core.plugin import ComplianceImplementation
from darnit_hello import register, get_framework_path
impl = register()
assert isinstance(impl, ComplianceImplementation), (
"HelloImplementation does not satisfy the ComplianceImplementation "
"protocol — the packaging guide's protocol example is wrong."
)
assert impl.name == "hello", f"impl.name = {impl.name!r}, expected 'hello'"
assert impl.version == "0.1.0"
assert impl.get_framework_config_path() == get_framework_path()
assert impl.get_framework_config_path().exists(), (
f"TOML config not found at {impl.get_framework_config_path()}"
)
print(f"✓ {impl.display_name} {impl.version} — protocol-conforming")
PY
- name: TOML config defines exactly the documented controls
run: |
uv run python <<'PY'
import tomllib
from darnit_hello import get_framework_path
with open(get_framework_path(), "rb") as f:
config = tomllib.load(f)
controls = list((config.get("controls") or {}).keys())
print(f"Defined controls: {controls}")
assert controls == ["HELLO-01.01"], (
f"darnit-hello drifted: expected exactly [HELLO-01.01], got {controls}. "
"Update the worked example AND docs/packaging-plugins.md together."
)
PY