Skip to content

Feat: Test lane steps per PR and add Python CLM - #113

Merged
tykeal merged 3 commits into
lfreleng-actions:mainfrom
modeseven-lfreleng-actions:test/validation-harness
Sep 23, 2026
Merged

tykeal merged 3 commits into
lfreleng-actions:mainfrom
modeseven-lfreleng-actions:test/validation-harness

Conversation

@ModeSevenIndustrialSolutions

Copy link
Copy Markdown
Member

Summary

Two atomic commits, closing two issues:

Closes #100.
Closes #42.

They belong together: the second commit adds its offline-testable cases to the harness the first creates, and its design was shaped by resolving real projects the same way the harness tests steps — by running them rather than reasoning about them.

Why not the other three open issues

Issue Blocker
#74 Needs a new fixture repository carrying direct and nested submodules
#39 Needs uploads to a live Nexus IQ server — side effects on a shared system, so I have asked before doing it
#40 Depends on #39's outcome

#100 — test the steps, not a copy of them

The fixture design I recorded in #100 cannot work. It needed a testing.yaml leg asserting the lane fails, and continue-on-error is not available on a job calling a reusable workflow — actionlint confirms it:

when a reusable workflow is called with "uses", "continue-on-error" is not available.

So a failing leg would fail the whole run.

tests/workflow-steps.sh instead pulls each step's run: block out of the workflow with yq, as GitHub sees it, and runs it with GitHub's own shell: bash flags (--noprofile --norc -eo pipefail) under an emptied environment. A new workflow-tests.yaml runs it on every PR touching a workflow — no credentials, no network, no fixture, where testing.yaml runs only on a credentialled dispatch.

Three properties that keep it honest:

  • A renamed or removed step fails the harness rather than being skipped.
  • A rejection must name its cause, so an input rejected for the wrong reason does not count as rejected.
  • A step interpolating ${{ }} in its run: block is refused, since GitHub would substitute it before bash saw it and the harness could not reproduce that.

69 cases cover the pre-scan hook exclusivity, path shapes, mvn_pom_file on both lanes, maven_args POM rejection, the scanner-side -f ./ assembly, pre-scan execution and containment, step ordering, and the new Python build type.

Verified it catches regressions, not merely that it passes

Each implementation was broken deliberately on a scratch copy:

Mutation Caught by
Symlink containment removed rejects a symlink leaving the workspace and and never executes it — the escaping script actually ran
Scanner-side ./ prefix dropped emits 'args=-f ./alt.xml', ... ./-Dalt.xml
.. reverted to a substring match two dots inside a name ('setup..sh')
python dropped from build_type accepts 'python'
Python scan target reverted to the source tree the scan targets the resolved directory for python
No-manifest error downgraded to a warning Survived at first — the assertion matched text both messages shared. Tightened to require the ::error:: annotation; now caught

That last row is why mutation-testing a test suite matters: the case looked like coverage and was not.

It found a latent defect on its first run

The CLM lane's mvn_pom_file check rejected an empty value, and was correct only because its if: happened to skip it — while its own comment claims to answer exactly as the Sonar lane does, which guards inside the script. Not live today, but removing that if: would have broken every CLM caller. Guarded in-script the same way.


#42 — Python build_type, designed against real consumers

The issue's precondition was identify consumers before building this. Three O-RAN-SC Gerrit projects still run the legacy gerrit-tox-nexus-iq-clm job: pti-o2, smo-ves and ric-plt-xapp-frame-py.

Resolve first, then scan what resolved. Nexus IQ reads only a requirements.txt, and only its == lines. pti-o2 pins 2 of its 18 requirement lines, so a manifest scan would evaluate two components; resolved, it yields 56 artefacts. That is the D12 failure mode in its purest form.

Source detection, first match wins:

Source Why Real project
requirements.txt Legacy parity smo-ves, pti-o2
uv.lock Locked versions, not fresh resolutions of the same ranges test-python-project
pyproject.toml / setup.py The project's declared deps, resolved as installing it would ric-plt-xapp-frame-py

ric-plt-xapp-frame-py has no requirements.txt at all, so the legacy script, which hardcodes the name, could never have resolved it. Its advertised REQUIREMENTS_FILE parameter was never read either; no equivalent is offered rather than an input that does nothing.

Four findings from running it, not reasoning about it

1. --frozen scanned a stale lock green — replaced with --locked. With a declared runtime dependency added to pyproject.toml but absent from uv.lock, uv export --frozen exported cleanly and the scan passed without it. My first negative test for this was itself broken — it produced invalid TOML, so it never tested a stale lock at all. Redone with a valid project confirmed stale by uv lock --check:

--frozen:  step exit=0   Artefacts resolved: 7   six scanned? 0   ← silent miss
--locked:  step exit=1   ::error::uv.lock is out of date with pyproject.toml ...

