-
Notifications
You must be signed in to change notification settings - Fork 230
USHIFT-6588: Add manage_common_versions.sh script #6663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vanhalenar
wants to merge
5
commits into
openshift:main
Choose a base branch
from
vanhalenar:manage-common-versions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+104
−2
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" | ||
|
|
||
| action_verify() { | ||
| echo "Verifying common_versions.sh is in sync..." | ||
|
|
||
| # Check if there was a change to common_versions.sh on current branch compared to base branch. | ||
| # --exit-code: 0 means no changes, 1 means changes hence the inverted condition with '!' | ||
| # Because the top commit is Merge Commit of PR branch into base branch (e.g. main), we need to check against the earlier commit (i.e. ^1). | ||
| if ! git diff --exit-code "${SCENARIO_BUILD_BRANCH}^1...HEAD" "${ROOTDIR}/test/bin/common_versions.sh" >/dev/null 2>&1; then | ||
|
vanhalenar marked this conversation as resolved.
|
||
| echo "Detected changes to common_versions.sh, verifying they match generated version..." | ||
|
|
||
| # If the file was changed, regenerate it and compare - diff means that most likely the file was updated manually. | ||
| "${ROOTDIR}/scripts/pyutils/create-venv.sh" | ||
|
|
||
| if [ "${SCENARIO_BUILD_BRANCH}" == "main" ]; then | ||
| y=$(awk -F'[ .]' '{print $3 "." $4}' < "${ROOTDIR}/Makefile.version.x86_64.var") | ||
| else | ||
| y=$(echo "${SCENARIO_BUILD_BRANCH}" | awk -F'[-]' '{ print $2 }') | ||
| fi | ||
|
|
||
| "${ROOTDIR}/_output/pyutils/bin/python" \ | ||
| "${ROOTDIR}/test/bin/pyutils/generate_common_versions.py" \ | ||
| "${y}" \ | ||
| --update-file | ||
|
|
||
| if ! git diff --exit-code "${ROOTDIR}/test/bin/common_versions.sh"; then | ||
| echo "ERROR: Discovered that common_versions.sh was updated on the branch under test, but the regenerated version is different" | ||
| git diff | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Verification passed: common_versions.sh matches generated version" | ||
| else | ||
| echo "No changes detected to common_versions.sh" | ||
| fi | ||
| } | ||
|
|
||
| action_generate() { | ||
| local version="${1:-}" | ||
|
|
||
| if [ -z "${version}" ]; then | ||
| echo "ERROR: Version is required" | ||
| echo "Usage: ${BASH_SOURCE[0]} generate <VERSION> [options]" | ||
| exit 1 | ||
| fi | ||
|
|
||
| "${ROOTDIR}/scripts/pyutils/create-venv.sh" | ||
| shift | ||
| "${ROOTDIR}/_output/pyutils/bin/python" \ | ||
| "${ROOTDIR}/test/bin/pyutils/generate_common_versions.py" \ | ||
| "${version}" \ | ||
| "$@" | ||
| } | ||
|
|
||
| usage() { | ||
| cat <<EOF | ||
| Usage: ${BASH_SOURCE[0]} <action> [options] | ||
|
|
||
| ACTIONS: | ||
| verify Verify that common_versions.sh is in sync with the template | ||
| and generation script. Checks if the file was manually edited | ||
| without regenerating. | ||
|
|
||
| generate <VERSION> Generate common_versions.sh for the specified version. | ||
| VERSION format depends on the release: | ||
| - For 4.22 and older: minor version only (e.g., 19, 22) | ||
| - For 5.0 and newer: X.Y format (e.g., 5.0, 5.1) | ||
|
|
||
| Additional options are passed to generate_common_versions.py: | ||
| --update-file Update test/bin/common_versions.sh | ||
| --create-pr Create a pull request with changes | ||
| --dry-run Dry run mode | ||
|
|
||
| -h, --help Show this help message | ||
|
|
||
| EOF | ||
| } | ||
|
|
||
| if [ $# -eq 0 ]; then | ||
| usage | ||
| exit 1 | ||
| fi | ||
|
|
||
| action="${1}" | ||
| shift | ||
|
|
||
| case "${action}" in | ||
| verify|generate) | ||
| "action_${action}" "$@" | ||
| ;; | ||
| -h|--help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| esac | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.