-
Notifications
You must be signed in to change notification settings - Fork 138
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
Add script to check outdated image references #2199
Open
rbaturov
wants to merge
1
commit into
openshift-kni:master
Choose a base branch
from
rbaturov:verify-image-ref-consistent
base: master
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.
+60
−1
Open
Changes from all commits
Commits
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 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 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,56 @@ | ||
#!/bin/bash | ||
|
||
# Purpose: This script ensures that specific files containing hardcoded release versions are up to date with the current release and do not reference any previous versions. | ||
|
||
# Functionality: | ||
# 1. Determines if the current branch is a release branch (e.g., release-4.x). | ||
# 2. Extracts the previous version (e.g. 4.16 for release-4.17). | ||
# 3. Checks specific files for any occurrences of the previous version. | ||
# 4. If matches are found, it prompts the user to update references to the current release branch and exits with an error code. | ||
# 5. Skips checks for non-release branches or missing files. | ||
|
||
branch_name=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
release_regex="release-([0-9]+)\.([0-9]+)" | ||
|
||
if [[ ! $branch_name =~ $release_regex ]]; then | ||
echo "Branch '$branch_name' is not a release branch. Skipping checks." | ||
exit 0 | ||
fi | ||
|
||
x="${BASH_REMATCH[1]}" | ||
y="${BASH_REMATCH[2]}" | ||
previous_version="$x.$((y - 1))" # Example: 4.16 for branch release-4.17 | ||
|
||
files_to_check=( | ||
"cnf-tests/Dockerfile.openshift" | ||
"cnf-tests/Dockerfile.konflux" | ||
"cnf-tests/mirror/images.json" | ||
"cnf-tests/testsuites/pkg/images/images.go" | ||
"hack/common.sh" | ||
"hack/run-functests.sh" | ||
) | ||
|
||
match_found=false | ||
|
||
for file in "${files_to_check[@]}"; do | ||
if [[ ! -f "$file" ]]; then | ||
echo "Warning: File '$file' does not exist. Skipping." | ||
continue | ||
fi | ||
if grep -nw "$file" -e "$previous_version" 2>/dev/null ; then | ||
echo "Reference to $previous_version found in $file." | ||
match_found=true | ||
fi | ||
done | ||
|
||
if $match_found; then | ||
echo "----------------------------------------------------------------------------------" | ||
echo "The following files contain references to the previous release version ($previous_version):" | ||
echo "Please update them to the current release branch ($branch_name) to ensure consistency." | ||
echo "This can be done by creating a PR against ($branch_name)." | ||
echo "For more details, refer to the Branching section in the project's readme.md." | ||
exit 1 | ||
else | ||
echo "All files are up-to-date. No references to $previous_version were found." | ||
fi |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the branch was significantly outdated and contained references older than the previous release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't be possible, look at my comment to Bart. Since we aligned the master branch to reference 4.19 images and assuming having this script this would be impossible