2. The interpreter decides what resolves. Neither smo-ves nor ric-plt-xapp-frame-py declares requires-python, so uv picks the newest. Both then fail: gevent==22.10.2 and hiredis==2.0.0 have no wheel for Python ≥3.12, and building from source fails.

python 3.13 / 3.12   smo-ves, xapp   exit=1
python 3.11          smo-ves  exit=0  40 artefacts    xapp  exit=0  18 artefacts

I did not guess an older default — that would be wrong for the next project. python_version pins it, and the failure is actionable, naming that input and pointing at the package responsible.

3. What looked like build tooling leaking in was not. pip download fetched build, setuptools, packaging and pyproject_hooks — which read like the go.sum over-reporting problem. My hypothesis was wrong: they are genuine runtime dependencies, declared by inotify, ricsdl, redis and build. So nothing is filtered.

4. An errexit trap, proven rather than assumed. A function called in an if: or || context runs with errexit off:

$ bash -eo pipefail -c 'f(){ false; echo continued; }; if f; then echo "f returned success"; fi'
continued
f returned success

So without an explicit || return on every command, a failed uv export would fall through to an empty download. Every command in resolve() returns explicitly, with distinct codes so a stale lock and a failed download get different, accurate messages.

Final matrix, against the shipped step

--- positive ---
smo-ves   py=3.11  exit=0  Artefacts resolved for the scan: 40
xapp      py=3.11  exit=0  Artefacts resolved for the scan: 18
pti-o2    py=3.11  exit=0  Artefacts resolved for the scan: 56
fixture   py=auto  exit=0  Artefacts resolved for the scan: 7
--- negative (each names its own cause) ---
stale     exit=1  ::error::uv.lock is out of date with pyproject.toml ...
smo-ves   exit=1  ::error::could not resolve ... under Python 3.13 ...
empty     exit=1  ::error::build_type 'python' found nothing to resolve ...

uv provisions the interpreter, so the lane needs no setup-python — no action in the organisation uses it — and supplies uv export for lock files; pip resolves, since uv has no download command. astral-sh/setup-uv is pinned to the organisation's existing bec219d… # v10.1.0, verified to be a commit and not a tag object, with its cache disabled for the same reason as Setup Go.


Validation

  • prek run --all-files — all hooks pass (codespell caught my deliberate typo test input; changed the input rather than adding an exclusion)
  • tests/workflow-steps.sh — 69/69, plus the six mutations above
  • zizmor --persona auditor — 0 findings. That is the true baseline: main migrated all 18 self-repository references to the $/ form, which cleared the old figure, and upstream/main also scores 0. A positive control confirms the new setup-uv step is genuinely audited — replacing its pin with @v10 is flagged unpinned-uses
  • aislop ci --staged — 0 errors, 0 warnings
  • gitlint --commits upstream/main..HEAD — clean; both commits signed

The new sonatype-lifecycle-python leg in testing.yaml is workflow_dispatch-only and needs org credentials, so it will not run on this PR. workflow-tests.yaml runs here for the first time, which is its own real test on GitHub's runners.

The validation and hook steps that gate every scan had no committed
coverage. The pre-scan script's containment check -- what stops a
symlink in an untrusted patchset reaching outside the checkout -- had
been proved only against a temporary tree, which proves nothing about
the next change.

The fixture design recorded in lfreleng-actions#100 cannot work. It needed a
testing.yaml leg asserting that the lane FAILS, and continue-on-error
is not available on a job calling a reusable workflow, so the failing
leg would fail the whole run. actionlint confirms it.

Extract the steps instead. tests/workflow-steps.sh pulls each run
block out of the workflow with yq, as GitHub would see it, and runs
it with the flags GitHub uses for 'shell: bash' under an emptied
environment. A copy of a step would test the copy; a renamed or
removed step fails the harness rather than being skipped. Each
rejection must also name its cause, so an input rejected for the
wrong reason does not count.

This is better coverage than the fixture legs would have been, not a
substitute: it runs on every pull request touching a workflow, with
no credentials, no network and no fixture, where testing.yaml runs
only on a credentialled dispatch.

Checked that it catches regressions rather than only passing.
Removing the containment check made the escaping script execute, and
the harness failed on exactly that. Dropping the './' prefix on the
scanner-side POM and reverting '..' to a substring match were each
caught by the case written for them.

It also found a latent defect on its first run. The CLM lane's
mvn_pom_file check rejected an empty value and was correct only
because its if: skipped it, while the step claims to answer exactly
as the Sonar lane does, which guards inside the script. Guard it the
same way, so removing the if: cannot break every caller.

Closes: lfreleng-actions#100

Co-authored-by: Claude <[email protected]>
Signed-off-by: Matthew Watkins <[email protected]>
Three O-RAN-SC Gerrit projects still run the legacy
gerrit-tox-nexus-iq-clm job: pti-o2, smo-ves and
ric-plt-xapp-frame-py. That settles the issue's own precondition of
identifying consumers before building this.

