Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions scripts/run_coverage_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ def _pytest_cwd(repo: Path) -> Path:


def _cov_source_args(cwd: Path) -> List[str]:
# tool-images tests exercise the registry API; its previous scripts-only
# target produced "No data to report" even with all tests passing.
if cwd.name == "omnibioai-tool-images" and (cwd / "api").is_dir():
return ["--cov=api"]

text = _read_text(cwd / "pyproject.toml")
if text:
m = re.search(r'\[tool\.coverage\.run\](.*?)(?=\n\[|\Z)', text, re.DOTALL)
Expand Down Expand Up @@ -465,13 +470,33 @@ def run_npm_repo(repo: Path, timeout_override: int | None = None) -> Dict[str, A
"branches": None, "partial_branches": None, "coverage_pct": None,
"total_line": None, "stdout_tail": None, "stderr_tail": None,
"status": "ok",
"install_status": "not_attempted",
"install_returncode": None,
"install_stderr_tail": None,
}
script_name = _npm_coverage_script(repo)
result.update(_empty_test_details("npm"))
if script_name is None:
result["status"] = "no_coverage_script"
return result
timeout = timeout_override or REPO_TIMEOUTS.get(repo.name, DEFAULT_TIMEOUT)
package_lock = repo / "package-lock.json"
if package_lock.exists() and not (repo / "node_modules").is_dir():
print(" npm ci --ignore-scripts …", end=" ", flush=True)
try:
install = subprocess.run(
["npm", "ci", "--ignore-scripts", "--no-audit", "--no-fund"],
cwd=str(repo), env=_subprocess_env(repo),
capture_output=True, text=True, timeout=min(timeout, 900),
)
result["install_returncode"] = install.returncode
result["install_status"] = "ok" if install.returncode == 0 else "failed"
result["install_stderr_tail"] = "\n".join(install.stderr.strip().splitlines()[-10:]) or None
print("ok" if install.returncode == 0 else f"WARN rc={install.returncode}")
except subprocess.TimeoutExpired as exc:
result["install_status"] = "timeout"
result["install_stderr_tail"] = str(exc)
print("timeout")
print(f" npm run {script_name} (timeout={timeout}s) …", end=" ", flush=True)
try:
proc = subprocess.run(
Expand Down Expand Up @@ -606,7 +631,17 @@ def run_repo(repo: Path, timeout_override: int | None = None) -> Dict[str, Any]:
result["total_line"] = "json"
result.update(cov_data)
else:
result["status"] = "no_total_found"
# Some test-only repositories (for example dev-docker) have a
# passing pytest suite but no importable application package for
# coverage to measure. Preserve that distinction in the ecosystem
# report instead of marking a green test run as a failure.
if (proc.returncode == 0
and (result.get("tests_failed") or 0) == 0
and (result.get("test_errors") or 0) == 0):
result["status"] = "ok_no_coverage"
result["coverage_basis"] = "tests_passed_no_measurable_source"
else:
result["status"] = "no_total_found"

if proc.returncode != 0 and result["status"] == "ok":
result["status"] = "test_failure"
Expand Down Expand Up @@ -774,7 +809,7 @@ def main() -> int:
print(f" → {status}{suffix} → {out_f.name}")
print()

if status == "ok":
if status == "ok" or status.startswith("ok_"):
ok += 1
elif status.startswith("skipped") or status == "missing_path":
skip += 1
Expand Down
13 changes: 8 additions & 5 deletions scripts/sections/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def _stderr_tail(stderr: str, n: int = 10) -> Optional[str]:
return "\n".join(stderr.splitlines()[-n:]) if stderr else None

def _classify_status(rc, total_line, coverage_pct, fail_under, stdout, stderr) -> str:
if total_line is None: return "no_total_found"
if total_line is None:
return "ok_no_coverage" if rc == 0 else "no_total_found"
if rc == 0: return "ok"
combined = f"{stdout}\n{stderr}".lower()
cov_fail = ("required test coverage" in combined or "fail-under" in combined
Expand Down Expand Up @@ -297,6 +298,7 @@ def _safe_int(value):
"collectionErrors": _safe_int(row.get("collection_errors")),
"fileTypes": row.get("test_file_types") or {},
"basis": row.get("test_detail_basis"),
"coverageBasis": row.get("coverage_basis"),
"installStatus": row.get("install_status"),
"color": _cov_color(pct if pct == pct else None),
"bg": _cov_bg(pct if pct == pct else None),
Expand Down Expand Up @@ -447,14 +449,15 @@ def _safe_int(value):
'<div style="height:4px;background:#2a2d3e;border-radius:2px;margin-top:3px;overflow:hidden">'+
'<div style="height:100%;width:'+r.pct.toFixed(1)+'%;background:'+r.color+';border-radius:2px"></div></div>'
:'<span style="color:#6b7280;font-size:12px">—</span>';
var stBg=r.status==='ok'?'#EAF3DE':r.status.includes('skip')||r.status.includes('missing')?'#F1EFE8':'#FAEEDA';
var stCol=r.status==='ok'?'#3B6D11':r.status.includes('skip')||r.status.includes('missing')?'#444441':'#854F0B';
var stLbl=r.status==='ok'?'ok':r.status.includes('skip')?'skipped':r.status.includes('miss')?'missing':r.status.startsWith('error')?'error':'partial';
var stBg=r.status.startsWith('ok')?'#EAF3DE':r.status.includes('skip')||r.status.includes('missing')?'#F1EFE8':'#FAEEDA';
var stCol=r.status.startsWith('ok')?'#3B6D11':r.status.includes('skip')||r.status.includes('missing')?'#444441':'#854F0B';
var stLbl=r.status.startsWith('ok')?'ok':r.status.includes('skip')?'skipped':r.status.includes('miss')?'missing':r.status.startsWith('error')?'error':'partial';
var types=(r.framework?r.framework+' · ':'')+Object.keys(r.fileTypes||{{}}).map(function(k){{return k+': '+r.fileTypes[k];}}).join(', ');
if(r.installStatus==='failed')types+=(types?' · ':'')+'install failed';
if(r.coverageBasis)types+=(types?' · ':'')+'no coverage data';
var tr=document.createElement('tr');
var short=r.repo.replace('omnibioai-','').replace('omnibioai_','').replace('omnibioai','omnibioai');
tr.title=(r.basis||'')+(r.installStatus==='failed'?' · editable install failed; tests ran in the existing environment':'');
tr.title=(r.basis||r.coverageBasis||'')+(r.installStatus==='failed'?' · editable install failed; tests ran in the existing environment':'');
tr.innerHTML='<td style="font-weight:600;font-size:12px">'+short+'</td>'+
'<td><span class="badge" style="background:'+stBg+';color:'+stCol+'">'+stLbl+'</span></td>'+
'<td class="r">'+(r.collected!==null?r.collected.toLocaleString():'—')+'</td>'+
Expand Down
Loading