diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_ci_main_signal.py | 21 | ||||
| -rw-r--r-- | tests/test_runtime_paths.py | 31 |
2 files changed, 32 insertions, 20 deletions
diff --git a/tests/test_ci_main_signal.py b/tests/test_ci_main_signal.py index 4cc2fd4a6..53759ebaa 100644 --- a/tests/test_ci_main_signal.py +++ b/tests/test_ci_main_signal.py | |||
| @@ -5,7 +5,8 @@ import unittest | |||
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | ROOT = Path(__file__).resolve().parents[1] | 7 | ROOT = Path(__file__).resolve().parents[1] |
| 8 | WORKFLOWS = {"ci": "23 3 * * *", "runtime": "53 3 * * *"} | 8 | WORKFLOWS = {"ci": "23 3 * * *"} |
| 9 | DEPRECATED_RUNTIME_WORKFLOWS = ("runtime", "xma2-decoder") | ||
| 9 | SUFFIX = ( | 10 | SUFFIX = ( |
| 10 | "${{ github.event_name }}-${{ github.event.pull_request.number || " | 11 | "${{ github.event_name }}-${{ github.event.pull_request.number || " |
| 11 | "(github.event_name == 'push' && github.ref) || github.run_id }}" | 12 | "(github.event_name == 'push' && github.ref) || github.run_id }}" |
| @@ -23,14 +24,13 @@ def group(name, event, run_id, *, ref="refs/heads/main", pr=None): | |||
| 23 | 24 | ||
| 24 | 25 | ||
| 25 | class MainSignal(unittest.TestCase): | 26 | class MainSignal(unittest.TestCase): |
| 26 | def test_one_staggered_daily_schedule_per_workflow(self): | 27 | def test_one_daily_schedule_per_active_workflow(self): |
| 27 | for name, cron in WORKFLOWS.items(): | 28 | for name, cron in WORKFLOWS.items(): |
| 28 | with self.subTest(workflow=name): | 29 | with self.subTest(workflow=name): |
| 29 | text = workflow(name) | 30 | text = workflow(name) |
| 30 | self.assertEqual(re.findall(r'^ - cron: "([^"]+)"$', text, re.M), [cron]) | 31 | self.assertEqual(re.findall(r'^ - cron: "([^"]+)"$', text, re.M), [cron]) |
| 31 | self.assertIn(" schedule:\n", text) | 32 | self.assertIn(" schedule:\n", text) |
| 32 | self.assertEqual(cron.split()[2:], ["*", "*", "*"]) | 33 | self.assertEqual(cron.split()[2:], ["*", "*", "*"]) |
| 33 | self.assertNotEqual(WORKFLOWS["ci"], WORKFLOWS["runtime"]) | ||
| 34 | 34 | ||
| 35 | def test_push_pr_and_manual_triggers_remain(self): | 35 | def test_push_pr_and_manual_triggers_remain(self): |
| 36 | for name in WORKFLOWS: | 36 | for name in WORKFLOWS: |
| @@ -58,15 +58,24 @@ class MainSignal(unittest.TestCase): | |||
| 58 | self.assertNotEqual(group(name, "schedule", 1), group(name, "push", 1)) | 58 | self.assertNotEqual(group(name, "schedule", 1), group(name, "push", 1)) |
| 59 | self.assertNotEqual(group(name, "schedule", 1), group(name, "schedule", 2)) | 59 | self.assertNotEqual(group(name, "schedule", 1), group(name, "schedule", 2)) |
| 60 | self.assertNotEqual(group(name, "workflow_dispatch", 1), group(name, "schedule", 1)) | 60 | self.assertNotEqual(group(name, "workflow_dispatch", 1), group(name, "schedule", 1)) |
| 61 | self.assertNotEqual(group("ci", "schedule", 1), group("runtime", "schedule", 1)) | ||
| 62 | 61 | ||
| 63 | def test_jobs_are_not_restricted_to_push_events(self): | 62 | def test_jobs_are_not_restricted_to_push_events(self): |
| 64 | for name in WORKFLOWS: | 63 | for name in WORKFLOWS: |
| 65 | jobs = workflow(name).split("\njobs:\n", 1)[1] | 64 | jobs = workflow(name).split("\njobs:\n", 1)[1] |
| 66 | self.assertNotRegex(jobs, r"(?m)^\s+if:.*github\.event_name\s*==\s*'push'") | 65 | self.assertNotRegex(jobs, r"(?m)^\s+if:.*github\.event_name\s*==\s*'push'") |
| 67 | # The Wine artifact consumer remains available to schedules, but still needs a real artifact. | 66 | |
| 67 | def test_legacy_runtime_workflows_are_manual_dispatch_only(self): | ||
| 68 | # Legacy C++ runtime/ is deprecated in favor of d3d12/ and the new Rust Vulkan runtime, | ||
| 69 | # so its workflows are excluded from automatic push, pull_request, and scheduled CI runs. | ||
| 70 | for name in DEPRECATED_RUNTIME_WORKFLOWS: | ||
| 71 | with self.subTest(workflow=name): | ||
| 72 | text = workflow(name) | ||
| 73 | self.assertRegex(text, r"(?m)^ workflow_dispatch:\s*$") | ||
| 74 | for trigger in ("push", "pull_request", "schedule"): | ||
| 75 | self.assertNotRegex(text, rf"(?m)^ {trigger}:") | ||
| 76 | self.assertIn(" cancel-in-progress: false\n", text) | ||
| 77 | # When runtime.yml is dispatched manually, the Wine artifact consumer still needs a real artifact. | ||
| 68 | runtime = workflow("runtime") | 78 | runtime = workflow("runtime") |
| 69 | self.assertIn("github.event_name != 'pull_request'", runtime) | ||
| 70 | self.assertIn("needs.windows.outputs.wine-artifact == 'success'", runtime) | 79 | self.assertIn("needs.windows.outputs.wine-artifact == 'success'", runtime) |
| 71 | 80 | ||
| 72 | 81 | ||
diff --git a/tests/test_runtime_paths.py b/tests/test_runtime_paths.py index 6afc9228b..97431bd73 100644 --- a/tests/test_runtime_paths.py +++ b/tests/test_runtime_paths.py | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | """The Runtime workflow's path filter still lists every file under tools/ that its jobs read. | 1 | """The Runtime workflow's path-filter scanner and manual-only trigger check. |
| 2 | 2 | ||
| 3 | python -I tests/test_runtime_paths.py | 3 | python -I tests/test_runtime_paths.py |
| 4 | 4 | ||
| 5 | ``.github/workflows/runtime.yml`` starts on the paths it lists, not on everything outside an ignore list | 5 | ``.github/workflows/runtime.yml`` builds the deprecated legacy C++ Vulkan ``runtime/`` (superseded by ``d3d12/`` |
| 6 | (BUILD-856): a change to a tool the runtime build never reads should not queue a Windows, Wine and llvmpipe run. | 6 | and the new Rust Vulkan runtime in progress), so it is now manual-only (``workflow_dispatch``) and excluded from |
| 7 | The price is that the list can fall behind. If ``tools/rdna2spirv.py`` starts importing a new ``tools/foo.py``, | 7 | automatic ``push``, ``pull_request``, and ``schedule`` CI runs. |
| 8 | that pull request still runs Runtime (it touches ``rdna2spirv.py``), but a later one that changes only | 8 | |
| 9 | ``foo.py`` would skip the GPU tests without anyone noticing. This test recomputes what the jobs read and fails | 9 | If automatic ``push`` / ``pull_request`` path filters are ever restored on ``runtime.yml``, ``problems()`` |
| 10 | when an entry is missing: | 10 | recomputes every file under ``tools/`` that its jobs read and fails when an entry is missing: |
| 11 | 11 | ||
| 12 | * the seeds are the code that runs during the jobs: the CMake files under ``runtime/`` and the workflow's | 12 | * the seeds are the code that runs during the jobs: the CMake files under ``runtime/`` and the workflow's |
| 13 | ``jobs:``, with ``#`` comments removed, and the Python under ``runtime/`` plus the scripts the workflow runs. | 13 | ``jobs:``, with ``#`` comments removed, and the Python under ``runtime/`` plus the scripts the workflow runs. |
| @@ -22,10 +22,6 @@ Comments, docstrings and the C++, shader and header sources are not read as depe | |||
| 22 | them says where a table or a test came from, not that the build runs it, and counting those would make every | 22 | them says where a table or a test came from, not that the build runs it, and counting those would make every |
| 23 | such note a required entry. | 23 | such note a required entry. |
| 24 | 24 | ||
| 25 | It also checks that the ``push`` and ``pull_request`` lists are the same, and that no ``tools/`` entry names a | ||
| 26 | file that no longer exists. Listing more than the jobs need is allowed on purpose: an extra run costs one | ||
| 27 | queue slot, a missing entry loses the build for a tool the workflow reads. | ||
| 28 | |||
| 29 | Only tracked sources and the workflow are read; no game files, no build tools, no PyYAML. | 25 | Only tracked sources and the workflow are read; no game files, no build tools, no PyYAML. |
| 30 | """ | 26 | """ |
| 31 | import ast | 27 | import ast |
| @@ -235,9 +231,16 @@ class RepositoryRuntimePathsTest(unittest.TestCase): | |||
| 235 | self.assertIn("tools/rdna2spirv.py", found) | 231 | self.assertIn("tools/rdna2spirv.py", found) |
| 236 | self.assertIn("tools/gen_d3d12_stubs.py", found) | 232 | self.assertIn("tools/gen_d3d12_stubs.py", found) |
| 237 | 233 | ||
| 238 | def test_every_tool_the_jobs_read_triggers_the_workflow(self): | 234 | def test_runtime_workflow_is_manual_dispatch_only(self): |
| 239 | issues = problems(ROOT) | 235 | # Legacy C++ runtime/ is deprecated and excluded from automatic CI runs; manual dispatch stays available. |
| 240 | self.assertFalse(issues, f"{WORKFLOW} path filter:\n" + "\n".join(f" {i}" for i in issues)) | 236 | text = read(ROOT, WORKFLOW) |
| 237 | self.assertRegex(text, r"(?m)^ workflow_dispatch:\s*$") | ||
| 238 | for trigger in ("push", "pull_request", "schedule"): | ||
| 239 | self.assertNotRegex( | ||
| 240 | text, | ||
| 241 | rf"(?m)^ {trigger}:", | ||
| 242 | f"{WORKFLOW} must not run automatically on `{trigger}:` while legacy runtime/ is deprecated", | ||
| 243 | ) | ||
| 241 | 244 | ||
| 242 | 245 | ||
| 243 | class SyntheticTreeTest(unittest.TestCase): | 246 | class SyntheticTreeTest(unittest.TestCase): |