Resolve first, then scan what resolved. Nexus IQ reads only a file
named requirements.txt and only its '==' lines, so a manifest scan of
a loosely pinned project evaluates almost nothing. pti-o2 pins two
of its eighteen requirement lines; resolved, it yields 56 artefacts.

Take the source in order: requirements.txt for parity with the
legacy job, then uv.lock, then the project's own metadata.
ric-plt-xapp-frame-py has no requirements.txt at all, so the legacy
script, which hardcodes the name, could never have resolved it. Its
advertised REQUIREMENTS_FILE parameter was never read; offer nothing
rather than an input that does nothing.

Found by resolving the real projects rather than reasoning about
them:

Use 'uv export --locked', not --frozen. With a declared runtime
dependency missing from uv.lock, --frozen exported cleanly and the
scan passed without it. --locked fails on a stale lock and says so.

The interpreter decides what resolves. smo-ves and
ric-plt-xapp-frame-py declare no requires-python, so uv picks the
newest, where gevent==22.10.2 and hiredis==2.0.0 have no wheel and
fail to build. Both resolve under 3.11. Do not guess an older
default: python_version pins it, and the error names that input.

build, setuptools, packaging and pyproject_hooks looked like build
tooling leaking into the scan. They are genuine runtime dependencies
declared by inotify, ricsdl, redis and build, so nothing is filtered.

No continue-on-error, as for Go: a partial resolution scanned as if
whole is worse than a failed job. An empty result fails too.

Detection runs before anything is fetched, so the no-manifest
rejection is covered offline by tests/workflow-steps.sh; resolution
and the scan run in a new testing.yaml leg against the fixture.

Closes: lfreleng-actions#42

Co-authored-by: Claude <[email protected]>
Signed-off-by: Matthew Watkins <[email protected]>

This comment was marked as resolved.

Copilot review round 1.

scan_targets is overridden for build_type 'python', but its public
description gave no exception at all and the GitHub example named Go
as the only one. A caller could set a target the lane then discarded
without saying so. Document both exceptions on the input itself, and
point scan_mode at it rather than restating the rule twice.

The other finding does not hold. It claimed 'pip download .' writes
the local project's own distribution into the download directory,
so a dependency-free project would bypass the empty check. pip saves
only what it fetches, and a local directory is not fetched: a
dependency-free probe project left the directory empty and the
check fired, and ric-plt-xapp-frame-py yields its 18 dependencies
with no ricxappframe artefact. Record that in the step, so the
behaviour it relies on is stated where it is relied on.

Co-authored-by: Claude <[email protected]>
Signed-off-by: Matthew Watkins <[email protected]>
Copilot AI review requested due to automatic review settings September 23, 2026 11:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation, validation harness, integration coverage, and caller documentation are internally consistent with no unresolved defects identified.

Review effort: Balanced
Findings: None

Resolved since last review (2)

@tykeal
tykeal merged commit 76ea523 into lfreleng-actions:main Sep 23, 2026
11 checks passed
ModeSevenIndustrialSolutions added a commit to modeseven-lfreleng-actions/security-workflows that referenced this pull request Sep 23, 2026
Break-point review of the repository against docs/BRIEF.md, taken
after PR lfreleng-actions#113 merged, with v0.8.0 the latest release. Revises the
first review, written after PR lfreleng-actions#38 and v0.3.0, against what the cycle
since then delivered.

Records seventeen issues closed across ten releases, and the four
places the previous plan was wrong: lfreleng-actions#43 closed the opposite way,
because build metadata was the defect D21 records; lfreleng-actions#41 was never
blocked, since the policy-opa-pdp cutover had already happened; lfreleng-actions#59
and lfreleng-actions#60 closed as evidence-backed decisions rather than features; and
lfreleng-actions#42's consumer gate passed, with three O-RAN-SC projects found.

Adds an estate adoption survey: 55 repositories across ONAP and
OpenDaylight call the lanes, 21 calls still pinned to v0.3.0, and no
O-RAN-SC callers yet.

Reports honestly that neither course correction the first review
raised was acted on: inline shell in the CLM lane grew from 127 to 323
lines, and the build-scan artefact interface is unstarted.

Leads the remaining work with proving what already shipped:
testing.yaml has run six times, all in July, and the fixture
applications on the Nexus IQ server hold no reports. Then the v0.9.0
release carrying the Python build type, the v0.3.0 callers, O-RAN-SC
onboarding, and the SBOM transport still blocked on lfreleng-actions#39.

Extends the write-good exclusion to the new document, matching the
existing BRIEF.md exemption for design-decisions records.

Co-authored-by: Claude <[email protected]>
Signed-off-by: Matthew Watkins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No fixture exercises prescan_script_path or its containment check Add a Python build_type to the Sonatype Lifecycle lane

3 participants