Repository navigation
Feat: Add the linting-verify reusable workflow - #125
ModeSevenIndustrialSolutions merged 5 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical issues could allow hooks to run without egress enforcement, poison trusted caches, or produce a vote without checking the intended patchset.
7 open issues
Fail closed if the harden-runner agent did not start · New Reject Gerrit patchset dispatches without a refspec · New Disable hook caches for untrusted GitHub refs · New Add the validated Gerrit endpoint to the egress allow-list · New Pass Gerrit host and port separately to the visibility check · New Derive the Gerrit vote from resolved job results · New Preserve non-lint jobs and vote dependencies in caller workflows · New
What changed in this PR
Adds a reusable workflow for linting Gerrit patchsets, complementing linting.yaml’s post-merge checks and replacing the legacy per-patchset linting workflow.
Changes:
- Adds Gerrit-aware checkout, input validation, credential removal and hardened hook execution.
- Adds a self-test caller, fixture coverage and shared-script drift checks.
- Provides a Gerrit voting example and migration guidance, and guards
linting.yamlagainst patchset dispatches.
| File | Description |
|---|---|
tests/test-linting-verify-plan.sh |
Tests validation, workflow structure and the patchset guard. |
tests/test-ci-management-verify-plan.sh |
Extends shared-script drift checks to linting verify. |
tests/fixtures/linting-verify/.pre-commit-config.yaml |
Defines hooks for the self-test caller. |
README.md |
Introduces linting verify and distinguishes Gerrit usage models. |
examples/linting-verify/gerrit-linting-verify.yaml |
Demonstrates visibility checks, linting and Gerrit voting. |
docs/linting.md |
Corrects per-patchset migration advice. |
docs/linting-verify.md |
Documents inputs, security, testing and migration. |
.pre-commit-config.yaml |
Registers fixtures and extends drift-check triggers. |
.github/zizmor.yml |
Adds scoped suppressions for the example. |
.github/workflows/linting.yaml |
Rejects per-patchset Gerrit dispatches. |
.github/workflows/linting-verify.yaml |
Implements the reusable patchset linting workflow. |
.github/workflows/linting-verify-action.yaml |
Exercises the reusable workflow on pull requests. |
.github/actionlint.yaml |
Adds the self-caller reference suppression. |
Review effort: Balanced
61f2771 to
08ca612
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A miswired Gerrit refspec can produce a green vote for the wrong tree, and the custom-image gate can run hooks without verifying that the requested security policy was applied.
7 open issues
Reject refspecs that do not match the dispatched patchset · New Fail closed unless the custom image proves policy was applied · New Pass the Gerrit endpoint through loader DNS validation · New Allow Gerrit fallback when the mirror lacks the target ref · New Avoid changing Code-Review votes on cancellation and reruns · New Preserve actionlint checks when migrating skip lists · New Preserve callers’ Gerrit inputs and job dependencies · New
Review effort: Balanced
08ca612 to
696c02d
Compare
696c02d to
e5dd426
Compare
e5dd426 to
41ca613
Compare
41ca613 to
8e3000a
Compare
8e3000a to
9a65442
Compare
7967956 to
058a89d
Compare
058a89d to
d3a4996
Compare
Add linting-verify.yaml, which lints a Gerrit change per patchset and replaces compose-repo-linting.yaml in lfit/releng-reusable-workflows. linting.yaml cannot serve that caller: gerrit_to_platform dispatches on the target branch, so a plain checkout lints the branch tip rather than the change. The workflow is ci-management-verify.yaml's Lint job without the JJB leg: a 'gerrit' job resolving the ref, a 'plan' job validating path_prefix, skip_hooks and the hardening inputs, and a 'Lint' job that checks the change out, removes the persisted checkout token and runs every pre-commit-stage hook but those in skip_hooks; commit-msg hooks such as gitlint do not run, as in the legacy workflow. Every job runs behind harden-runner v2.22.3 in block mode by default. The Lint job fails before it checks anything out unless harden-runner's agent is running: the step succeeds with no agent when the agent times out or the repository sets the skip-harden-runner property, and the hooks would then run with no egress enforcement. The check is linting.yaml's harden_check region, byte for byte, all of it applying here: the agent wait, the verdict (on an ephemeral GitHub-hosted runner the status file can only come from this job's pre-step, so it is evidence; a self-hosted runner's is not) and the gate. The gate is told the event is untrusted, since every hook here is code under review, so an unmonitored runner fails under 'audit' too. The plan refuses a 'patchset-created' or 'comment-added' dispatch that passes no gerrit_refspec, read from the caller's event through 'env': it would otherwise select GitHub mode and lint the branch tip. 'change-merged' and ordinary GitHub events keep GitHub mode. The hooks' caches stay off in both modes, not only Gerrit mode: a 'ref' naming an unmerged branch or a pull_request_target caller's contributor SHA also runs untrusted hooks in a scope trusted runs may share. The 'gerrit' job outputs the endpoint it validated, and the Lint job merges it into the block-action's extra_endpoints ahead of the caller's own, so the Gerrit checkout's HTTPS fallback is allowed and the loader's DNS check and invalid_records policy cover the endpoint. It goes first because the loader strips a '#' comment to the end of its line: a caller's value ending in one would swallow an endpoint appended after it. Added to harden-runner's allowed-endpoints directly, as change-isolation.yaml does, it skipped both, and one unresolvable host there makes the agent drop the whole policy. tests/test-harden-runner-inputs.sh accepts that one second form of extra_endpoints, one job output followed by the caller's input, and gains mutants for the forms it must still refuse, the reverse order among them. A gerrit_refspec must be a change ref, refs/changes/NN/<n>/<ps>, whose two-digit part is the change number's last two digits, zero padded, and must equal the GERRIT_REFSPEC the dispatch carried, when it carried one. After the Gerrit checkout, HEAD must equal the dispatch's GERRIT_PATCHSET_REVISION, when it carried one. A refspec naming a branch, or another patchset, would otherwise be linted and voted on as the change. An empty gerrit_refspec stays GitHub mode, which the patchset-created rule already governs, so a change-merged caller keeps working. tests/test-ci-management-verify-plan.sh now holds this workflow's copies of the Gerrit script and the credential removal to the same drift check as its siblings, and its harden-runner check to linting.yaml's. tests/test-linting-verify-plan.sh exercises the plan, most cases rejections, the dispatch rule, the harden-runner check against a scratch agent directory, and the workflow's structure; a new prek hook runs it. It also runs the refspec checks, the revision check against a throwaway repository, and the endpoint wiring check against mutated copies of the workflow. It renders the extra_endpoints format() for caller values ending in a '#' comment and strips comments with a copy of the loader's comment regex, then expects the Gerrit endpoint to survive; the loader itself does not run here. A copy with the old order fails both checks. Review round 1 findings fixed here: the fail-open harden-runner step, the missing-refspec patchset dispatch, the GitHub-mode hook caches and the Gerrit endpoint missing from the allow-list. Review round 2 findings fixed here: the miswired refspec (shape, dispatch match and revision checks) and the Gerrit endpoint bypassing the loader's DNS check. Not changed, at the maintainer's direction: on a custom VM image, STEP_SECURITY_HARDEN_RUNNER=true passes the agent check even when skip-harden-runner kept the allow-list from the agent. The check is held byte-identical to linting.yaml's harden_check, and the sibling workflows share it, so the fix is one family-wide follow-up. Review round 3 findings fixed here: the Gerrit endpoint, appended after the caller's extra_endpoints, could be stripped by a trailing '#' comment in the caller's value; it now goes first, as the maintainer directed, and the fixtures cover a trailing comment. The header, skip_hooks description and linting step comment now say the job runs every pre-commit-stage hook: standalone-linting-action runs commit-msg hooks only given a commit_range, which this workflow does not pass. Review round 4 findings fixed here: - The caller's vote could name another patchset than the one linted: the example votes on the dispatch's GERRIT_CHANGE_NUMBER and GERRIT_PATCHSET_NUMBER, which the refspec checks never compared. The plan now reads both from github.event.inputs and refuses a gerrit_refspec whose change or patchset differs from them, compared as digit strings so a leading zero is a mismatch; an empty dispatch value skips its comparison, for a hybrid caller. Fixtures cover the mismatches, zero-padded values, a match and each empty value, and four mutants of the comparisons, dropped or made zero-tolerant. - standalone-linting-action's node_setup default, 'auto', runs a frozen dependency install from a package.json and lockfile the change controls, which the legacy workflow never did. The linting step passes node_setup: 'false', with no input to change it; a fixture and three mutants (dropped, 'auto', a second line) hold it. Review round 5 finding fixed here: standalone-linting-action's rust_toolchain_setup default, 'auto', prepares a Rust toolchain with rustfmt and clippy whenever a tracked Cargo.toml lies under path_prefix, which the change controls and the legacy workflow never did; an unavailable toolchain or component would fail the run before any hook. The linting step passes rust_toolchain_setup: 'false', with no input to change it, and the comment beside cache_hooks names both it and node_setup. It and node_setup are the action's only inputs defaulting to 'auto'. The node_setup fixture now covers both inputs, each with the same three mutants (dropped, 'auto', a second line). Review round 6 finding fixed here: gerrit_to_platform also dispatches 'comment-added' events (rechecks and gha-<action> commands) on the target branch, and check_dispatch refused only 'patchset-created', so a caller passing no gerrit_refspec linted the branch tip on a recheck. It now refuses either event type, by exact, case-sensitive match, and the error names both. Fixtures cover comment-added with and without a refspec, and change-merged, comment-added-extra, Comment-Added and Patchset-Created passing; four mutants (either event dropped, a prefix match, a case-insensitive match) must each fail them, and a mutant that is not valid Python counts as a fixture failure. Review round 8 finding fixed here, in the input description alone: the ref input said an empty value checks out the triggering commit, which actions/checkout does only for the calling repository; for a different repository input it resolves that repository's default branch. The description now says so and tells a cross-repository caller to pass the ref it intends. No behaviour changes. Review round 9 finding fixed here, in comments alone, at the maintainer's direction: the header said the Lint job receives no token, and the credential-removal step's comment said the token goes before the hooks start, yet the checkout's token still reaches its post-job cleanup, where a hook can capture it. Both now say no Git credential is persisted (the GitHub checkout stores none, the Gerrit checkout's stored token is removed first) and that the token still reaches the post-job cleanup, pointing to "Residual exposure" in docs/linting-verify.md. No behaviour changes. Review round 10 finding fixed here, at the maintainer's direction: the pinned standalone-linting-action passes <path_prefix>/.pre-commit-config.yaml to prek explicitly, while prek's own discovery ranks prek.toml above it, so a change adding a prek.toml beside the YAML was linted against a configuration the repository has superseded, and could still earn a positive vote. A new Lint job step, 'Refuse a prek.toml configuration', runs in both modes after both checkouts and the credential removal and before the linting step. It fails, with fixed text naming the fix and no value echoed, when <path_prefix>/prek.toml exists or is a symlink, dangling included; path_prefix arrives through env, '.' is the root. The fixtures extract the script and run it against throwaway trees: prek.toml at the root and under a path_prefix subdirectory, and a dangling symlink at either, are refused; a prek.toml in another directory, and none, pass. Six mutants (either test dropped, path_prefix ignored, a whole-tree search, refusing everything, not exiting) must each fail them. Further fixtures require the step between the checkouts and credential removal and the linting step, with no 'if:', reading path_prefix through env. linting.yaml is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
Call linting-verify.yaml on this repository's own pull requests, in block mode, against a small fixture whose hooks come from GitHub and PyPI alone. The run skips check-json and an always-failing local trap hook through skip_hooks, so it fails if the input stops reaching the hook executor, and runs the actionlint hook migrating consumers are asked to add. A pull request cannot dispatch Gerrit mode, so that path stays with the offline fixtures. actionlint does not know the '$/' self-repository form yet, so the new caller gets its own line-scoped ignore, as its siblings do. Review round 3 finding fixed here: skipping check-json could not show that skip_hooks reaches the executor, since check-json also passes when it runs. The fixture gains linting-verify-self-test-trap, a local hook that exits 1 when GITHUB_WORKFLOW_REF names linting-verify-action.yaml, which in a called workflow is the caller's, and the self-test skips it. Checked locally with prek 0.4.10 against the fixture configuration: with GITHUB_WORKFLOW_REF set to o/r/.github/workflows/linting-verify-action.yaml@refs/pull/1/merge the trap fails unless skipped, and the run passes with it skipped; with the variable unset, or naming another workflow, the trap passes. prek run --all-files at the repository root still passes; prek 0.4.10 did not pick the fixture up as a nested project there, and where an older prek does, the variable is unset or names another workflow, so the trap passes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
Add examples/linting-verify/gerrit-linting-verify.yaml, built from
the ci-management verify example: a visibility gate, a vote clear,
the reusable call and a Verified vote, with the Gerrit-talking jobs
in block mode. It uses the variable and secret names the existing
compose-repo-linting callers set, notes the LFIT_GERRIT_* names the
lfit repositories use, and explains how to report without voting.
The vote is derived from the 'needs' results, not from
im-open/workflow-conclusion: that action reads the jobs API, which
can still list finished jobs as running, then reports 'skipped',
which gerrit-review-action rejects, as onap/.github's caller records.
The rule: success only when every result is success, and failure
otherwise, so a skipped job never earns a positive vote. GitHub
expressions have no all(), so "every result is success" is written
as no failure, no cancelled and no skipped: GitHub documents exactly
four job results, so that leaves only success. This was chosen over
counting with join() or fromJSON(), which the expression language
cannot do for a list of unknown length. The 'vote' job no longer
needs 'actions: read'.
tests/test-linting-verify-plan.sh evaluates the example's own
vote-type line, through a small evaluator of the operators it uses,
over every combination of results for one, two and three needs and
for a caller keeping a fourth, against the rule written longhand,
and checks that six wrong rules fail it. It tests the logic, not
GitHub's evaluator; ONAP's form as written fails it on the
combinations where a dependency was skipped.
The header no longer tells a consumer to copy the file over an
existing caller, which would delete its other verification jobs: a
caller with other jobs replaces its lint job alone and keeps the
others in the vote's needs. It also states that
gerrit-change-visible-action v0.0.2 takes a bare host and a separate
port, unlike gerrit-review-action, and how a caller with a
non-default port splits it for the visibility step.
The file name keeps 'gerrit' and 'verify' and avoids 'required', so
gerrit_to_platform dispatches it per patchset. Its placeholder pin
and secret references get line-scoped zizmor ignores under a
basename no other example uses, moved with the lines this round.
Review round 1 findings fixed here: the vote derived from the jobs
API, the host:port mismatch, and the copy-over instruction.
Review round 2 findings addressed here, in comments alone: the header
says a caller replacing its lint job keeps the job ID, needs,
conditions and Gerrit value sources, passing
needs.<job>.outputs.GERRIT_* where a job such as
call-gerrit-change-info derives them (opendaylight/docs and
opendaylight/gnmi); the skip_hooks comment says to remove actionlint
from a carried-over list. (A caveat added then about cancelled votes
went in round 5, with its cause.) The zizmor line ignores follow the
shifted lines.
Review round 3 finding addressed here, in comments alone: the header
and the skip_hooks comment say the Lint job runs every
pre-commit-stage hook, and that commit-msg hooks such as gitlint do
not run, as in the legacy workflow. The line count is unchanged, so
the zizmor line ignores still hold.
Review round 4 finding addressed here, in the header alone: the votes
name the change and patchset from the same dispatch inputs that the
reusable now checks its refspec against, so the lint and the vote
name one patchset. The vote steps are unchanged; the zizmor line
ignores follow the three added lines.
Review round 5 finding fixed here: the vote job ran under always(),
which keeps a job running after its workflow is cancelled. A run
superseded by a recheck of the same patchset (the concurrency group
is per change, with cancel-in-progress) could still vote, after the
newer run's 'prepare' had cleared, and overwrite the newer result:
a stale success or failure, or a cancelled vote that left
Code-Review=-1. The condition is now !cancelled() && visible, so a
failed 'prepare' or 'linting-verify' still reaches the vote and votes
failure, while a cancelled run casts no vote and the clear stands.
The vote rule drops its cancelled branch, which this example never
casts, and keeps its strictness. The vote comment's cancelled-vote
caveat becomes one sentence: a cancelled run casts no vote, so a
recheck leaves nothing stale; rerun the whole workflow to vote
again. A fixture asserts the vote job's only 'if' is the !cancelled()
condition and that the job calls no always(), and four mutants
(always(), the guard dropped, both, cancelled() unnegated) fail it.
The zizmor ignore for the vote job's secret follows its line.
The tox-verify, ci-management and change-isolation examples share
the always() pattern and are left unchanged here; they get one
follow-up change after this merges.
Review round 6 findings addressed here, in the header alone:
- The header says linting.yaml refuses a 'comment-added' dispatch
too, since rechecks arrive on the branch as well.
- The actionlint note says this workflow installs no actionlint
executable: add the self-installing actionlint-py hook, replacing a
'language: system' one (rhysd/actionlint v1.6.24, as FDio/.github
and onap/.github define it, or actionlint-system), or set runs_on
to an image that provides the executable. A step in the calling
job cannot provision it: the reusable's job has its own runner.
The zizmor line ignores follow the five added lines.
Review round 7 findings fixed here, at the maintainer's direction:
- The concurrency group was per change, so a recheck naming an older
patchset (gerrit_to_platform dispatches the patchset the comment
names) cancelled a running verification of a newer one and left it
unchecked. It was also keyed by Change-Id and branch, which GitHub
compares case-insensitively, so cherry-picks to 'main' and 'Main'
cancelled each other. The group is now the workflow, the change
number (or the run ID when that is empty) and the patchset number:
digits, unique within a Gerrit server, one group per patchset, and
a repeat dispatch for one patchset still cancels the run in flight.
The comment above it says why, that the project is no longer
needed, and that a central '.github' repository serving more than
one Gerrit server must add the server to the key.
- tests/test-linting-verify-plan.sh renders the group through the
vote rule's evaluator, now a shared library, and checks that two
patchsets differ, a recheck of one matches, two changes, the
cherry-picks and two workflows differ, the project, branch and
Change-Id do not matter, and an empty or missing change number
falls back to the run ID, all compared case-insensitively. Seven
mutants of the key must each fail it.
The tox-verify, ci-management and change-isolation examples share the
per-change key and are left unchanged here; the same fix is tracked as
one follow-up across them. The zizmor line ignores follow the nine
added lines.
Review round 10 finding fixed here, in comments alone, at the
maintainer's direction: the header told lfit repositories to
substitute their LFIT_GERRIT_* names throughout, but the example
passes no gerrit_url and the reusable's fallback reads only
vars.GERRIT_URL, so a caller keeping its URL solely under an
LFIT_GERRIT_* name failed endpoint resolution before linting. The
header and the comment in the linting-verify job's with: block now
tell those callers to pass gerrit_url: ${{ vars.LFIT_GERRIT_URL }}
(the variable name their repository uses) explicitly; the with:
block carries that line, commented out. The zizmor line ignores
follow the eight added lines.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
Add docs/linting-verify.md: the job graph, inputs, credential
handling, egress, testing and migration from compose-repo-linting,
including the actionlint hook the 20 callers without one must add
before they migrate, and the changed skip_hooks default.
The migration section tells a consumer to replace its lint job and
nothing else. Measured on 2026-11-03, 7 of the 30 callers run
linting alone and may adopt the example's job graph whole; 23 run
other verification jobs beside it, which copying the example over
the caller would delete while the vote stayed green. Those replace
the compose-repo-linting job alone and keep every other job in the
vote's needs, and the needs-derived vote rule counts them all.
The page also describes this round's workflow changes: the
harden-runner agent check, the refused patchset dispatch without a
refspec, the hook caches off in both modes, and the Gerrit endpoint
on the Lint job's allow-list.
Correct docs/linting.md, which told a Gerrit-mirrored project to
migrate to linting.yaml wholesale. That holds for the post-merge
push model and a change-merged dispatch, but a per-patchset caller
is dispatched on the target branch, so linting.yaml would lint the
branch tip rather than the change. Such callers use linting-verify.
The README gains a linting verify section and lists the workflow in
the egress, caller filename and Gerrit support sections.
Review round 1 finding fixed here: the copy-over migration
instruction.
Review round 2 findings addressed here: a Gerrit mode section
documents the refspec shape, dispatch-match and revision checks, and
that the checkout seeds from the target branch on the GitHub mirror,
so an unreplicated branch fails at that step; the egress section
describes the endpoint merged through the loader's extra_endpoints,
and the README the drift check's second accepted form; the migration
says to keep the replaced job's ID, needs, conditions and Gerrit value
sources, naming the two hybrid callers measured, and to remove
actionlint from a carried-over skip list. (A caveat added then about
cancelled votes went in round 5, with its cause.)
Review round 3 findings addressed here, in documentation alone:
- The pages said the Lint job runs every hook. They now say every
pre-commit-stage hook, and docs/linting-verify.md adds that
commit-msg hooks such as gitlint do not run, as in the legacy
workflow, so a repository wanting them keeps a separate job.
- The egress section and the README's drift-check paragraph describe
the Gerrit endpoint going first in extra_endpoints, so a '#'
comment ending the caller's value cannot strip it; the testing
section names the trailing-comment fixture.
- The testing section describes the self-test's trap hook, which
fails unless skip_hooks reaches the executor.
- docs/linting.md, docs/linting-verify.md and the README's Gerrit
support paragraph no longer call a change-merged dispatch the
branch tip: a push trigger on the mirror is the recommended
post-merge model, and a change-merged caller must not dispatch
until it has confirmed replication, linking ci-management merge's
ancestry check.
- docs/linting.md's migration section tells a migrator to remove
actionlint from a carried-over skip list and to add the
actionlint-py hook where absent, pointing to the linting verify
migration; its example no longer carries actionlint.
Review round 4 findings addressed here: the Gerrit mode section
describes the change and patchset number checks; the behaviour that
changes on migration says the workflow installs no Node.js
dependencies, as the legacy workflow installed none, so a hook that
needs them installs its own environment through prek or stays in a
separate job; the job graph and testing sections name node_setup and
the new fixtures.
Review round 5 findings addressed here:
- The migration's vote rule is the example's new one, success only
when every result in needs is success, with no cancelled branch.
The paragraph on cancelled votes setting Code-Review=-1 is gone:
the example's vote job now runs on !cancelled() rather than
always(), so a failed job still votes failure and a cancelled run
casts no vote, the prepare job's clear standing, and one sentence
says so. The testing section names the vote condition fixture and
the vote rule's mutants.
- The behaviour that changes on migration says no Rust toolchain is
set up either, as the legacy workflow set up none: the linting
step passes rust_toolchain_setup: 'false' beside node_setup, so a
hook needing either installs its own environment through prek or
keeps a separate job. The job graph and testing sections name the
setting and its fixture. No opt-out is described.
Review round 6 findings addressed here:
- The reusable's dispatch rule is documented as refusing a
'comment-added' dispatch with no gerrit_refspec as well as a
'patchset-created' one, by exact, case-sensitive match, because
rechecks also arrive on the target branch; the testing section
lists the new cases and mutants.
- The actionlint migration no longer says the other 10 callers
define the hook already. Measured on 2026-11-03, 8 define one that
installs itself (actionlint-py, or rhysd/actionlint as language:
golang) and 2, FDio/.github and onap/.github, define
rhysd/actionlint v1.6.24 as language: system, which needs an
executable this workflow does not install. Consumers replace a
system hook (or actionlint-system) with actionlint-py, or run on a
runner image that already provides the executable: a step in the
calling job cannot, since the Lint job has its own runner. Their
pre-commit.ci skip entry may stay. actionlint-py is recommended
over a golang hook, which needs its toolchain and module hosts
allowed and has not been run here. The migration table,
docs/linting.md and the README say the same; the 20 of 30 count
is unchanged.
Review round 7 findings addressed here, at the maintainer's direction:
- A "Residual exposure" subsection under the credentials section says
plainly that the hooks run in the job that did the checkout, so a
hook can put its own git on PATH through $GITHUB_PATH and capture
the token the checkout's post-job cleanup receives; that the
exposure is not closed; that the job's GITHUB_TOKEN carries
contents: read alone, so secrets.token should be no wider than
reading the mirror; and that separating checkout from hook
execution is a follow-up across the verify workflows. The workflow
is unchanged.
- The job graph section describes the example's per-patchset
concurrency group and says a central '.github' repository serving
more than one Gerrit server must add the server to the key; the
migration says to take it over a per-change group; the testing
section lists the group fixture and its mutants.
Review round 8 findings addressed here, in documentation alone, at
the maintainer's direction:
- The vote section adds that each patchset has its own run, prepare
clear and vote, and that a Verified label with a copyCondition
accepts an older patchset's vote on a newer one whenever Gerrit's
condition holds, including from an older run finishing after the
newer patchset's clear; a project wanting Verified to reflect the
current patchset's lint alone must not copy Verified votes. No
workflow or vote change, and no server-side option is described.
- The inputs table's ref row gives the empty default as the
triggering commit for the calling repository alone, and the target
repository's default branch otherwise, matching the workflow's
input description.
- docs/linting.md no longer says the post-merge migration matches the
legacy behaviour with no inputs at all: linting.yaml's node_setup
and rust_toolchain_setup default to 'auto'. It shows the with:
block setting both to 'false' for a repository holding a
package.json and lockfile or a Cargo.toml, says the preparation
otherwise fails the run on a stale lockfile or an unavailable
toolchain, and limits "no with: block" to a repository with
neither manifest. The README's linting section says the same
briefly. linting.yaml's defaults are unchanged.
Review round 9 finding fixed here, in wording alone, at the
maintainer's direction: "Credentials go first" said no token remains
after the GitHub checkout, contradicting its own Residual exposure
subsection. It now says the checkout persists no Git credential,
that no Git credential may stay persisted where the hooks could read
it, and that in both modes the checkout's token still reaches its
post-job cleanup, linking to Residual exposure, which is unchanged.
Review round 10 findings addressed here, in documentation alone, at
the maintainer's direction:
- The job graph says the Lint job refuses a prek.toml at path_prefix,
and the behaviour that changes on migration explains why: this
workflow runs the .pre-commit-config.yaml alone, prek prefers
prek.toml, the legacy workflow ran pre-commit, which ignores it,
and linting.yaml refuses it too. The testing section lists the
refusal's fixtures, its six mutants and its placement check.
- Next to the LFIT_GERRIT_* substitution note, the migration tells
those callers to pass gerrit_url: ${{ vars.LFIT_GERRIT_URL }} (the
variable name their repository uses) under the linting-verify
job's with:, because the reusable's fallback reads only
vars.GERRIT_URL.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
linting.yaml checks out the triggering commit. gerrit_to_platform dispatches on the target branch, so a caller dispatched for a new patchset, or for a recheck of one, would lint the branch tip, not the change, and could report green having never seen it. The old migration notes invited exactly that caller. The plan job's guard step now reads the caller's GERRIT_EVENT_TYPE input through 'env' and fails a workflow_dispatch carrying 'patchset-created' or 'comment-added', matched in full and case-sensitively, naming linting-verify.yaml. A 'change-merged' dispatch, and push, pull request and schedule callers, are unaffected. A change-merged dispatch can still arrive before the mirror replicates the merge; the guard's comment points to docs/linting.md, which says to dispatch only after replication. tests/test-linting-verify-plan.sh extracts the guard and feeds it both refused event types, change-merged, near misses in suffix and case, an empty and a missing value and the other events; five mutants of the guard must each fail those cases. Its prek hook now also runs when linting.yaml changes. Review round 6 finding fixed here: gerrit_to_platform also dispatches 'comment-added' events (rechecks and gha-<action> commands) on the target branch, and the guard refused only 'patchset-created'. It now refuses both, and its error names both event types. The fixtures add comment-added (refused), comment-added-extra and Comment-Added (passed), and a push carrying an event type (passed); the mutants drop either event type, loosen the match to a prefix, make it case-insensitive or drop the workflow_dispatch condition. The guard's comment, docs/linting.md, docs/linting-verify.md and the README's Gerrit support section say both events, and why. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
d3a4996 to
dc43c7b
Compare
|
No other changes. |
53acd2a
into
lfreleng-actions:main



