The dependabot bump moved pyproject's ruff pin to 0.16.1, but nothing else followed it, so the repo asked for three different versions at once: - pyproject.toml said 0.16.1 (the bump) - uv.lock still resolved 0.15.20 (dependabot did not update it) - .github/workflows/ci.yml installed 0.15.14 by its own literal pin The lint job never reads pyproject, so CI kept linting with 0.15.14 and reported this PR green without 0.16.1 ever running. The ci.yml pin had already drifted from pyproject before this bump, under a comment saying to keep them identical. - ci.yml: pin 0.16.1 to match pyproject. - uv.lock: regenerated so the locked resolution agrees. - test_ruff_pins_match: assert ci.yml and pyproject stay equal, so the next bump that touches only one of them fails loudly instead of passing blind. - extend-exclude '*.md': 0.16 began formatting Python inside markdown fences, taking the formatter from 199 files to 295 and reflowing hand-aligned example code in docs/rfcs/002 and three website pages. Excluding docs keeps this a version bump rather than a silent documentation reflow, and restores the exact file scope the project has always formatted. Verified with 0.16.1 actually installed: ruff check and ruff format --check both clean over the same 199 files, full suite green (3669 passed).
63 lines
2.3 KiB
Python
63 lines
2.3 KiB
Python
import re
|
|
from pathlib import Path
|
|
|
|
from mempalace import __version__
|
|
from mempalace.mcp_server import handle_request
|
|
|
|
|
|
def _expected_version() -> str:
|
|
pyproject = Path(__file__).resolve().parents[1] / "pyproject.toml"
|
|
content = pyproject.read_text(encoding="utf-8")
|
|
match = re.search(r'^version\s*=\s*"([^"]+)"', content, re.MULTILINE)
|
|
assert match is not None, "Could not find project version in pyproject.toml"
|
|
return match.group(1)
|
|
|
|
|
|
def test_package_version_matches_pyproject():
|
|
assert __version__ == _expected_version()
|
|
|
|
|
|
def test_mcp_initialize_reports_package_version():
|
|
response = handle_request({"jsonrpc": "2.0", "id": 1, "method": "initialize"})
|
|
assert response["result"]["serverInfo"]["version"] == _expected_version()
|
|
|
|
|
|
def _repo_root() -> Path:
|
|
return Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def _pyproject_ruff_pins() -> list[str]:
|
|
content = (_repo_root() / "pyproject.toml").read_text(encoding="utf-8")
|
|
return re.findall(r'"ruff==([^"]+)"', content)
|
|
|
|
|
|
def _ci_ruff_pins() -> list[str]:
|
|
content = (_repo_root() / ".github" / "workflows" / "ci.yml").read_text(encoding="utf-8")
|
|
return re.findall(r'pip install "ruff==([^"]+)"', content)
|
|
|
|
|
|
def test_ruff_pins_match():
|
|
"""CI's ruff and pyproject's ruff must be the same version.
|
|
|
|
The lint job installs ruff by literal pin rather than from pyproject, so
|
|
the two can drift with nothing to notice: CI went on linting with 0.15.14
|
|
while pyproject asked for 0.15.20. A dependabot bump to pyproject then
|
|
passes CI green without the new version ever running — which matters,
|
|
because 0.16 started formatting Python inside markdown fences and would
|
|
have landed a lint config that disagreed with every contributor's local
|
|
`ruff format`.
|
|
"""
|
|
pyproject_pins = _pyproject_ruff_pins()
|
|
ci_pins = _ci_ruff_pins()
|
|
|
|
assert pyproject_pins, "no ruff pin found in pyproject.toml"
|
|
assert ci_pins, "no ruff pin found in .github/workflows/ci.yml"
|
|
assert len(set(pyproject_pins)) == 1, (
|
|
f"pyproject.toml pins ruff at more than one version: {sorted(set(pyproject_pins))}"
|
|
)
|
|
assert set(ci_pins) == set(pyproject_pins), (
|
|
f"ruff pin drift — ci.yml has {sorted(set(ci_pins))}, "
|
|
f"pyproject.toml has {sorted(set(pyproject_pins))}. "
|
|
"Bump both together so CI and local runs format identically."
|
|
)
|