Skip to content

DevEx: add local CI check runner script and update contributor guide - #803

Open
sombraSoft wants to merge 3 commits into
ItsNotRexed:mainfrom
sombraSoft:devex/run-checks-and-docs
Open

sombraSoft wants to merge 3 commits into
ItsNotRexed:mainfrom
sombraSoft:devex/run-checks-and-docs

Conversation

@sombraSoft

Copy link
Copy Markdown
Contributor

Summary

Part 4 of #799 (independent of #800-#802; base: main).

Makes running local pre-PR checks a single cross-platform command matching CI and updates CONTRIBUTING.md to match current CI tooling:

  • scripts/run_checks.py (stdlib-only, works with python -I, Windows-first, no bash required):
    • Default checks mirroring CI: no-game-data, compileall, help, stdlib-tests (recursive tests/**/test_*.py excluding tests/semantic/), pytest (exact complement + test_tex_headers parity node; skips with pip install -r tests/requirements.txt hint if not installed), semantic, viewer (tests/test_*.cjs), dotnet (rpf9dump + Rpf9DumpDiagnostics; skips cleanly with submodule hint if uninitialized).
    • Opt-in checks: --runtime (auto-detects runtime/CMakePresets.json when present, otherwise falls back cleanly to scripts/build_runtime.ps1 / cmake + ctest) and --lint (runs jactionlint using the profile configured in .github/workflows/jactionlint.yml).
    • CLI flags: --list, --only, --skip, --runtime, --lint, --strict, --fail-fast, -v/--verbose, with a PASS/SKIP/FAIL timing summary.
  • tests/test_run_checks.py: 13 stdlib unittest cases verifying recursive discovery, exact disjoint stdlib-tests / pytest partition parity across the repo, no-game-data regex, jactionlint profile parsing, OS preset selection, and CLI flag parsing.
  • CONTRIBUTING.md: document scripts/run_checks.py, pip install -r tests/requirements.txt, Rpf9DumpDiagnostics, -DLEONIDA_D3D12_SHIM_TESTS=ON and header-only VULKAN_SDK, compileall on scripts, and jactionlint.

Tested

Notes

  • No game data included.
  • AI-assisted (OpenCode).

@kotorvr

kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Reviewed db51f20: 1 finding

  • scripts/run_checks.py:508-522: on Windows --runtime effectively always takes the build_runtime.ps1 path (runtime/CMakePresets.json doesn't exist on main, and powershell is always on PATH), then runs ctest --test-dir runtime/build. Two consequences: (1) build_runtime.ps1 never passes -DLEONIDA_D3D12_SHIM_TESTS=ON, so the root-signature test the CONTRIBUTING.md change tells people to enable is never built; the -DLEONIDA_D3D12_SHIM_TESTS=ON fallback at :549-550 is only reached when no PowerShell exists. (2) When VS lacks the C++ CMake tools, build_runtime.ps1 builds with cl.exe directly and writes no CTest files; ctest --test-dir <dir without tests> prints "No tests were found!!!" and exits 0 (checked with ctest 4.4.3), so the check reports PASS with zero tests run. Passing --no-tests=error to ctest (and the shim-tests option, or calling cmake directly) would fix both.

CONTRIBUTING.md claims check out (tests/requirements.txt, tests/Rpf9DumpDiagnostics, LEONIDA_D3D12_SHIM_TESTS, the VULKAN_SDK header-only path in runtime/CMakeLists.txt, --only lint), and the stdlib/pytest partition matches ci.yml on current main.

Ran (on this branch merged with origin/main dcd8ecf, clean merge): python -I tests/test_run_checks.py 13/13 OK; python -m compileall -q make_game.py tools tests scripts clean; python -I scripts/run_checks.py --skip dotnet,pytest: 6/6 PASS (no-game-data, compileall, help, stdlib-tests 107 files, semantic, viewer); --only dotnet SKIP (submodule not populated), --only lint SKIP / --strict FAIL as documented; ctest --test-dir <empty dir> rc 0. Runtime not built. Windows 11, Python 3.13.7.

Review was AI-assisted (Claude Code).

@bobcatchris

Copy link
Copy Markdown
Contributor

One addition to the unit-test bullet, from running the suite on Windows today: installing tests/requirements.txt is necessary but not sufficient for the documented command.

python -I tests/test_<name>.py cannot work for the pytest-based files even with pytest installed, because -I implies -s — the user site-packages (where pip install puts pytest) are hidden, so the file dies on the import:

$ python -I tests/test_amd_swizzle.py
ModuleNotFoundError: No module named 'pytest'
$ python -m pytest tests/test_amd_swizzle.py -q
...   (passes)

18 of the files under tests/ start with import pytest, so the bullet is only true for the stdlib-only ones. Suggested wording for the same line:

python -I tests/test_<name>.py runs one of the standard-library unit tests. The pytest-based ones need pip install -r tests/requirements.txt and python -m pytest tests/test_<name>.py (not -I: it hides site-packages, so import pytest fails). python -m pytest tests -q runs all of them.

Everything else in this PR reads right to me; the runtime and rpf9dump additions match what I had to discover by hand.

AI-assisted.

@sombraSoft

Copy link
Copy Markdown
Contributor Author

Good catch on both points, @kotorvr — fixed in dad59c0:

  1. Windows CMake + -DLEONIDA_D3D12_SHIM_TESTS=ON without presets: _find_cmake_tool() now resolves both cmake and ctest from PATH or Visual Studio (vswhere.exe). When runtime/CMakePresets.json is absent, --runtime calls CMake directly with -DLEONIDA_D3D12_SHIM_TESTS=ON (using -G Ninja only when cl + ninja are on PATH, otherwise CMake's default VS generator with --config RelWithDebInfo / -C RelWithDebInfo). When cmake or ctest is missing, --runtime returns SKIP (or FAIL with --strict) instead of running a cl.exe-only fallback with no CTest files.
  2. --no-tests=error everywhere: passed to every ctest invocation (preset, build_runtime.ps1 + preset, and direct CMake paths), so an empty build directory can never report PASS with zero tests run.
  3. Added unit tests in tests/test_run_checks.py covering plain-shell Windows, Dev Prompt Windows, preset mode, and missing cmake/ctest.

Verified locally on Windows 11 (plain PowerShell, MSVC 19.51 / VS Build Tools CMake):

  • python -m compileall -q make_game.py tools tests scripts -> exit 0
  • python -I tests/test_run_checks.py -> 16/16 OK
  • python -I scripts/run_checks.py --only runtime -v -> built with -DLEONIDA_D3D12_SHIM_TESTS=ON and passed 23/23 ctest tests including #23 d3d12_xs_root_signature (--no-tests=error)

@sombraSoft

Copy link
Copy Markdown
Contributor Author

Good catch on -I hiding user site-packages, @bobcatchris — updated that bullet in CONTRIBUTING.md in the latest commit to call out python -m pytest tests/test_<name>.py (without -I) and python -m pytest tests -q. (scripts/run_checks.py itself invokes sys.executable -m pytest without -I, so it already avoids that trap when launched via python -I scripts/run_checks.py.)

@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 290101e merged onto current main (0d61c35). The branch is 356 commits behind but merges cleanly. Windows 11 Pro 26300, Python 3.13 (Microsoft Store build), .NET 8.0.428, Node 26: pass, with one Windows setup note.

In a venv with tests/requirements.txt: python -I scripts\run_checks.py gives 8 passed, 0 skipped, 0 failed in 443 s:

check time
no-game-data 0.04 s 797 tracked files
compileall 3.1 s
help 0.1 s
stdlib-tests 229 s 137 files
pytest 16 s 23 targets
semantic 188 s
viewer 0.3 s 1 file
dotnet 5.8 s
  • Matches CI: I recomputed ci.yml's split (PYTEST_FILE_MARKERS, the __main__ test, tests/semantic pruned) over the merged tree. It gives 137 stdlib files and 22 pytest files plus the tex_headers parity node, the same as the runner's 137 and 23.
  • Its own tests: tests/test_run_checks.py gives 16 OK.
  • CLI: --list and --only work. --only nosuch is a clean usage error, exit 2, listing the valid names.

Setup note: Microsoft Store Python with user-site packages. I ran with the system python after pip install -r tests/requirements.txt had gone into the user site, which is pip's default for the Store build. There the pytest check fails rather than skips:

  • pytest itself is importable, so the check runs;
  • tools the tests start with python -I (tile_probe.py, swizzle_search.py) can't import numpy, because -I ignores the user site;
  • result: ModuleNotFoundError: No module named 'numpy' in the subprocess, and the summary shows FAIL pytest ... exit 1.

CI and a venv don't hit this, and it isn't caused by this PR. But since the runner is the "one command before a PR" entry point, a line in CONTRIBUTING.md would save the next Windows contributor the confusion. It could recommend a venv, or say that pip install --user packages are invisible to python -I. Optionally, the pytest check could also look for numpy with -I before it runs.

--runtime and --lint (opt-in) were not tried.

AI-assisted (Claude Code).

@sombraSoft
sombraSoft force-pushed the devex/run-checks-and-docs branch from 290101e to 045cd98 Compare November 22, 2026 08:58
@kotorvr

kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Reviewed 045cd98: looks good. My finding from db51f20 is fixed. Without presets (main has no runtime/CMakePresets.json), --runtime now calls CMake directly with -DLEONIDA_D3D12_SHIM_TESTS=ON on Windows, and every ctest call passes --no-tests=error. A build that produces no tests now fails instead of passing: ctest --test-dir <empty> --no-tests=error gives rc 8. Ran on this branch merged with current origin/main (clean): python -I tests/test_run_checks.py OK. Runtime not built. Windows 11, Python 3.13.7. Review was AI-assisted (Claude Code).

@x2Tweek

x2Tweek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Static review — PR #803

Branch: devex/run-checks-and-docs (head of PR #803)
Commit: (head of PR #803)
Author: sombraSoft
State: OPEN, CONFLICTING with main (needs rebase before merge)

What it does

DevEx / CI local check runner:

  • scripts/run_checks.py (new, 823 lines) — runs the repository's CI checks locally from one command:
    • no-game-data — git ls-files scan for forbidden game/binary extensions (rpf, ttpf, xvd, dxbc, fssm, spv, spvasm, dds, bk2, awc, exe, dll).
    • compileall — byte-compiles make_game.py, tools, tests, scripts.
    • help — python -I make_game.py --help.
    • stdlib-tests — runs all stdlib test files under python -I (excluding tests/semantic/).
    • pytest — runs pytest-marked test targets (skips if pytest not installed).
    • semantic — unittest discover -s tests/semantic.
    • viewer — Node.js viewer streaming tests (skips if node not found).
    • dotnet — builds tools/rpf9dump and runs Rpf9DumpDiagnostics (skips if dotnet/submodule missing).
    • runtime (opt-in) — CMake configure/build/ctest for the C++ runtime, with preset support and Windows PowerShell fallback.
    • lint (opt-in) — jactionlint workflow linting (skips if jactionlint not installed).
    • --list, --only, --skip, --runtime, --lint, --strict, --fail-fast, -v flags.
  • tests/test_run_checks.py (new, 323 lines) — unit tests for discovery, partition, no-game-data regex, CLI selection, jactionlint profile, and runtime preset selection.
  • CONTRIBUTING.md — documents python -I scripts/run_checks.py, dotnet build/test commands, pytest install hint, and Vulkan-Headers-only Windows build note.

Reviewer recommendation

Approve (static review). Well-structured check runner with sensible defaults, opt-in checks for heavy toolchains (runtime, dotnet, lint), clean skip behavior when optional tools are missing, and comprehensive unit tests. All 16 tests pass, compileall clean, script runs end-to-end.

Note: PR is marked CONFLICTING on GitHub — the author needs to rebase on main before it can be merged.

CPU test results

  • tests/test_run_checks.py: 16 passed
  • python -m compileall: clean on all changed .py files
  • python -I scripts/run_checks.py --only no-game-data,compileall,help: 3 passed

AI-assisted. Reviewed with Claude Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants