Repository navigation
ci: Port the flatpak-builder-lint action to Python (GEN-005) - #2702
Conversation
RED on master: ci/flatpak_builder_lint.py does not exist and
.github/actions/flatpak-builder-lint/action.yaml still carries two
inline run: blocks (artifact guard, lint + jq annotation pipeline).
uv run --no-project python -m unittest ci/test_flatpak_builder_lint.py
AssertionError: ci/flatpak_builder_lint.py is missing: the action still runs shell
Ran 10 tests -- FAILED (failures=10)
The action's two inline run: blocks (artifact guard; flatpak-builder-lint
call plus the two-stage jq annotation pipeline) are ci/flatpak_builder_lint.py
now, invoked as `uv run --no-project`, and the path's GEN-005 exception
block leaves ci.toml.
uv run --no-project python -m unittest ci/test_flatpak_builder_lint.py
Ran 10 tests ... OK
ci-lint precheck: 11 violation(s), 483 approved exception(s), 10 needs_review
(was 485 exceptions; GEN-005 245 -> 243, no new finding).
zackees
left a comment
There was a problem hiding this comment.
Reviewed the port against the two inline run: blocks it replaces. Behaviour matches, and I checked the edges that differ:
lintinherits the step'sworking-directory(cwd=None), so--pathstays relative to it as the shell's did.- The empty-body-with-non-zero-exit case still exits 2 before the appstream branch, so a broken tool is not misreported as invalid appstream.
- Tool stderr still reaches the job log, and the return code is the tool's except for the two error paths (2), which is the shell's contract.
guardis now an exact match on the four kinds. The old=~ builddir|repo|manifest|appstreamwas unanchored, sobuilddirxused to pass; rejecting it is the intent and no caller passes anything but the four.
Tests: uv run --no-project python -m unittest ci/test_flatpak_builder_lint.py → 10 tests OK, and ci/test_*.py discovery in ci/local_gate.py picks the file up. RED first (test(ci): pin ...) then the implementation, and the ci.toml GEN-005 exception for the action path is gone, so the path leaves the baseline.
I pushed one fixup commit (da3bbb5) for two things the port needed:
- publish.yaml had no uv.
flatpak-publishruns inghcr.io/flathub-infra/flatpak-github-actions:freedesktop-26.08and the module docstring's claim that "the flatpak job that calls the action sets uv up before it" only holds forbuild-project.yaml. That job (gated ongithub.repository_owner == 'obsproject') calls the action five times with nosetup-uv, so it would fail withuv: command not foundonce it runs. Added the same pinnedastral-sh/setup-uv@bec219dstep its sibling flatpak jobs use. Its other four callers (flatpak-build,flatpak-compiler-consumer) already set uv up before their first lint step. - A
SyntaxWarningon every run. The docstring was not raw, so\(was an invalid escape sequence and printedSyntaxWarningbefore the linter did anything. It is a raw docstring now, and its list of deliberate differences says three, not two.
One thing worth knowing for later, not a defect here: ci/flatpak_pruned_build_probe.py:140 still invokes flatpak-builder-lint directly rather than through this module. It is Python and outside GEN-005's business, so I left it alone.
…arning The action is a ci/ Python module now (GEN-005, #2700), so the flatpak-publish job in publish.yaml needs setup-uv before it calls the action. Its sibling jobs in build-project.yaml already do; this job has no uv step, so the action would fail there with 'uv: command not found' (Runner: ghcr.io/flathub-infra/flatpak-github-actions). The module docstring is raw now: '\(' was an invalid escape sequence, so every run printed a SyntaxWarning before the linter ever ran. Its list of deliberate differences also says three, not two.
da3bbb5 to
66e4fcc
Compare
|
Amended the fixup ( |
|
Regression check on master, from the Flatpak lane in run 40595018476 (job 122510595479): the lane is red on this change, and it is my fault as much as the author's — I reviewed and queued it.
#2707 fixes it — the action derives the repo root from |
…bs-rust#2705) (obs-rust#2706) * ci: Pin that the Flatpak lint action addresses its module relatively (obs-rust#2705) The Flatpak job runs in a container at /__w/obs-studio/obs-studio, but ${{ github.workspace }} in a composite action's run: resolves to the runner host path, so the module never spawns. The pin fails on master. * ci: Address the Flatpak lint module relative to the job's container (obs-rust#2705) The Flatpak job runs inside a container at /__w/obs-studio/obs-studio, while ${{ github.workspace }} and ${{ github.action_path }} interpolate the runner host path (/home/runner/work/...). Passing those as arguments is not translated the way working-directory: is, so obs-rust#2702's GEN-005 port made the first lint step die with 'Failed to spawn: .../ci/flatpak_builder_lint.py' before the build. Both steps already carry working-directory: ${{ inputs.workingDirectory }} (the workspace by default), so the module and the action's own exceptions.json are now addressed relative to it, matching the neighbouring ci/flatpak_compiler_diagnostics.py step in the same job. Verified locally: the new pin passes, ci/test_flatpak_builder_lint.py stays green, guard exits 0 for manifest and 2 for an unknown kind, and the action YAML parses with both run commands as intended. The Flatpak lane itself only runs from Scheduled/dispatch, so a workflow_dispatch is the real proof.
What this does
.github/actions/flatpak-builder-lint/action.yamlwas one of theGEN-005approved exceptions: CI logic living in shell. It carried two inlinerun:blocks — an artifact-type guard, and theflatpak-builder-lintcall with a two-stagejqpipeline that turns the linter's JSON into::warning::/::error::annotations.Both are
ci/flatpak_builder_lint.pynow (guard,lintsubcommands, stdlib only,#!/usr/bin/env -S uv run --script), the action calls it asuv run --no-project, and the path's[[exceptions]]block leavesci.toml. Theflatpak-buildjob inbuild-project.yaml— the action's only caller, three steps:manifest,appstream,builddir,repo— installsastral-sh/setup-uvbefore the action, and a compositeuses:runs on the runner, souvis available.RED
9e34df047addsci/test_flatpak_builder_lint.py, which fails on master — the module does not exist and the action still carries inline shell:GREEN
f433806e0(the branch tipb05435373, amended to carry the test's own argument expectation — the tool path isargv[0]) is the port.ci-lint precheck(pinnedci.yml@a1917ce):1369daf30No
GEN-005finding for.github/actions/flatpak-builder-lint/action.yamlremains and nothing new appeared.Differential run — old block vs module, same fixtures
The old
run:block was extracted verbatim from master, substituted withbuilddir/appstreamand run underbash -eo pipefailagainst a stubflatpak-builder-lintthat prints a fixed body and exits with a fixed code; the module ran on the same fixture in the same directory:{"warnings":["unused-key","old-runtime"],"errors":["missing-icon"]}{"warnings":[],"errors":[]}{"errors":[]}::error::Flatpak appstream info is not valid, exit 1::error::Error while running flatpak-builder-lint, exit 2The one difference is a defect in the old block, deliberately fixed. It set
template=" found in the Flatpak <artifact>"but interpolated${template}inside a single-quotedjqprogram, sojqprinted the literal text${template}— every annotation endedunused-key${template}instead ofunused-key found in the Flatpak builddir(jqinterpolates with\(…), not${…}). The module emits the suffix the block's own comment describes;ci/test_flatpak_builder_lint.pypins the exact lines.Two smaller, documented divergences, both in the fail-safe direction: a non-JSON body yields no annotations instead of a
jqparse error under-eo pipefail(the real tool always prints JSON), and awarnings/errorsvalue that is not a list is skipped, matching thetrythe original filter wrapped aroundmap.Not verified here
The flatpak lane is
workflow_dispatch-only, so PR CI does not execute it; the evidence above is the module test plus the differential run, not a green flatpak build. The action's step semantics (arguments, annotations, exit codes) are unchanged apart from the suffix fix.Fixes #2700. Refs #962 (closed tracker; this is one of the remaining
GEN-005exceptions).