Skip to content

CI: Exercise live Gerrit transfer and REST auth - #525

Merged
ModeSevenIndustrialSolutions merged 2 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-524
Nov 2, 2026
Merged

ModeSevenIndustrialSolutions merged 2 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-524

Conversation

@lf-releng-code-monkey-bot

@lf-releng-code-monkey-bot lf-releng-code-monkey-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #524

Authored by an AI agent; human review required
Command Exit
uv run pytest -q --no-cov tests/test_testing_workflow.py 0
prek run --files .github/workflows/testing.yaml tests/test_testing_workflow.py 0
uvx zizmor --persona auditor .github/workflows/ 0
git log --raw --format=%h 03c617aa6ef9f5075f9a357590f11c0853271446..HEAD 0

The github-code-monkey-bot workflow 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 1 of revision, on its base.


Fixes #524.

The Gerrit integration job in testing.yaml passed on every push to main without transferring anything, and failed on every dispatch. This PR makes it exercise a live transfer and authenticated Gerrit REST on both events.

Commits

  1. Test: Add expected-fail live Gerrit job tests adds tests/test_testing_workflow.py, which runs the job's step scripts out of the workflow with gh, uv and python stubbed. The tests carry strict xfail markers until the workflow change lands.
  2. CI: Exercise live Gerrit transfer and REST auth changes the workflow and removes the markers:
    • GITHUB_EVENT_NAME=workflow_dispatch and an empty GITHUB_EVENT_PATH are set for the CLI process alone, so a push takes the single-PR path rather than the merged-PR cleanup path.
    • An open app/dependabot PR in lfit/sandbox is selected at run time. DEPENDABOT_PR_URL_1/_2 remain as validated optional overrides.
    • GERRIT_HTTP_USER/GERRIT_HTTP_PASSWORD are passed to both Gerrit steps. A missing password fails the step. Any anonymous (auth_user=) line fails the step. The dry run must log Gerrit REST authenticated access verified. The live step must log at least one request line of the form Gerrit REST <METHOD> … (auth_user=<user>).
    • The live step needs both the Successfully pushed changes to Gerrit log line and a sandbox change URL in the CLI's outputs. It writes the URL to the step summary.
    • The duplicate action-integration-test job is removed. The composite action takes its PR from this repository's event, so it cannot target lfit/sandbox.
    • The environment: comment no longer claims that the environment scopes the secrets.

This round

Both Copilot findings were fixed as the maintainer directed:

  • The authenticated-REST check in the live step now matches request lines only, not the GerritRestClient(…, auth_user=…) constructor log.
  • The push check now also requires the post-push log line, because reconciliation can return an existing change's URL without pushing.

Two harness cases were added: a log that holds only the constructor line, and a URL with no push line. Both must fail.

Checks run

  • uv run pytest --no-cov tests/test_testing_workflow.py: 23 passed. On the test commit alone the new cases xfail.
  • prek run --files on the changed files: passed.
  • zizmor --persona auditor .github/workflows/: no findings.

Still to look at

  • Before merge: a maintainer must add GERRIT_HTTP_PASSWORD as a repository secret. Without it, the first push to main fails the new check by design.
  • Possible follow-up: surface SubmissionResult.pushed as a CLI output. That would give the live step a cleaner push signal than a debug log line, but it is a tool change and is left out of this PR.

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.

🟡 Changes recommended

The workflow checks can mistake client-construction logs for authenticated REST requests and an existing Gerrit URL for a completed push, allowing paths that perform neither operation to pass.

2 open issues
What changed in this PR

Updates the CLI integration workflow to exercise sandbox transfers and authenticated Gerrit REST access on both pushes to main and manual runs, addressing #524.

Changes:

  • Selects an open sandbox Dependabot PR, with optional URL overrides, and sets the CLI event context per process.
  • Adds credential checks, REST-log validation, and live change-URL reporting; removes the duplicate action integration job.
  • Adds stub-based workflow tests covering selection, event handling, authentication checks, and output validation.
