Repository navigation
195 lines (181 loc) · 8.79 KB
/
Copy pathtest.yml
File metadata and controls
195 lines (181 loc) · 8.79 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
name: tests
# The suite is ~485 offline cases with no network and no paid LLM calls, so it can
# run on every push. Until this existed it ran only when someone remembered to type
# `pytest` (doc/architecture/CODE_TOUR.md documents it as a manual step) — tests that nothing runs
# protect nothing.
#
# NOTE: this workflow is a SIGNAL, not a merge gate. Making it blocking needs a branch
# protection rule / ruleset naming the `suite` job as a required status check, which is
# a repository setting and cannot be done from a commit.
on:
push:
pull_request:
merge_group:
workflow_dispatch:
permissions:
contents: read
jobs:
suite:
runs-on: ubuntu-latest
steps:
# Full history, not the default depth-1 shallow clone. check_spec_freshness
# dates each source file with `git log -1 -- <path>`, and in a shallow clone
# the single commit has no parent, so git reports EVERY tracked file as
# created in it. All 62 SPEC pages then read as modified today and the
# strict check fails wholesale. It only ever passed because the tip commit
# happened to predate the pages' verified-against: dates; the first commit
# made on a later day broke all 62 at once.
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
# pytest lives in the `dev` extra; `mcp` is needed for the MCP server tests;
# `kb` (cryptography) for the knowledge service's signing.
- name: Install
run: pip install -e ".[dev,mcp,kb]"
- name: Unit tests
run: python -m pytest -q
- name: CLI smoke
run: infermatrix-copilot --help
# doctor exits 1 when credentials are absent, which is the expected state in CI.
# The claim under test is "it runs and emits valid JSON", not "it is configured",
# so tolerate 0/1 explicitly rather than piping into a parser — steps run under
# `pipefail`, where the expected exit 1 would fail the step.
- name: doctor emits valid JSON
run: |
infermatrix-copilot doctor --json > doctor.json || [ $? -le 1 ]
python -c "import json; json.load(open('doctor.json'))"
# test_packaged_runtime.py asserts on pyproject's TEXT, so nothing else proves the
# force-include data trees actually ship. Build the artifact and import it from a
# clean venv, where a missing tree cannot be masked by the source checkout.
- name: Wheel ships its runtime data
run: |
pip install build
python -m build --wheel
python -m venv /tmp/clean
/tmp/clean/bin/pip install --quiet dist/*.whl
cd /tmp # import the INSTALLED package, never the source checkout
/tmp/clean/bin/python - <<'PY'
import importlib.metadata
import importlib.resources
import sys
import tempfile
from pathlib import Path
from infermatrix_copilot import __version__
from infermatrix_copilot.sdk.v1 import (
ChangedPath, DirectClient, DirectReviewRequest,
KNOWLEDGE_API_VERSION,
KnowledgeCurator, KnowledgeEvidenceBatch,
KnowledgeEvidenceEvent, RepositoryRef, StrictRuntime,
get_capabilities,
)
forbidden = {
"infermatrix_copilot.config",
"infermatrix_copilot.contract",
"infermatrix_copilot.direct_routing",
"infermatrix_copilot.mcp_server",
}
loaded = sorted(forbidden.intersection(sys.modules))
if loaded:
sys.exit(f"public SDK import loaded private implementation: {loaded}")
caps = get_capabilities()
if "vllm-gr" not in caps.supported_repositories:
sys.exit("installed SDK omits vLLM-GR review support")
dist_version = importlib.metadata.version("infermatrix-copilot")
if not (__version__ == dist_version == caps.distribution_version == "0.2.0"):
sys.exit(
"version mismatch: "
f"module={__version__}, metadata={dist_version}, "
f"capabilities={caps.distribution_version}"
)
if not caps.resource_revision.startswith("sha256:"):
sys.exit("SDK capabilities have no resource revision")
if not caps.supports_knowledge_curation:
sys.exit("SDK capabilities omit knowledge curation")
if not (
caps.knowledge_api_version == KNOWLEDGE_API_VERSION == "1.1.0"
):
sys.exit("installed SDK knowledge API version mismatch")
if KnowledgeCurator.proposal_schema(max_rules=3)["properties"][
"rules"
]["maxItems"] != 3:
sys.exit("installed SDK has a broken knowledge proposal schema")
evidence = KnowledgeEvidenceBatch(
batch_id="wheel-smoke",
repository=RepositoryRef(alias="vllm-omni"),
events=(KnowledgeEvidenceEvent(
event_id="event-1", source_kind="merged_pr",
source_reference="PR #1", title="wheel smoke",
),),
)
if evidence.to_dict()["events"][0]["event_id"] != "event-1":
sys.exit("installed SDK knowledge models are not serializable")
if not importlib.resources.files("infermatrix_copilot").joinpath(
"py.typed"
).is_file():
sys.exit("wheel does not ship py.typed")
from infermatrix_copilot.config import _resource_dir, _RESOURCE_MARKERS
# resolve through the production probe and require its marker to exist:
# a present-but-empty directory would satisfy a bare is_dir() check
bad = []
for name, marker in _RESOURCE_MARKERS.items():
d = _resource_dir(name)
if not d.is_dir():
bad.append(f"{name}: {d} missing")
elif not any(m.is_file() for m in d.glob(marker)):
bad.append(f"{name}: {d} has no {marker}")
if bad:
sys.exit("wheel runtime data broken: " + "; ".join(bad))
client = DirectClient()
for repo, changed in (
("vllm-omni", "vllm_omni/core/sched/scheduler.py"),
("afd-plugin", "afd_plugin/compat/vllm.py"),
):
plan = client.plan(DirectReviewRequest(
review_id="wheel-smoke",
repository=RepositoryRef(alias=repo),
pr_number=1,
expected_head_sha="a" * 40,
title="runtime change",
body="exercise the installed SDK",
changed_paths=(ChangedPath(changed),),
))
if not plan.knowledge_routes:
sys.exit(f"installed SDK did not route {repo}")
if any("/" == ref.document.document_id[:1]
for ref in plan.knowledge_routes):
sys.exit("installed SDK leaked an absolute document path")
if Path(plan.navigation_policy["fallback_document_id"]).is_absolute():
sys.exit("installed SDK leaked an absolute fallback path")
with tempfile.TemporaryDirectory() as run_root:
with StrictRuntime(settings_overrides={
"_env_file": None, "run_root": run_root,
}) as strict:
if strict.capabilities().distribution_version != "0.2.0":
sys.exit("Strict facade capabilities mismatch")
print("packaged runtime data resolves via _resource_dir:",
", ".join(_RESOURCE_MARKERS))
PY
# Doc integrity. These exist because the doc/ refactor measured the damage
# they prevent: 29 in-code citations of doc/ paths that no linter checked,
# and 44 of 45 SPEC pages silently behind their own source.
- name: Doc linters
run: |
python tools/check_doc_links.py
python tools/check_doc_citations.py
# BLOCKING as of the P5 rewrite: all 92 modules have a SPEC page and all
# 62 pages carry a `verified-against:` date. --strict additionally fails
# on a page whose source changed after that date, or one that dropped its
# marker — which is the whole point: 44 of 45 pages had silently fallen
# behind before this check existed.
- name: SPEC coverage and freshness
run: python tools/check_spec_freshness.py --strict
# Written, tested, and until now invoked only from prose (AGENTS.md, DEVELOPMENT.md).
- name: Knowledge linters
run: |
python knowledge/tools/check_knowledge_tree.py
python knowledge/tools/check_wiki_lint.py
python -m pytest -q knowledge/tools/test_check_knowledge_tree.py \
knowledge/tools/test_check_review_report.py