Files
Heimdall/scripts/ci/test-plan.py
T
arnaud.dartois d12e16c6e5
Heimdall Gitea / Detect CI scope (push) Successful in 17s
Heimdall Gitea / Build and tests (push) Successful in 25m35s
Heimdall Gitea / Publish versioned release (push) Skipped
Heimdall Gitea / Build and scan server image (push) Successful in 15m3s
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Successful in 27m31s
Heimdall Gitea / Build and scan agent image (push) Successful in 16m55s
Heimdall Gitea / Publish Docker Hub latest tags (push) Successful in 39s
Heimdall Gitea / CI policy (push) Successful in 1s
docs: migrate work tracking to Gitea issues (#170)
Refs #169

## Changements

- Remplace `todo.md` par les issues Gitea comme source de suivi; crée un skill dédié au format de ticket, aux labels, aux maquettes, à la liaison PR et à la clôture.
- Met à jour les skills et guides qui pointaient vers le backlog supprimé.
- Ajuste le plan CI et ajoute un test ciblé pour s’assurer que la suppression de `todo.md` ne devient pas un changement documentaire ignoré.

## Vérifications

- `python3 scripts/ci/test_ci.py TestPlanTests` — 4 tests réussis.
- `git diff --check` — réussi.
- Aucun test .NET exécuté; le plan CI déclenche les suites pertinentes sur cette PR.

La tentative de créer la taxonomie de labels dans Gitea a expiré côté API; le skill documente les règles, mais les labels doivent encore être créés et appliqués lorsque l’écriture API sera disponible.

Reviewed-on: #170
Co-authored-by: Arnaud Dartois <admin@tordais.cc>
2026-11-06 14:11:28 +01:00

84 lines
3.1 KiB
Python

#!/usr/bin/env python3
"""Choose affected test projects for a PR; test everything on main and tags."""
import json
import os
from pathlib import Path
import subprocess
import xml.etree.ElementTree as ET
ROOT = Path(__file__).resolve().parents[2]
TESTS = sorted(path for path in (ROOT / "tests").glob("*/*.csproj") if path.stem != "Heimdall.TestCommon")
def references(project: Path) -> set[Path]:
tree = ET.parse(project)
return {
(project.parent / item.attrib["Include"].replace("\\", "/")).resolve()
for item in tree.iter("ProjectReference")
}
def changed_files() -> list[str] | None:
if os.environ.get("GITEA_EVENT_NAME") != "pull_request":
return None
result = subprocess.run(
["git", "diff", "--name-only", "origin/main...HEAD"],
cwd=ROOT, text=True, capture_output=True, check=False,
)
return result.stdout.splitlines() if result.returncode == 0 else None
def plan(changed: list[str] | None) -> dict[str, object]:
if changed is None:
return {"mode": "all", "changed": [], "suites": [p.stem for p in TESTS]}
all_paths = {p.resolve() for p in (ROOT / "src").glob("*/*.csproj")} | {
p.resolve() for p in (ROOT / "tests").glob("*/*.csproj")
}
graph = {project: references(project) for project in all_paths}
changed_projects: set[Path] = set()
broad = False
for name in changed:
parts = Path(name).parts
if parts and parts[0] in {"src", "tests"} and len(parts) >= 3:
if name.endswith(".csproj"):
broad = True
matches = list((ROOT / parts[0] / parts[1]).glob("*.csproj"))
changed_projects.update(p.resolve() for p in matches)
elif parts and parts[0] in {"src", "tests"}:
broad = True
elif name.startswith(("scripts/ci/", "docker/", "models/")) or name in {
"Heimdall.slnx", "global.json", "Directory.Build.props",
"Directory.Build.targets", "GitVersion.yml", "GitVersion.yaml",
}:
broad = True
if not broad and changed and not changed_projects and all(
name.startswith(("docs/", "skills/"))
or name in {"readme.md", "AGENTS.md", ".gitea/PULL_REQUEST_TEMPLATE.md"}
for name in changed
):
return {"mode": "affected", "changed": changed, "suites": []}
if broad or (changed and not changed_projects):
return {"mode": "all", "changed": changed, "suites": [p.stem for p in TESTS]}
affected = set(changed_projects)
while True:
additions = {project for project, refs in graph.items() if refs & affected}
if additions <= affected:
break
affected |= additions
suites = [p.stem for p in TESTS if p.resolve() in affected]
return {"mode": "affected", "changed": changed, "suites": suites}
if __name__ == "__main__":
result = plan(changed_files())
output = ROOT / "artifacts" / "tests" / "plan.json"
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(json.dumps(result, indent=2) + "\n")
print(f"Test plan: {result['mode']} — {', '.join(result['suites']) or 'no .NET suite'}")