Closes #124
Authored by an AI agent; human review required
claude-opus-5.5via GitHub Copilot CLI377efe6d5192202c709b29fd9d7f4f11e3d325bdbash tests/test-linting-verify-plan.shbash tests/test-ci-management-verify-plan.shbash tests/test-harden-runner-inputs.shfor each commit in 377efe6..HEAD: bash tests/test-linting-verify-plan.sh && bash tests/test-ci-management-verify-plan.sh && bash tests/test-harden-runner-inputs.shprek run --files $(git diff --name-only 377efe6d5192202c709b29fd9d7f4f11e3d325bd HEAD)prek run --files docs/linting-verify.mdaislop scan --changes --base 377efe6d5192202c709b29fd9d7f4f11e3d325bd --json (0 diagnostics; 0 files scanned)prek run gitlint --hook-stage commit-msg (amended messages; flags only the inherited bot Signed-off-by line length)git log --raw --format=%h 377efe6d5192202c709b29fd9d7f4f11e3d325bd..HEAD (no 100755/120000/160000, no mode change)The
github-code-monkey-botworkflow opened this pull request.Nobody has merged it; a maintainer must review it first.
Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds; a maintainer must act on any finding that remains after that, and reviews every round before merge.
Round 10 of revision, on its base.
What this pull request does
Adds
.github/workflows/linting-verify.yaml, a reusable workflow that lints a Gerrit change per patchset. It replacescompose-repo-linting.yamlinlfit/releng-reusable-workflows(#124). It also stopslinting.yamlfrom being used for that job:linting.yamllints the branch tip on a Gerrit dispatch, not the change.Five commits:
Feat: Add the linting-verify reusable workflow: jobs
[gerrit] -> plan -> Lint. TheLintjob checks:prek.tomlsits atpath_prefix(new this round).It then runs
standalone-linting-actionwith hook caches, Node and Rust setup turned off. The fixtures are intests/test-linting-verify-plan.sh, and the drift checks are extended intests/test-ci-management-verify-plan.sh.CI: Add the linting-verify self-test caller:
linting-verify-action.yaml, block mode, againsttests/fixtures/linting-verify/.Docs: Add the Gerrit linting-verify example caller:
examples/linting-verify/gerrit-linting-verify.yaml, withvisibility,prepare,linting-verifyandvotejobs, plus line-scoped zizmor ignores.Docs: Describe linting-verify and its migration:
docs/linting-verify.md, the correcteddocs/linting.mdmigration section and README sections.Fix: Refuse a per-patchset Gerrit dispatch in lint:
linting.yaml's plan guard refuses apatchset-createdorcomment-addeddispatch and names this workflow. The guard sits outside the regions the executable test scripts extract.Changed in review round 10
prek.toml: prek prefersprek.toml, but the linting action passes the YAML explicitly, so a change could add aprek.tomland still be linted, and voted on, against the superseded YAML.Lintstep,Refuse a prek.toml configuration, runs in both modes. It sits after the checkouts and the credential removal, and before the hooks.<path_prefix>/prek.tomlexists or is a symlink, including a dangling one. The error text is fixed and echoes no value.linting.yamlis unchanged.with:comment and the migration docs now telllfitcallers to passgerrit_url: ${{ vars.LFIT_GERRIT_URL }}explicitly, because the reusable falls back tovars.GERRIT_URLonly. Wording only. The zizmor line ignores moved with the shifted lines.What was run
prek run --files <every file the PR changes>: passed. This includes actionlint, offline zizmor, yamllint, shellcheck, markdownlint, write-good and the fixture hooks.bash tests/test-linting-verify-plan.sh: 202 fixtures passed, and it passes at every commit.bash tests/test-ci-management-verify-plan.sh(73 fixtures) andbash tests/test-harden-runner-inputs.sh: both passed.Signed-off-bytrailer, which the publisher replaces.What a reviewer should still look at
gerrit_to_platformdispatch of thelinting.yamlguard;github.event.inputsto a called workflow.zizmor --persona auditorrun was blocked in this environment. Only the prek zizmor hook ran.