File Description
tests/​test_testing_workflow.py Adds regression tests for the integration step scripts and workflow configuration.
.github/​workflows/​testing.yaml Updates sandbox selection, CLI invocation, REST checks, and live-result reporting.

Review effort: Balanced

Comment thread .github/workflows/testing.yaml Resolved
Comment thread .github/workflows/testing.yaml Resolved
lf-releng-code-monkey-bot Bot and others added 2 commits November 2, 2026 16:36
The CLI integration job in testing.yaml runs only on a push to main
or a dispatch, so a pull request never shows whether it still
exercises anything. On a push it took the merged-PR cleanup path,
because a step's env: cannot override GITHUB_EVENT_NAME; on a
dispatch it failed on fixture pull requests closed long ago; and
every Gerrit REST call it made was anonymous.

These tests run the job's step scripts out of the workflow under
stubbed gh, uv and python, and pin what each step should accept as a
pass: the CLI runs as a dispatch on a push, an open Dependabot pull
request is selected at run time, a missing HTTP password or an
anonymous REST call fails, and the live step names a change URL.
The live step must also fail on a log whose only auth_user line is
the REST client's constructor, logged before any request, and on a
change URL without the push line, since reconciliation can return
an existing change's URL without pushing.
They are marked strict xfail until the workflow change lands.

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>
The Gerrit integration jobs passed on every push to main without
transferring anything. A step's env: cannot override the runner's
GITHUB_EVENT_NAME, so on a push the CLI saw a push event and took the
merged-PR cleanup path. On a dispatch both jobs failed at once,
because the fixture pull requests they named were long closed. No
Gerrit HTTP credentials were set, so every REST call was anonymous
and the authenticated path lfreleng-actions#513 changed went untested.

The CLI job now:

- sets GITHUB_EVENT_NAME and GITHUB_EVENT_PATH for the CLI process
  alone, so a push runs the same single-PR path as a dispatch; the
  expected-failure step moves its override the same way, and the
  other runner defaults the steps restated are dropped
- selects an open app/dependabot pull request in lfit/sandbox at run
  time, keeping DEPENDABOT_PR_URL_1 and _2 as optional overrides,
  and fails naming the problem when none is open
- passes GERRIT_HTTP_USER and GERRIT_HTTP_PASSWORD to both Gerrit
  steps, fails when the password is missing, and fails when the log
  shows an anonymous REST call or, in dry-run, no verified
  authentication
- checks that the live push reported a sandbox change URL instead of
  printing a fixed success line

The action integration job is removed. It ran the same CLI commands
as the CLI job, and the composite action cannot stand in for them:
it takes its pull request from this repository's event and
github.token, so it cannot target lfit/sandbox. The reusable workflow
and action jobs keep covering the action under G2G_NO_GERRIT.

Review of lfreleng-actions#525 found two ways the live step could pass without the
operation it checks:

- Its authenticated-REST check matched any auth_user= line, which
  the REST client's constructor log satisfies before any request.
  It now requires a request line, Gerrit REST <METHOD> ...
  (auth_user=<user>); the anonymous (auth_user=) check is unchanged.
- A change URL in the CLI's outputs does not prove a push:
  reconciliation returns an existing change's URL without pushing.
  The step now also requires the "Successfully pushed changes to
  Gerrit" log line, which G2G_VERBOSE makes visible.

The environment comment no longer claims to scope the secrets, which
are repository secrets.

GERRIT_HTTP_PASSWORD must exist as a repository secret before this
merges, or the first push to main fails the new check by design.

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>

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.

🔵 Needs a closer look

A maintainer must provision GERRIT_HTTP_PASSWORD and validate live Gerrit transfers for both push and workflow_dispatch runs, since the stubbed harness cannot verify authentication or server-side success.

No open issues 🎉

Review effort: Balanced

@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions merged commit 51eca1f into lfreleng-actions:main Nov 2, 2026
33 checks passed
@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions deleted the code-monkey/issue-524 branch November 2, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI CI and tests updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gerrit integration jobs test neither a transfer nor authenticated REST

2 participants