Skip to content

Fix: Add Gerrit DNS validation, CI_TEST_MODE#165

Open
ModeSevenIndustrialSolutions wants to merge 1 commit intolfreleng-actions:mainfrom
modeseven-lfreleng-actions:ci-test-fixes
Open

Fix: Add Gerrit DNS validation, CI_TEST_MODE#165
ModeSevenIndustrialSolutions wants to merge 1 commit intolfreleng-actions:mainfrom
modeseven-lfreleng-actions:ci-test-fixes

Conversation

@ModeSevenIndustrialSolutions
Copy link
Contributor

Add fast-fail DNS validation of the Gerrit server
hostname after config display, before PR processing. This catches bogus derived hostnames early instead of letting the tool fail silently during cleanup.

Implement CI_TEST_MODE leveraging DRY_RUN: when
CI_TEST_MODE=true, force DRY_RUN=true and
G2G_DRYRUN_DISABLE_NETWORK=true so all tool logic
runs but Gerrit network operations are no-ops.
Cleanup tasks are also suppressed since there is no server to query. Display a CI_TEST_MODE row with a test-tube emoji in the config table when active.

Gate all cleanup operations on not ci_test_mode to prevent network calls to non-existent Gerrit servers.

The early DNS validation is skipped when CI_TEST_MODE, G2G_TEST_MODE, or G2G_DRYRUN_DISABLE_NETWORK are
active, consistent with existing dry-run preflight.

Add CI_TEST_MODE as an action input in action.yaml and pass it to the CLI step. Update the reusable
workflow to read vars.CI_TEST_MODE. Switch the
testing.yaml happy-path test to CI_TEST_MODE=true.

Update test fixtures using placeholder hostnames to set G2G_DRYRUN_DISABLE_NETWORK=true when popping
G2G_TEST_MODE since they target validation logic
not network reachability.

Copilot AI review requested due to automatic review settings March 17, 2026 12:45

This comment was marked as duplicate.

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 adds an early DNS fast-fail check for the configured Gerrit server and introduces CI_TEST_MODE to run the full tool logic in CI while disabling Gerrit network operations and suppressing cleanup paths that would query Gerrit.

Changes:

  • Add Orchestrator.validate_gerrit_server() and invoke it early in CLI execution (unless test/no-network flags are active).
  • Implement CI_TEST_MODE behavior in the CLI (force DRY_RUN + G2G_DRYRUN_DISABLE_NETWORK, suppress cleanup operations, and surface state in the config table).
  • Update action/workflows and tests to plumb CI_TEST_MODE and to disable DNS validation in unit tests that use placeholder hostnames.

Reviewed changes

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

Show a summary per file
File Description
src/github2gerrit/core.py Adds a DNS resolution validator for Gerrit hostnames.
src/github2gerrit/cli.py Implements CI_TEST_MODE behavior, early DNS validation, and gates cleanup in test mode; updates config display.
action.yaml Adds CI_TEST_MODE input and passes it into the CLI environment.
.github/workflows/testing.yaml Switches the happy-path workflow test to CI_TEST_MODE: 'true'.
.github/workflows/github2gerrit.yaml Plumbs vars.CI_TEST_MODE into workflow env for jobs using the reusable workflow.
tests/test_dns_validation_and_ci_test_mode.py Adds focused tests for DNS validation and CI_TEST_MODE environment/skip behavior.
tests/test_cli_url_and_dryrun.py Sets G2G_DRYRUN_DISABLE_NETWORK=true in base env to avoid DNS failures with placeholder hostnames.
tests/test_cli_outputs_file.py Sets G2G_DRYRUN_DISABLE_NETWORK=true in relevant env blocks to avoid early DNS validation.
tests/test_cli.py Sets G2G_DRYRUN_DISABLE_NETWORK=true for validation-focused tests that aren’t about network reachability.

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

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

Adds early Gerrit hostname DNS validation and introduces a new CI_TEST_MODE execution mode intended for CI workflows where the full pipeline runs but all Gerrit network operations (and cleanup sweeps) are suppressed.

Changes:

  • Added Orchestrator.validate_gerrit_server() and wired an early DNS “fast-fail” check into the CLI _process() path (with skip guards for test/no-network modes).
  • Implemented CI_TEST_MODE behavior in the CLI (forces DRY_RUN + disables network; suppresses cleanup operations) and surfaced it in the config display.
  • Updated action/workflows and tests to pass CI_TEST_MODE and/or disable network DNS checks for placeholder hosts.

Reviewed changes

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

Show a summary per file
File Description
src/github2gerrit/core.py Adds validate_gerrit_server() DNS resolution helper on Orchestrator.
src/github2gerrit/cli.py Implements CI_TEST_MODE forcing, early DNS validation, and gates cleanup operations on not ci_test_mode.
action.yaml Adds CI_TEST_MODE action input and passes it through to the CLI step.
.github/workflows/testing.yaml Switches happy-path action test run to CI_TEST_MODE: 'true'.
.github/workflows/github2gerrit.yaml Passes vars.CI_TEST_MODE into jobs so reusable workflow runs can toggle CI test mode.
tests/test_dns_validation_and_ci_test_mode.py New unit tests for DNS validation + CI_TEST_MODE behavior/guards.
tests/test_cli.py Sets G2G_DRYRUN_DISABLE_NETWORK=true in targeted tests to avoid new DNS preflight failures.
tests/test_cli_url_and_dryrun.py Adds G2G_DRYRUN_DISABLE_NETWORK=true to base env for tests using placeholder Gerrit hosts.
tests/test_cli_outputs_file.py Adds G2G_DRYRUN_DISABLE_NETWORK=true to env setups to bypass DNS preflight.

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

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

Adds an early, fast-fail Gerrit hostname DNS validation step and introduces CI_TEST_MODE to run the full pipeline logic in a network-disabled dry-run configuration suitable for CI/local action testing. Updates the GitHub Action and workflows to plumb the new input and adjusts/extends tests to account for the new preflight behavior.

Changes:

  • Add Orchestrator.validate_gerrit_server() and invoke early DNS validation in the CLI (skipped for CI/test/no-network modes).
  • Implement CI_TEST_MODE to force DRY_RUN=true + G2G_DRYRUN_DISABLE_NETWORK=true, and suppress cleanup paths that would hit Gerrit.
  • Update action/workflows and test suite to pass/cover the new behavior.

Reviewed changes

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

Show a summary per file
File Description
src/github2gerrit/core.py Adds a DNS-resolution validator for Gerrit hostname.
src/github2gerrit/cli.py Integrates CI_TEST_MODE, adds early DNS validation, and gates cleanup operations.
action.yaml Adds CI_TEST_MODE as an action input and passes it into the CLI environment.
.github/workflows/testing.yaml Switches the happy-path workflow run to CI_TEST_MODE=true.
.github/workflows/github2gerrit.yaml Wires vars.CI_TEST_MODE into jobs’ environment.
tests/test_dns_validation_and_ci_test_mode.py Adds targeted unit tests for DNS validation and CI test-mode behavior.
tests/test_cli_url_and_dryrun.py Sets G2G_DRYRUN_DISABLE_NETWORK=true in baseline env to avoid new DNS preflight in mocked tests.
tests/test_cli_outputs_file.py Sets G2G_DRYRUN_DISABLE_NETWORK=true where tests focus on CLI/output behavior rather than reachability.
tests/test_cli.py Sets G2G_DRYRUN_DISABLE_NETWORK=true in validation-focused tests to bypass DNS preflight.

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

Add fast-fail DNS validation of the Gerrit server
hostname after config display, before PR processing.
This catches bogus derived hostnames early instead of
letting the tool fail silently during cleanup.

Implement CI_TEST_MODE leveraging DRY_RUN: when
CI_TEST_MODE=true, force DRY_RUN=true and
G2G_DRYRUN_DISABLE_NETWORK=true so all tool logic
runs but Gerrit network operations are no-ops.
Cleanup tasks are also suppressed since there is no
server to query. Display a CI_TEST_MODE row with a
test-tube emoji in the config table when active.

Gate all cleanup operations on not ci_test_mode to
prevent network calls to non-existent Gerrit servers.

The early DNS validation is skipped when CI_TEST_MODE,
G2G_TEST_MODE, or G2G_DRYRUN_DISABLE_NETWORK are
active, consistent with existing dry-run preflight.

Add CI_TEST_MODE as an action input in action.yaml
and pass it to the CLI step. Update the reusable
workflow to read vars.CI_TEST_MODE. Switch the
testing.yaml happy-path test to CI_TEST_MODE=true.

Update test fixtures using placeholder hostnames to
set G2G_DRYRUN_DISABLE_NETWORK=true when popping
G2G_TEST_MODE since they target validation logic
not network reachability.

Remove console output blank line before:
- ✅ Operation completed!
- ❌ Operation failed!

Co-authored-by: Claude <[email protected]>
Signed-off-by: Matthew Watkins <[email protected]>
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

Adds a CI-focused “no-network” execution mode and an early Gerrit hostname DNS preflight to fail fast on misderived/unresolvable Gerrit servers, while updating the action/workflows and tests to accommodate the new preflight behavior.

Changes:

  • Add Orchestrator.validate_gerrit_server() and invoke it early in the CLI (with skip guards for CI/test/no-network modes).
  • Implement CI_TEST_MODE (forces DRY_RUN=true + G2G_DRYRUN_DISABLE_NETWORK=true) and gate Gerrit cleanup operations when enabled.
  • Update GitHub Action inputs/workflows and adjust tests/fixtures to disable the new early DNS probe where appropriate.

Reviewed changes

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

Show a summary per file
File Description
src/github2gerrit/core.py Adds validate_gerrit_server() DNS resolution preflight helper.
src/github2gerrit/cli.py Adds CI_TEST_MODE behavior, early DNS validation, and suppresses cleanup in CI_TEST_MODE; shows CI_TEST_MODE in config table.
action.yaml Introduces CI_TEST_MODE action input and passes it into the CLI environment.
.github/workflows/testing.yaml Switches happy-path local action test to CI_TEST_MODE=true.
.github/workflows/github2gerrit.yaml Wires vars.CI_TEST_MODE into the composite action input in both jobs.
tests/test_dns_validation_and_ci_test_mode.py New unit tests covering DNS validation + CI_TEST_MODE semantics/guards.
tests/test_cli_url_and_dryrun.py Sets G2G_DRYRUN_DISABLE_NETWORK=true in baseline env to skip early DNS probe.
tests/test_cli_outputs_file.py Disables early DNS probe in baseline envs used by CLI output tests.
tests/test_cli.py Disables early DNS probe in targeted validation tests that don’t intend to test network reachability.

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

Comment on lines +2185 to +2188
safe_console_print(
f"❌ Gerrit server '{gerrit_host}' could not be resolved. "
f"Cannot proceed without a valid Gerrit server.",
style="red",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants