Skip to content

Feat: Implement fallback missing change creation#145

Merged
ModeSevenIndustrialSolutions merged 5 commits intolfreleng-actions:mainfrom
modeseven-lfreleng-actions:implement-keyword-comments
Mar 3, 2026
Merged

Feat: Implement fallback missing change creation#145
ModeSevenIndustrialSolutions merged 5 commits intolfreleng-actions:mainfrom
modeseven-lfreleng-actions:implement-keyword-comments

Conversation

@ModeSevenIndustrialSolutions
Copy link
Contributor

Provide fallback mechanisms for when a previous GitHub2Gerrit run failed to create a corresponding Gerrit change. Previously, in this scenario, the tool would attempt to update an existing Gerrit change, fail to find one, and exit with an error.

Out fallback mechanism provides two invocation methods:

  • A new CLI flag/arg --create-missing and action input
  • Commenting on pull requests with @github2gerrit

Adding this line as a comment on a pull request:
@github2gerrit create missing change

...will trigger the creation of a new change, and prevent a failed update call, which would otherwise cause the workflow run to error.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a fallback mechanism that allows GitHub2Gerrit to recover from scenarios where a previous run failed to create a corresponding Gerrit change. Previously, when an opened event failed and subsequent synchronize events tried to update a non-existent change, the tool would exit with an error. The fallback provides two recovery methods: a --create-missing CLI flag/action input and a PR comment command system using @github2gerrit create missing change.

Changes:

  • Introduced an extensible PR command system with a registry-based architecture for parsing @github2gerrit directives from PR comments
  • Added _should_create_missing() and _post_create_missing_notice() methods to the Orchestrator to detect and handle the fallback scenario
  • Modified the execute() method to catch OrchestratorError during UPDATE operations and switch to CREATE mode when authorized via flag or comment

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/github2gerrit/pr_commands.py New module implementing the extensible command parsing system with case-insensitive, alias-aware matching
tests/test_pr_commands.py Comprehensive test suite covering command parsing, orchestrator integration, edge cases, and real-world regression scenarios
src/github2gerrit/core.py Added fallback detection logic in _should_create_missing(), PR notification in _post_create_missing_notice(), and exception handling in execute()
src/github2gerrit/cli.py Added --create-missing CLI option with environment variable support (G2G_CREATE_MISSING)
src/github2gerrit/models.py Added create_missing boolean field to Inputs dataclass
action.yaml Added CREATE_MISSING input for GitHub Actions workflows
README.md Added comprehensive documentation for PR comment commands and the create missing change feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Provide fallback mechanisms for when a previous GitHub2Gerrit run
failed to create a corresponding Gerrit change. Previously, in this
scenario, the tool would attempt to update an existing Gerrit
change, fail to find one, and exit with an error.

Out fallback mechanism provides two invocation methods:
- A new CLI flag/arg --create-missing and action input
- Commenting on pull requests with @github2gerrit

Adding this line as a comment on a pull request:
@github2gerrit create missing change

...will trigger the creation of a new change, and prevent a failed
update call, which would otherwise cause the workflow run to error.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
Replace emoji characters that use variation selectors (U+FE0F) with
single-codepoint alternatives to fix misaligned table borders and
missing spaces in macOS Terminal.app:

- Remove hardcoded clipboard prefix from progress tracker output
- Replace checkbox with green tick in config display
- Replace stopwatch with hourglass in timing display
- Replace up arrow with magnifier for commit extraction
- Replace clipboard with folder for local checkout step

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
Copilot AI review requested due to automatic review settings March 2, 2026 22:44

This comment was marked as outdated.

Fix two issues observed during local CLI testing:

- The fallback SSH command for Gerrit back-reference comments used
  -F /dev/null and IdentityAgent=none, which blocks agent-based SSH
  keys (e.g. Secretive, 1Password). Remove these restrictive options
  in local/CLI mode and preserve the system SSH_AUTH_SOCK so the
  user's SSH agent can authenticate
- Downgrade the shallow clone merge-base failure from WARNING to
  DEBUG, since the tool handles this gracefully by deepening the
  repository automatically

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
Boolean options that default to True need the --no-* counterpart
so users can disable them from the command line. Without the
negation flag, Typer only shows the positive form in --help and
provides no CLI mechanism to override the default.

- Add --no-allow-duplicates (default: True)
- Add --no-close-merged-prs (default: True)
- Add --no-preserve-github-prs (default: True)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
Copilot AI review requested due to automatic review settings March 2, 2026 23:21
@ModeSevenIndustrialSolutions ModeSevenIndustrialSolutions marked this pull request as ready for review March 2, 2026 23:22
@ModeSevenIndustrialSolutions
Copy link
Contributor Author

