ci: execute tagged module pytest suites
This commit is contained in:
@@ -60,24 +60,6 @@ retry() {
|
||||
done
|
||||
}
|
||||
|
||||
run_discovered_tests() {
|
||||
local suite_dir="$1"
|
||||
local status
|
||||
if ! find "$suite_dir" -type f -name 'test*.py' -print -quit | grep -q .; then
|
||||
echo "No unittest test files found under $suite_dir; skipping."
|
||||
return 0
|
||||
fi
|
||||
set +e
|
||||
"$PYTHON" -m unittest discover -s "$suite_dir"
|
||||
status=$?
|
||||
set -e
|
||||
if [[ "$status" == 5 ]]; then
|
||||
echo "No unittest tests discovered under $suite_dir; skipping."
|
||||
return 0
|
||||
fi
|
||||
return "$status"
|
||||
}
|
||||
|
||||
install_cloned_webui_dependencies() {
|
||||
local webui_dir="$1"
|
||||
if [[ ! -f "$webui_dir/package.json" ]]; then
|
||||
@@ -253,9 +235,10 @@ run_step "Run core backend release tests"
|
||||
"$PYTHON" "$META_ROOT/tools/checks/check_dependency_boundaries.py"
|
||||
|
||||
run_step "Run cloned module backend tests"
|
||||
run_discovered_tests "$WORK_ROOT/govoplan-mail/tests"
|
||||
run_discovered_tests "$WORK_ROOT/govoplan-calendar/tests"
|
||||
run_discovered_tests "$WORK_ROOT/govoplan-campaign/tests"
|
||||
for repo in govoplan-mail govoplan-calendar govoplan-campaign; do
|
||||
"$PYTHON" "$META_ROOT/tools/checks/release_integration.py" module-tests \
|
||||
--module-root "$WORK_ROOT/$repo"
|
||||
done
|
||||
|
||||
run_step "Run core WebUI release tests and build"
|
||||
cd "$ROOT/webui"
|
||||
|
||||
@@ -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