Skip to content

ci(qt-xml): Port the UI XML validator action to Python (GEN-005, #2724) - #2726

Merged
zackees merged 2 commits into
masterfrom
infra/2724-qt-xml-validator-python
Oct 28, 2026
Merged

zackees merged 2 commits into
masterfrom
infra/2724-qt-xml-validator-python

Conversation

@zackees

@zackees zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member

The Qt UI XML validator composite action ran three multi-line shell steps, so ci-lint precheck reported three GEN-005 findings for it and the path-scoped exception in ci.toml could not leave the baseline until all three were gone. Each step is now one uv run --no-project --script call into ci/qt_xml_validate.py, and the exception block is deleted.

RED → GREEN

  • RED 8d482e487 — ci/test_qt_xml_validate.py, 14 tests, 9 failures, 2 errors on master: ci/qt_xml_validate.py is missing, the action still carries run: | blocks, and ci.toml:344-349 still names the path.
  • GREEN 5ad9360d1 — the module, the action's three one-line steps, and the exception deleted: 14 tests … OK.

ci-lint precheck on the change (pinned a1917ce)

master this branch
violations 11 11
approved exceptions 483 480
needs_review 10 10
qt-xml-validator lines 3 0

The first attempt at the GREEN added a sys.platform check and precheck reported LAYOUT-001 … references 'sys.platform' outside the platform facade (12 violations, 480 exceptions). The module now asks shutil.which('apt-get') before attempting the install, so the platform decision is capability-based and the violation is gone.

Behaviour preserved

  • guard --notice <text> — the action's if: runner.os == 'Windows' step: prints ::notice::… and exits 2, so an unsupported runner fails before the check.
  • validate --changed-files-json … --schema … --fail-condition … — parses the check-changes output (a JSON list, with the old shell's [ ] ' " strip as a fallback), installs libxml2-utils through sudo apt-get only when xmllint is not on PATH (the deleted install step), and runs xmllint --schema <xsd> --noout <files>.
  • --fail-condition never (the action input's default) returns 0 whatever xmllint said — the old block's set +e. Anything else returns the check's status.
  • The korelstar/xmllint-problem-matcher and ./.github/actions/check-changes steps are untouched; uses: steps are not GEN-005 findings.
  • The action gains its own pinned astral-sh/setup-uv step with the save-cache and pr-<N> cache-suffix expressions (the shape #2692/#2700 used), because the guard now calls uv and a Windows runner has none. The one caller, check-format.yaml:58, is the checks job, which already runs setup-uv on ubuntu-latest, so no caller changes are needed.

Evidence run locally

$ uv run --no-project --script ci/qt_xml_validate.py guard --notice probe
::notice::probe                                   # exit 2

$ PATH=<stub-dir>:$PATH uv run --no-project --script ci/qt_xml_validate.py validate \
    --changed-files-json '["frontend/forms/OBSBasic.ui"]' \
    --schema "$PWD/frontend/forms/XML-Schema-Qt5.15.xsd" --fail-condition error
ARGV: --schema …/frontend/forms/XML-Schema-Qt5.15.xsd --noout frontend/forms/OBSBasic.ui   # exit 0

uv run --no-project ci/local_gate.py --only self-test → == self-test: ok (all 373 ci/ tests), and uv run ruff check is clean on both new files.

Not verified here

xmllint is not installed on this host and the agent shell has no passwordless sudo, so the libxml2-utils install branch is exercised only against a stub apt-get (it must not run when xmllint is present — pinned by test_installs_nothing_when_xmllint_is_present). The PR's check-format lane will not run the check either, because no frontend/forms/**/*.ui file changed; the command it would run is verified above. The schema check itself is byte-for-byte the same xmllint invocation as before.

Fixes #2724

The three multi-line shell steps of
.github/actions/qt-xml-validator/action.yaml (Windows guard, libxml2-utils
install, xmllint schema check) become one `uv run --no-project --script`
call each into ci/qt_xml_validate.py, so the action's path-scoped GEN-005
exception in ci.toml can go.

Same behaviour: the guard prints the notice and exits 2; validate parses the
check-changes output, installs libxml2-utils through sudo apt-get only when
xmllint is absent, runs `xmllint --schema ... --noout <files>`, and honours
--fail-condition never (the action input's default) as the old `set +e` did.

Refs #2724

@zackees zackees left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. The port matches the deleted shell block and the exception removal is correct.

  • Behaviour preserved: guard --notice still prints ::notice:: and exits 2 (the Windows-only step), validate parses the check-changes JSON with the old [ ] ' " strip as a fallback, installs libxml2-utils only when xmllint is absent, and --fail-condition never returns 0 like the old set +e.
  • Command shape you care about here: the three run: blocks are now single-line uv run --no-project --script … calls, and the action gained its own setup-uv step (with the save-cache expression and the CACHE-013 pr-<N> suffix) above the guard, since the guard now needs uv — the ordering is right, the guard would otherwise run before an interpreter exists.
  • Path form is safe in this caller: ${{ github.workspace }} is interpolated in a runs-on: ubuntu-latest job (check-format.yaml checks), not a container, so the module path resolves. (That form is only wrong inside a container job, as #2702/#2705 found for the Flatpak lane.)
  • Capability check instead of platform check: shutil.which('apt-get') keeps LAYOUT-001 out; the module does not reference sys.platform.
  • Tests: ci/test_qt_xml_validate.py drives the module through a stub xmllint/sudo/apt-get (no network, no libxml2), and the RED → GREEN pair is real: 9 failures + 2 errors on master, 14 OK with the port.

Checks: uv run -m workflow.coordinator checks obs-studio 2726 → 32 passed, 0 failed. Queuing.

@zackees
zackees added this pull request to the merge queue Oct 28, 2026
Merged via the queue into master with commit fc03526 Oct 28, 2026
32 checks passed
@zackees
zackees deleted the infra/2724-qt-xml-validator-python branch October 28, 2026 02:58
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.

infra: Port the Qt UI XML validator composite action to Python and clear its GEN-005 exception

1 participant