Skip to content

ci: Run the sanitizer harness from Python (#962) - #2605

Merged
zackees merged 2 commits into
masterfrom
infra/962-gen-005-sanitize-python
Oct 27, 2026
Merged

zackees merged 2 commits into
masterfrom
infra/962-gen-005-sanitize-python

Conversation

@zackees

@zackees zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

Refs #962

GEN-005 burn-down: rust/tools/sanitize/sanitize.sh (178 lines) → rust/tools/sanitize/sanitize.py and rust/tools/sanitize/install-ubuntu-deps.sh (16 lines) → rust/tools/sanitize/install_ubuntu_deps.py. Both shell scripts are deleted, the sanitizers workflow runs the Python, and both ci.toml GEN-005 exceptions are gone.

RED 127bf4aef (local evidence — a focused CI/config change, so RED and GREEN are pushed together):

uv run python -m unittest ci/test_sanitize_harness.py ci/test_sanitize_deps.py → 14 tests, 14 errors. Neither module exists on that tree, so every test that loads one by path errors with FileNotFoundError.

GREEN 6be80f1ab:

  • rust/tools/sanitize/sanitize.py — the harness port.
  • rust/tools/sanitize/install_ubuntu_deps.py — the dependency port. It reads the shared Tier 2 list rust/tools/linux-validate/apt-packages.txt (ci: Run Tier 2 Linux natively on the runner #967 moved the packages there) instead of scraping the Dockerfile, adds the sanitizer-only extras (valgrind, gdb, xvfb, xauth, libgl1-mesa-dri, dbus-daemon, dbus-x11, qt6-image-formats-plugins), and keeps the shell's sudo-unless-root and DEBIAN_FRONTEND=noninteractive handling.
  • .github/workflows/sanitizers.yaml — both steps now uv run --no-project rust/tools/sanitize/…, the way the job already runs triage.py; it sets uv up before either step, so no image needs a new interpreter.
  • ci.toml — the GEN-005 exceptions for sanitize.sh and install-ubuntu-deps.sh removed.
  • ci/test_tool_guard.py — the port replaces the shell script in SCAN_ALLOWLIST (it still runs bare rustup toolchain install, in the sanitizer image), ci/test_zccache.py reads it for the launcher and the daemon stop, and shell.nix and triage.py name the Python file.

What the port keeps

Every branch, argument and output of the shell:

  • the per-tool flags and build type (asan/ubsan: RelWithDebInfo + -fsanitize=…, tsan: RelWithDebInfo + -fsanitize=thread, RUST_LIBOBS=ON default, SKIP_TESTS), the shared rustup toolchain install line, the install-zccache.sh call, and the SAN_OUT default of /tmp/obs-sanitize;
  • the cmake configure line, including the zccache launcher and the libobs backend, with the same configure.log/build.log artifacts;
  • ctest --show-only=json-v1 parsed directly (jq is gone) into the per-test commands: the wrapper in front of the named binary is dropped, WORKING_DIRECTORY is honoured, and an unregistered or non-executable command is not run;
  • the two tests only the asan pass may run, the per-test ASan/UBSan/TSan log paths, and the 10-minute per-test bound;
  • the headless launch: Xvfb on a free display, dbus-run-session around obs, the launch window, and on a hang the gdb backtrace (sudo -n first, plain gdb as a fallback) before SIGKILL — with app-exit.txt written either way;
  • zccache stop on the way out, so the cache directory the job saves is flushed.

Tests

ci/test_sanitize_harness.py (11 tests) and ci/test_sanitize_deps.py (3 tests) load the modules by path (no sys.path edit — ci/test_no_sys_path_edits.py forbids one) and drive their decisions: the per-tool flags, the arg check, the ctest JSON → per-test mapping (wrapper dropped, WORKING_DIRECTORY, unregistered/non-executable skipped), the asan-only tests, the per-test log paths, the configure line's zccache launcher and libobs backend, the valgrind launch window, and the dependency list plus its usage errors. One test runs main() end to end against a stub toolchain on PATH (rustup, cmake, ctest, Xvfb, dbus-run-session, pgrep) and asserts the artifacts triage.py reads: tests/summary.txt with test_core exit=0, tests/ctest.tsv, app-exit.txt = app exit=0 (exited), and the four logs.

Local:

  • uv run python -m unittest ci/test_sanitize_harness.py ci/test_sanitize_deps.py → 14 OK.
  • uv run python -m unittest ci/test_sanitize_triage.py ci/test_sanitizers_schedule.py ci/test_zccache.py ci/test_tool_guard.py ci/test_ci_toml.py ci/test_no_sys_path_edits.py ci/test_uv_run.py → OK.
  • uvx --from ruff==0.14.0 ruff check --no-cache --quiet $(git ls-files '*.py') → clean.
  • uv run --no-project rust/tools/sanitize/sanitize.py (no arguments, and an unknown tool) → the usage message and exit 2, i.e. the exact command sanitizers.yaml now runs.
  • ci/local_gate.py --only self-test → every file green except ci/test_gate_dylint.py and ci/test_local_gate_probe.py.

Not run locally

./lint's rust lane errors in this environment, unrelated to this change: test_local_gate_probe fails against the host's soldr (0.9.35 broker vs the repo's 0.9.41) and test_gate_dylint asserts CARGO_TARGET_DIR is unset, which this shell sets to ''. Both fail on master here too; PR CI is the gate.

No user-visible change: CI tooling only, so no docs/features.md line.

…e shell (#962)

RED: ci/test_sanitize_harness.py (11 tests, including one whole stub-toolchain
run) and ci/test_sanitize_deps.py (3 tests) load rust/tools/sanitize/sanitize.py
and install_ubuntu_deps.py by path and drive their decisions. On the unfixed
tree neither module exists, so every test errors with FileNotFoundError.
GREEN: rust/tools/sanitize/sanitize.py (178-line sanitize.sh) and
install_ubuntu_deps.py (16-line install-ubuntu-deps.sh) replace the shell, and
the ci.toml GEN-005 exceptions for both are gone.

- sanitizers.yaml runs both through `uv run --no-project`, the way it already
  runs rust/tools/sanitize/triage.py; the job sets uv up before either step, so
  no container needs a new interpreter.
- The port keeps the shell's behavior: the per-tool flags and build type, the
  `ctest --show-only=json-v1` to per-test mapping (wrapper dropped, WORKING_DIRECTORY
  honored, unregistered or non-executable commands skipped), the two tests only
  the asan pass may run, the per-test ASan/UBSan/TSan log paths, the zccache
  launcher and `zccache stop` on the way out, the 10-minute per-test bound, and
  the SIGINT/SIGKILL launch window with the gdb backtrace when it hangs. jq is
  gone: the ctest JSON is parsed directly.
- ci/test_tool_guard.py allowlists the port (it still runs bare `rustup
  toolchain install`, in the sanitizer image), ci/test_zccache.py reads it for
  the zccache launcher and daemon stop, and shell.nix/triage.py name it.

Refs #962
@zackees
zackees force-pushed the infra/962-gen-005-sanitize-python branch from 6be80f1 to 6fa462c Compare October 27, 2026 10:58
@zackees
zackees added this pull request to the merge queue Oct 27, 2026
@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator.

  • Rebased onto origin/master (c2a9d135e) and force-pushed (lease); the PR reports MERGEABLE / CLEAN and sits in the merge queue after ci: Run the Tier 2 stale-build reset from Python (#962) #2601.
  • Local gate: ./lint passes end to end (formatting, ruff on 350 files, the 240 ci/test_*.py self-tests, clippy/dylint). The stamping run (ci-lint local-gate run) is green on its lint, rust-test and cross lanes, with tier2-linux still going at handoff — PR CI is the gate and its CI Gate ✅ is already in.
  • Evidence for the port and its RED/GREEN commits is in the description; nothing needs a device or a maintainer decision.

Merged via the queue into master with commit 81f7d26 Oct 27, 2026
31 checks passed
@zackees
zackees deleted the infra/962-gen-005-sanitize-python branch October 27, 2026 11:24
MCPVOT pushed a commit to MCPVOT/obs-studio that referenced this pull request Oct 30, 2026
* test: Point the zccache installer test at the Python port (obs-rust#962)

The zccache installer is being ported from install-zccache.sh to
install_zccache.py. This changes ci/test_zccache.py to read the Python
module, to assert the Python port's shapes (a pinned ZCCACHE_VERSION, two
SHA-256 digests, hashlib.sha256) and to pin the wiring: the shell script
is gone, ci.toml keeps no GEN-005 exception for it, and every caller
(Dockerfiles, .dockerignore, setup_zccache, build-project.yaml,
sanitize.sh) runs the Python through uv run. A new PortTest exercises the
port offline: the arch map (and the unsupported-arch failure), the
archive digest, and the already-installed early return.

RED: uv run python -m unittest ci/test_zccache.py -> 9 failures, 8 errors
(install_zccache.py does not exist yet; the Dockerfile and the other
callers still name install-zccache.sh).

* ci: Port the zccache installer to Python (obs-rust#962)

install-zccache.sh (38 lines) installs the pinned zccache 1.15.5 static-musl
release into a destination dir, mapping uname -m x86_64/amd64 and
aarch64/arm64 to their pinned SHA-256, returning early when the installed
binary already reports the version, and failing on any other arch.

install_zccache.py is a faithful port: same version, same two digests,
same messages and exit codes. The download keeps curl's retry, the digest
is checked before install, the binary lands at mode 0755, and the final
step prints --version. The arch map, digest and installed-check are
exercised offline by ci/test_zccache.py.

Every caller now runs the Python through uv (TOOL-003):
- rust/tools/linux-validate/Dockerfile (uv run --no-project --python
  /usr/bin/python3, uv is already in the image)
- build-aux/appimage/manylinux/Dockerfile (uv arrives later in that
  Dockerfile, so the manylinux interpreter runs it)
- .github/scripts/utils.zsh/setup_zccache and both build-project.yaml
  steps (uv run --no-project)
- rust/tools/sanitize/sanitize.sh (uv run --no-project)
- .dockerignore lists the .py; the GEN-005 exception for the .sh is gone
  from ci.toml, and docs/ci-tooling.md names install_zccache.py.

No docs/features.md line: a pure tooling port with no user-visible change.

GREEN: uv run python -m unittest ci/test_zccache.py -> 22 tests, OK;
ci.test_uv_run, ci.test_dockerignore_copies and ci.test_tool_guard -> OK;
./lint -> ok (its ci/test_local_gate_probe and test_gate_dylint failures
were this shell's empty CARGO_TARGET_DIR, gone with it unset).

* ci: Run the sanitizer's zccache install from Python after obs-rust#2605 (obs-rust#2606)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant