mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-29 04:48:54 -06:00
feat: run the CI suite as parallel processes
validate.yml and pr_checks.py run scripts/run_tests.py with four jobs, the runner's cores: 24 minutes here for the suite that took about 40 in one process. A failed module's tracebacks are printed in the summary, as a runner keeps no log file. The two scripts added today follow the rules the suite holds every script to (no abbreviated option, run_cli, every option documented), and the two isolation tests drop the per-module scratch variable to check the folder a module gets alone.
This commit is contained in:
1 parent
fb33ee58e1
commit
abbfebff3e
11 files changed
+63
-27
No files matched your search
@@ -241,11 +241,14 @@ class AModuleRunAloneHasItsScratchDirectory(unittest.TestCase):
|
||||
(clone / "tests" / "__init__.py").write_bytes(
|
||||
(ROOT / "tests" / "__init__.py").read_bytes()
|
||||
)
|
||||
# The folder a module gets alone, not the one scripts/run_tests.py
|
||||
# names for each module it runs beside others.
|
||||
env = {k: v for k, v in os.environ.items() if k != "RETROBIOS_TEST_SCRATCH"}
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "-I", "-c",
|
||||
"import sys; sys.path.insert(0, '.'); import tests, tempfile, os;"
|
||||
" print(tempfile.gettempdir()); print(os.environ['TMPDIR'])"],
|
||||
cwd=clone, capture_output=True, text=True, timeout=60, check=False,
|
||||
cwd=clone, env=env, capture_output=True, text=True, timeout=60, check=False,
|
||||
)
|
||||
self.assertEqual(proc.returncode, 0, proc.stderr)
|
||||
self.assertTrue((clone / "tmp" / "tests").is_dir())
|
||||
@@ -278,7 +281,8 @@ class EveryTestModuleImportsTheIsolation(unittest.TestCase):
|
||||
|
||||
def test_discover_without_a_top_level_runs_isolated(self):
|
||||
env = {k: v for k, v in os.environ.items()
|
||||
if k not in ("RETROBIOS_OFFLINE", "TMPDIR", "RETROBIOS_CACHE")}
|
||||
if k not in ("RETROBIOS_OFFLINE", "TMPDIR", "RETROBIOS_CACHE",
|
||||
"RETROBIOS_TEST_SCRATCH")}
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "-c",
|
||||
"import os, sys, tempfile, unittest\n"
|
||||
@@ -402,7 +406,7 @@ class WorkflowRegressions(unittest.TestCase):
|
||||
name
|
||||
for name, body in workflow["jobs"].items()
|
||||
if any(
|
||||
"unittest discover" in str(step.get("run", ""))
|
||||
"scripts/run_tests.py" in str(step.get("run", ""))
|
||||
for step in body.get("steps", [])
|
||||
)
|
||||
),
|
||||
@@ -4794,7 +4798,7 @@ class TheTestJobHasTheDataTrees(unittest.TestCase):
|
||||
)["jobs"]["run-tests"]["steps"]
|
||||
runs = [step.get("run", "") for step in steps]
|
||||
fetch = next(i for i, run in enumerate(runs) if "refresh_data_dirs.py" in run)
|
||||
suite = next(i for i, run in enumerate(runs) if "unittest discover" in run)
|
||||
suite = next(i for i, run in enumerate(runs) if "scripts/run_tests.py" in run)
|
||||
self.assertLess(fetch, suite)
|
||||
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class BeforeOpeningAPullRequest(unittest.TestCase):
|
||||
section = text.split("## Before opening a PR", 1)[1].split("\n## ", 1)[0]
|
||||
block = "".join(_re.findall(r"```bash\n(.*?)```", section, _re.S))
|
||||
for command in ("validate_pr.py --changed", "validate_schemas.py --source-only",
|
||||
"unittest discover"):
|
||||
"run_tests.py"):
|
||||
self.assertIn(command, block)
|
||||
self.assertNotIn("pipeline.py", block)
|
||||
workflow = (REPO_ROOT / ".github" / "workflows" / "validate.yml").read_text(encoding="utf-8")
|
||||
@@ -268,13 +268,13 @@ class OneCommandRunsTheChecks(unittest.TestCase):
|
||||
workflow = (REPO_ROOT / ".github" / "workflows" / "validate.yml").read_text(encoding="utf-8")
|
||||
order = [workflow.index(key) for key in (
|
||||
"refresh_data_dirs.py", "run: python scripts/generate_site.py",
|
||||
"npm run build --prefix website", "python -m unittest discover",
|
||||
"npm run build --prefix website", "python scripts/run_tests.py",
|
||||
"validate_site.py")]
|
||||
self.assertEqual(order, sorted(order))
|
||||
commands = [step.command for step in pr_checks.STEPS]
|
||||
positions = [next(i for i, c in enumerate(commands) if key in c) for key in (
|
||||
"refresh_data_dirs.py", "generate_site.py", "npm run build",
|
||||
"unittest discover", "validate_site.py")]
|
||||
"run_tests.py", "validate_site.py")]
|
||||
self.assertEqual(positions, sorted(positions))
|
||||
|
||||
def test_the_guide_gives_the_runner_and_what_it_runs(self):
|
||||
|
||||
@@ -397,14 +397,14 @@ class ContributorChecksMatchCi(unittest.TestCase):
|
||||
block = _section(text, "## Before opening a PR")
|
||||
self.assertIn("python scripts/refresh_data_dirs.py", block)
|
||||
self.assertLess(
|
||||
block.index("refresh_data_dirs.py"), block.index("unittest discover")
|
||||
block.index("refresh_data_dirs.py"), block.index("run_tests.py")
|
||||
)
|
||||
|
||||
def test_ci_does_the_same(self):
|
||||
workflow = _read(".github/workflows/validate.yml")
|
||||
self.assertLess(
|
||||
workflow.index("python scripts/refresh_data_dirs.py"),
|
||||
workflow.index("python -m unittest discover"),
|
||||
workflow.index("python scripts/run_tests.py"),
|
||||
)
|
||||
|
||||
def test_the_pr_checklist_generates_the_site_before_the_tests(self):
|
||||
@@ -413,7 +413,7 @@ class ContributorChecksMatchCi(unittest.TestCase):
|
||||
workflow = _read(".github/workflows/validate.yml")
|
||||
self.assertLess(
|
||||
workflow.index("run: python scripts/generate_site.py"),
|
||||
workflow.index("python -m unittest discover"),
|
||||
workflow.index("python scripts/run_tests.py"),
|
||||
)
|
||||
for text in (
|
||||
contributing_text(lambda page: page, "# C", "here"),
|
||||
@@ -422,7 +422,7 @@ class ContributorChecksMatchCi(unittest.TestCase):
|
||||
block = _section(text, "## Before opening a PR")
|
||||
self.assertIn("python scripts/generate_site.py", block)
|
||||
self.assertLess(
|
||||
block.index("generate_site.py"), block.index("unittest discover")
|
||||
block.index("generate_site.py"), block.index("run_tests.py")
|
||||
)
|
||||
|
||||
|
||||
@@ -626,7 +626,7 @@ class ContributorChecksFetchThePlatformsFiles(unittest.TestCase):
|
||||
workflow = _read(".github/workflows/validate.yml")
|
||||
self.assertLess(
|
||||
workflow.index("python scripts/export_native.py --all --refresh-cache"),
|
||||
workflow.index("python -m unittest discover"),
|
||||
workflow.index("python scripts/run_tests.py"),
|
||||
)
|
||||
for text in (
|
||||
contributing_text(lambda page: page, "# C", "here"),
|
||||
@@ -635,7 +635,7 @@ class ContributorChecksFetchThePlatformsFiles(unittest.TestCase):
|
||||
block = _section(text, "## Before opening a PR")
|
||||
self.assertIn("python scripts/export_native.py --all --refresh-cache", block)
|
||||
self.assertLess(
|
||||
block.index("export_native.py"), block.index("unittest discover")
|
||||
block.index("export_native.py"), block.index("run_tests.py")
|
||||
)
|
||||
|
||||
def test_the_testing_guide_names_the_command(self):
|
||||
|
||||
@@ -147,7 +147,7 @@ class ThePullRequestBuildsTheSite(unittest.TestCase):
|
||||
generate = next(
|
||||
i for i, run in enumerate(runs) if "scripts/generate_site.py" in run
|
||||
)
|
||||
suite = next(i for i, run in enumerate(runs) if "unittest discover" in run)
|
||||
suite = next(i for i, run in enumerate(runs) if "scripts/run_tests.py" in run)
|
||||
self.assertLess(generate, suite)
|
||||
# The built pages too: about fifty tests read website/dist.
|
||||
build = next(i for i, run in enumerate(runs) if "npm run build" in run)
|
||||
|
||||
Reference in new issue
Block a user