ModeSevenIndustrialSolutions commented Mar 2, 2026

Tested this pull request by using a development build of the CLI tool to process the FD.io changes that didn't get copied into the 'vpp' repository due to an earlier bug (that was fixed, but left several automation changes stuck in GitHub with no corresponding Gerrit change).

github2gerrit-action (🌴 implement-keyword-comments) % github2gerrit --create-missing --gerrit-server gerrit.fd.io https://github.com/FDio/vpp/pull/3689
                   GitHub2Gerrit Configuration                    
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Property                  ┃ Value                              ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ CLI_MODE                  │ ✅ Gerrit change from pull request │
│ GERRIT_SSH_USER_G2G       │ modesevenindustrialsolutions       │
│ GERRIT_SSH_USER_G2G_EMAIL │ mwatkins@linuxfoundation.org       │
│ ORGANIZATION              │ FDio                               │
│ REVIEWERS_EMAIL           │ mwatkins@linuxfoundation.org       │
│ PRESERVE_GITHUB_PRS       │ True                               │
│ ISSUE_ID                  │ ❎ Not provided                    │
│ GERRIT_SERVER             │ gerrit.fd.io                       │
│ GERRIT_PROJECT            │ vpp                                │
│ GERRIT_KNOWN_HOSTS        │ ❎                                 │
│ GERRIT_SSH_PRIVKEY_G2G    │ ❎                                 │
│ GITHUB_TOKEN              │ ✅                                 │
│ SSH_AGENT                 │ ✅ Available, Used                 │
│ CLEANUP_ABANDONED         │ ✅                                 │
│ CLEANUP_GERRIT            │ ✅                                 │
└───────────────────────────┴────────────────────────────────────┘
🔄 GitHub to Gerrit for FDio/vpp/pull/3689
Getting source PR details...
                                      Pull Request Details                                       
┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Property      ┃ Value                                                                         ┃
┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Repository    │ FDio/vpp                                                                      │
│ PR Number     │ 3689                                                                          │
│ Title         │ build(deps): bump fdio/vpp/.github/workflows/vpp-csit-verify-api.yml from     │
│               │ 1d3c4f761e2c0d2fa8b20d8653d4614a4fbaea49 to                                   │
│               │ 8b097bb2859be72108c26f7ab4d93538be45f9c6                                      │
│ Author        │ dependabot[bot]                                                               │
│ Base Branch   │ master                                                                        │
│ SHA           │ 27355b601cd7d5a5d657eb2576c1232a7831917d                                      │
│ URL           │ https://github.com/FDio/vpp/pull/3689                                         │
│ Files Changed │ 1                                                                             │
└───────────────┴───────────────────────────────────────────────────────────────────────────────┘
🤝 Processing pull request
📂 Preparing local checkout
🔐 Configuring SSH authentication
🔍 Extracting commit information
⏩ Submitting to Gerrit
⛔️ Checking for abandoned Gerrit changes

✅ Operation completed!
⏳ Total time: 1m 32s
📊 PRs processed: 1
📝 Changes updated: 1
🔗 Gerrit change: https://gerrit.fd.io/r/c/vpp/+/45040

This comment was marked as outdated.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Address issues raised during Copilot code review and reviewer feedback:

- CLI boolean env var overrides now check ctx.get_parameter_source()
  so that explicit --flag/--no-flag choices always take precedence
  over environment variables. The parse_bool_env workaround for
  GitHub Actions string "false" handling is preserved for non-CLI
  sources. Applied to all 12 boolean overrides in main()
- Sort parse_commands() matches by comment_index so result ordering
  reflects the latest (winning) occurrence position, matching the
  documented oldest-to-newest comment order contract
- Update module docstring to list both "create missing" and
  "create-missing" aliases, matching the command registry
- Capture SSH_AUTH_SOCK before build_non_interactive_ssh_env() blanks
  it, so the Gerrit back-reference comment fallback in local/CLI mode
  can use agent-based keys (e.g. Secretive, 1Password)
- Rename G2G_CREATE_MISSING env var to CREATE_MISSING for consistency
  with the other parameter env vars and the action.yaml input name

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
Copy link

@askb askb left a comment

Choose a reason for hiding this comment

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

LGTM

@ModeSevenIndustrialSolutions ModeSevenIndustrialSolutions merged commit de84770 into lfreleng-actions:main Mar 3, 2026
19 checks passed
@ModeSevenIndustrialSolutions ModeSevenIndustrialSolutions deleted the implement-keyword-comments branch March 3, 2026 12:58
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.

4 participants