refactor(infra): eliminate globals + split check_pyproject in project-status (#247)
* refactor(infra): introduce RepoCtx, eliminate globals in project-status * refactor(infra): split check_pyproject into 13 sub-functions * test(infra): add RepoCtx + 13 sub-function tests, migrate cookiecutter tests --------- Co-authored-by: opencode-agent <agent@opencode.local>
This commit is contained in:
parent
10df459cee
commit
93911f2af6
3 changed files with 764 additions and 549 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -461,16 +461,16 @@ def extra_context_value(render, key):
|
||||||
|
|
||||||
|
|
||||||
def _run_status_checks(repo_root: Path, fast: bool = True) -> tuple[str, list[ps.CheckResult]]:
|
def _run_status_checks(repo_root: Path, fast: bool = True) -> tuple[str, list[ps.CheckResult]]:
|
||||||
"""Run the project-status checks against ``repo_root`` (in-process)."""
|
"""Run the project-status checks against ``repo_root`` (in-process).
|
||||||
original_root = ps.REPO_ROOT
|
|
||||||
ps.REPO_ROOT = repo_root
|
Builds a ``RepoCtx`` rooted at ``repo_root`` so check-functions get an
|
||||||
try:
|
explicit context (no module-global mutation after the #242 refactor).
|
||||||
ptype = ps.detect_project_type()
|
"""
|
||||||
groups = ps.run_all_checks(ptype, fast=fast)
|
ctx = ps.RepoCtx(root=repo_root, config=ps.load_config(repo_root))
|
||||||
all_checks = [c for g in groups for c in g.checks]
|
ptype = ps.detect_project_type(ctx)
|
||||||
report = ps.format_output(ptype, groups)
|
groups = ps.run_all_checks(ptype, ctx, fast=fast)
|
||||||
finally:
|
all_checks = [c for g in groups for c in g.checks]
|
||||||
ps.REPO_ROOT = original_root
|
report = ps.format_output(ptype, groups)
|
||||||
return report, all_checks
|
return report, all_checks
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -553,12 +553,8 @@ def test_infra_checks_present(render):
|
||||||
def test_fullstack_passes_project_status_structure(render):
|
def test_fullstack_passes_project_status_structure(render):
|
||||||
"""Fullstack is detected as fullstack (backend/ + frontend/ present)."""
|
"""Fullstack is detected as fullstack (backend/ + frontend/ present)."""
|
||||||
ptype = ps.ProjectType.FULLSTACK
|
ptype = ps.ProjectType.FULLSTACK
|
||||||
original_root = ps.REPO_ROOT
|
ctx = ps.RepoCtx(root=render, config=ps.load_config(render))
|
||||||
ps.REPO_ROOT = render
|
detected = ps.detect_project_type(ctx)
|
||||||
try:
|
|
||||||
detected = ps.detect_project_type()
|
|
||||||
finally:
|
|
||||||
ps.REPO_ROOT = original_root
|
|
||||||
assert detected == ptype
|
assert detected == ptype
|
||||||
_, checks = _run_status_checks(render)
|
_, checks = _run_status_checks(render)
|
||||||
by_name = {c.name: c for c in checks}
|
by_name = {c.name: c for c in checks}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue