Skip to content

USHIFT-6859: Update generate_common_versions.py to take "X.Y" as argument for 5.0 handling#6505

Open
pmtk wants to merge 1 commit intoopenshift:mainfrom
pmtk:common-versions-5.0
Open

USHIFT-6859: Update generate_common_versions.py to take "X.Y" as argument for 5.0 handling#6505
pmtk wants to merge 1 commit intoopenshift:mainfrom
pmtk:common-versions-5.0

Conversation

@pmtk
Copy link
Copy Markdown
Member

@pmtk pmtk commented Apr 15, 2026

Summary by CodeRabbit

  • Refactor

    • CLI now accepts a single required version string in X.Y format instead of separate major/minor arguments.
    • Corrected a cross-major example so the prior-release minor for 5.0 is now 4.22.
  • Chore

    • Updated how the verification/regeneration process derives the version string, which changes the expected regenerated version output.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 15, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 15, 2026

@pmtk: This pull request references USHIFT-6859 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 15, 2026

Walkthrough

Replaced separate --major and minor CLI args in generate_common_versions.py with a single positional version in X.Y format (validated and parsed to integers). Updated VERSION_MAP comment. Adjusted common_versions_verify.sh to build/parse the y value differently when invoking the Python script.

Changes

Cohort / File(s) Summary
Python CLI change
test/bin/pyutils/generate_common_versions.py
Replaced --major + positional minor with one positional version (X.Y); added parse_major_minor() to validate/parse into integer (major, minor) and pass those to generate_common_versions; updated VERSION_MAP inline comment for 5.0.
Shell invocation/parsing update
test/bin/common_versions_verify.sh
Changed how the y version string is constructed: on main concatenates two Makefile fields ($3 "." $4), on non-main branches extracts a different field from branch name ($2 after splitting on [-]); this changes the version passed to the Python generator and the resulting expected output.

Sequence Diagram(s)

sequenceDiagram
    participant CI as CI / Caller
    participant Shell as common_versions_verify.sh
    participant Source as Makefile / Git
    participant Py as generate_common_versions.py
    participant Gen as generate_common_versions

    CI->>Shell: invoke verification
    Shell->>Source: read Makefile fields or branch name
    Source-->>Shell: return version fields / branch
    Shell->>Py: call with positional `version` ("X.Y")
    Py->>Py: parse_major_minor(version) -> (major, minor)
    Py->>Gen: generate_common_versions(major, minor)
    Gen-->>Py: produce/update common_versions.sh
    Py-->>Shell: exit status / output
    Shell->>CI: diff check result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 9 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating generate_common_versions.py to accept version strings in X.Y format for 5.0 support.
Stable And Deterministic Test Names ✅ Passed PR modifies only Python utility and shell scripts, not Ginkgo test files. Check not applicable.
Test Structure And Quality ✅ Passed PR modifies shell and Python scripts only; no Ginkgo test files present, making check not applicable.
Microshift Test Compatibility ✅ Passed PR does not add Ginkgo e2e tests; changes are limited to version management utility scripts.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests added; changes limited to utility scripts in test/bin/.
Topology-Aware Scheduling Compatibility ✅ Passed Pull request modifies only test and build utility scripts with no Kubernetes deployment manifests, operator code, controllers, or scheduling configurations.
Ote Binary Stdout Contract ✅ Passed PR modifies only Python and shell scripts, not OTE Go-based test binaries, so OTE Binary Stdout Contract is not applicable.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR does not add or modify any Ginkgo e2e tests. Changes are to Python and shell utility scripts for version management, not e2e test code.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci bot requested review from ggiguash and kasturinarra April 15, 2026 10:41
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 15, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 15, 2026

@pmtk: This pull request references USHIFT-6859 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary by CodeRabbit

  • Refactor
  • Updated CLI argument format to accept version as a single major.minor string instead of separate parameters
  • Adjusted version reference documentation to reflect current version information

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/bin/pyutils/generate_common_versions.py (1)

425-426: ⚠️ Potential issue | 🔴 Critical

args.major no longer exists and will crash --create-pr.

After switching to positional version, Line [425] and Line [426] reference args.major, which causes AttributeError when --create-pr is used.

💡 Proposed fix
-        if not base_branch.startswith(f"release-{args.major}"):
-            logging.error(f"Script is expected to be executed on branch starting with 'release-{args.major}', but it's {base_branch}")
+        expected_prefix = f"release-{major}.{minor}"
+        if not base_branch.startswith(expected_prefix):
+            logging.error(f"Script is expected to be executed on branch starting with '{expected_prefix}', but it's {base_branch}")
             exit(1)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/bin/pyutils/generate_common_versions.py` around lines 425 - 426, The
branch-name check currently references a non-existent args.major (causing
AttributeError when running --create-pr); update the code so it derives the
major version from args.version (e.g., parse args.version and extract the major
component) and use that computed major in the base_branch.startswith call
(replace uses of args.major with the new major variable), ensuring the check
still reads base_branch.startswith(f"release-{major}") and that args.version is
validated before parsing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/bin/pyutils/generate_common_versions.py`:
- Around line 397-408: The CLI currently splits args.version with naive indexing
which can raise IndexError/ValueError and breaks callers that pass just a major
(e.g., `${y}`); update the argument parsing around parser and args.version so it
strictly validates the format and provides a clear argparse error: accept either
"X.Y" or a single "X" (back-compat), validate using a regex or split and
explicit checks, convert to ints only after validation, and call
parser.error(...) on malformed inputs instead of letting raw exceptions
propagate; ensure you still call generate_common_versions(major, minor) with
minor defaulting to 0 for the single-number case, and update the caller
test/bin/common_versions_verify.sh to pass "X.Y" (or rely on the new
backward-compat behavior).

---

Outside diff comments:
In `@test/bin/pyutils/generate_common_versions.py`:
- Around line 425-426: The branch-name check currently references a non-existent
args.major (causing AttributeError when running --create-pr); update the code so
it derives the major version from args.version (e.g., parse args.version and
extract the major component) and use that computed major in the
base_branch.startswith call (replace uses of args.major with the new major
variable), ensuring the check still reads
base_branch.startswith(f"release-{major}") and that args.version is validated
before parsing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 508097f9-45d7-4b97-85ba-657b4c18f7a0

📥 Commits

Reviewing files that changed from the base of the PR and between 685552c and 7ecf033.

📒 Files selected for processing (1)
  • test/bin/pyutils/generate_common_versions.py

Comment thread test/bin/pyutils/generate_common_versions.py Outdated
@pmtk pmtk force-pushed the common-versions-5.0 branch from 7ecf033 to 862dc4b Compare April 15, 2026 12:38
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 15, 2026

@pmtk: This pull request references USHIFT-6859 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary by CodeRabbit

  • Refactor

  • CLI now accepts a single version string in X.Y format instead of separate major/minor arguments

  • Updated version reference in documentation to reflect the corrected cross-major example

  • Chore

  • Adjusted version parsing used by the verification/regeneration script, affecting regenerated version output

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Comment thread test/bin/pyutils/generate_common_versions.py Outdated
@pmtk pmtk force-pushed the common-versions-5.0 branch from 862dc4b to bb54432 Compare April 15, 2026 13:08
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 15, 2026

@pmtk: This pull request references USHIFT-6859 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary by CodeRabbit

  • Refactor

  • CLI now accepts a single version string in X.Y format instead of separate major/minor arguments.

  • Updated a version reference to correct the cross-major example (5.0’s Y-1 minor is now 4.22).

  • Chore

  • Adjusted how the verification/regeneration script derives the version string, affecting regenerated version output.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Comment thread test/bin/pyutils/generate_common_versions.py
@pmtk pmtk force-pushed the common-versions-5.0 branch from bb54432 to d3d78a7 Compare April 16, 2026 07:56
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 16, 2026

@pmtk: This pull request references USHIFT-6859 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary by CodeRabbit

  • Refactor

  • CLI now accepts a single required version string in X.Y format instead of separate major/minor arguments.

  • Corrected a cross-major example so the prior-release minor for 5.0 is now 4.22.

  • Chore

  • Updated how the verification/regeneration process derives the version string, which changes the expected regenerated version output.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
test/bin/pyutils/generate_common_versions.py (1)

396-403: ⚠️ Potential issue | 🟡 Minor

Handle invalid version via parser.error(...) instead of uncaught ArgumentTypeError.

Right now malformed input can produce a raw traceback instead of argparse’s normal CLI error output/exit flow.

💡 Proposed fix
 def main():
     def parse_major_minor(value: str):
         parts = value.split(".")
         if len(parts) != 2 or not all(p.isdigit() for p in parts):
             raise argparse.ArgumentTypeError("version must be in 'X.Y' format")
         return int(parts[0]), int(parts[1])

     parser = argparse.ArgumentParser(description="Generate common_versions.sh variables.")
     parser.add_argument("version", type=str, help="The major.minor version number.")
@@
     args = parser.parse_args()

-    major, minor = parse_major_minor(args.version)
+    try:
+        major, minor = parse_major_minor(args.version)
+    except argparse.ArgumentTypeError as e:
+        parser.error(str(e))
     output = generate_common_versions(major, minor)
#!/bin/bash
# Verify current parsing/error path wiring in generate_common_versions.py
rg -n -C2 'def parse_major_minor|ArgumentTypeError|parser\.add_argument\("version"|parse_major_minor\(args\.version\)|parser\.error\(' test/bin/pyutils/generate_common_versions.py

Also applies to: 411-412

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/bin/pyutils/generate_common_versions.py` around lines 396 - 403, The
parser currently defines parse_major_minor (which raises
argparse.ArgumentTypeError) but the argument is registered as type=str and later
the script manually calls parse_major_minor(args.version), so malformed input
can raise an uncaught ArgumentTypeError; update parser.add_argument("version",
...) to use type=parse_major_minor so argparse handles validation and prints its
normal error/exit flow, and for any other direct calls to parse_major_minor
(e.g., parse_major_minor(args.version) around lines referencing that call) wrap
them in try/except catching argparse.ArgumentTypeError and call
parser.error(str(err)) to convert the exception into argparse's error reporting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@test/bin/pyutils/generate_common_versions.py`:
- Around line 396-403: The parser currently defines parse_major_minor (which
raises argparse.ArgumentTypeError) but the argument is registered as type=str
and later the script manually calls parse_major_minor(args.version), so
malformed input can raise an uncaught ArgumentTypeError; update
parser.add_argument("version", ...) to use type=parse_major_minor so argparse
handles validation and prints its normal error/exit flow, and for any other
direct calls to parse_major_minor (e.g., parse_major_minor(args.version) around
lines referencing that call) wrap them in try/except catching
argparse.ArgumentTypeError and call parser.error(str(err)) to convert the
exception into argparse's error reporting.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 486b1673-6dee-4ee5-a35c-a3edbcb1e26e

📥 Commits

Reviewing files that changed from the base of the PR and between bb54432 and d3d78a7.

📒 Files selected for processing (2)
  • test/bin/common_versions_verify.sh
  • test/bin/pyutils/generate_common_versions.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/bin/common_versions_verify.sh

Copy link
Copy Markdown
Contributor

@pacevedom pacevedom left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 16, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pacevedom, pmtk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pmtk
Copy link
Copy Markdown
Member Author

pmtk commented Apr 16, 2026

/override ci/prow/e2e-aws-tests-bootc-el9

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 16, 2026

@pmtk: Overrode contexts on behalf of pmtk: ci/prow/e2e-aws-tests-bootc-el9

Details

In response to this:

/override ci/prow/e2e-aws-tests-bootc-el9

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@pmtk
Copy link
Copy Markdown
Member Author

pmtk commented Apr 16, 2026

/verified by @pmtk

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Apr 16, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@pmtk: This PR has been marked as verified by @pmtk.

Details

In response to this:

/verified by @pmtk

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 16, 2026

@pmtk: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 87d90b3 and 2 for PR HEAD d3d78a7 in total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants