ci: execute tagged module pytest suites
This commit is contained in:
@@ -5,6 +5,7 @@ import argparse
|
||||
import importlib.metadata as metadata
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
@@ -354,6 +355,24 @@ def run_core_release_tests(core_root: Path) -> int:
|
||||
return 0 if result.wasSuccessful() else 1
|
||||
|
||||
|
||||
def run_module_release_tests(module_root: Path) -> int:
|
||||
resolved_root = module_root.resolve()
|
||||
tests_root = resolved_root / "tests"
|
||||
if not tests_root.is_dir() or not any(tests_root.rglob("test*.py")):
|
||||
print(f"No test files found under {tests_root}; skipping.")
|
||||
return 0
|
||||
|
||||
result = subprocess.run(
|
||||
(sys.executable, "-m", "pytest", "-q", "tests"),
|
||||
cwd=resolved_root,
|
||||
check=False,
|
||||
)
|
||||
if result.returncode == 5:
|
||||
print(f"No tests collected under {tests_root}; skipping.")
|
||||
return 0
|
||||
return result.returncode
|
||||
|
||||
|
||||
def _parser() -> argparse.ArgumentParser:
|
||||
meta_root = Path(__file__).resolve().parents[2]
|
||||
parser = argparse.ArgumentParser(description="Artifact-aware GovOPlaN release integration checks")
|
||||
@@ -366,6 +385,8 @@ def _parser() -> argparse.ArgumentParser:
|
||||
)
|
||||
core_parser = subparsers.add_parser("core-tests", help="Run Core tests that are valid for tagged module artifacts")
|
||||
core_parser.add_argument("--core-root", type=Path, required=True)
|
||||
module_parser = subparsers.add_parser("module-tests", help="Run tests from one tagged module source checkout")
|
||||
module_parser.add_argument("--module-root", type=Path, required=True)
|
||||
return parser
|
||||
|
||||
|
||||
@@ -373,7 +394,9 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
args = _parser().parse_args(argv)
|
||||
if args.command == "artifacts":
|
||||
return run_installed_artifact_checks(args.requirements)
|
||||
return run_core_release_tests(args.core_root)
|
||||
if args.command == "core-tests":
|
||||
return run_core_release_tests(args.core_root)
|
||||
return run_module_release_tests(args.module_root)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user