-
Notifications
You must be signed in to change notification settings - Fork 174
ROX-12953: figure out last 4 versions of sensor automatically #3611
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
Merged
jschnath
merged 32 commits into
master
from
jschnath/ROX-12953_Figure_Out_Last_4_Versions_Of_Sensor_Automatically
Nov 16, 2022
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
b75cfff
X-Smart-Branch-Parent: master
jschnath b1dda77
Add sensorversions.py script (WIP)
jschnath e92a30e
Add TODOs for remaining changes
jschnath b870acf
Finish quay tag querying
jschnath 347a12d
Add git tag API query
jschnath da3d579
Make functions that don't need exposure private
jschnath 1b7f9c8
Separate tag syntax filtering between git and quay tags
jschnath ac0c621
Add Git CLI version fetching
jschnath bba20f1
Refactor
jschnath ab00749
Remove API methods for getting tags, remove underscores in functions
jschnath b9716e6
Remove main function
jschnath 0a22356
Rename sensorversions.py to sensor_versions.py to follow python namin…
jschnath 6ddd356
Use sensor_versions.py to grab the latest sensor versions for compati…
jschnath 9936fd3
make tag within sensor_versions.py script to get MAIN_IMAGE_TAG
jschnath fed49f7
Change function names to underscores instead of camel case
jschnath 1568159
Split split_version into two functions
jschnath 8f28b02
Refactor and simplify using dict
jschnath 793544e
Ensure that no sensor versions newer than central get tested
jschnath 0bce4cf
Rename main script function to be less verbose
jschnath 6b8bf85
Readd main function
jschnath 7bf3c44
Add "--quiet" and "--no-print-directory" to make tag call
jschnath d43ffc0
Rename functions to make them shorter
jschnath 1021b41
Use is not None instead of bool() cast
jschnath 963eebe
Remove unused variable
jschnath 731d912
Shorten filter_tags function
jschnath 04de0f9
Inline cli_output_to_tags function
jschnath d8a469b
compare major and minor versions
jschnath fea9ce4
make script executable
jschnath 653bccf
Constrain regex search more
jschnath 44be872
Split get_latest_tags into two functions
jschnath cb63286
Import only the function get_latest_release_versions instead of the w…
jschnath f9b6049
rename mainimagetag to tag
jschnath 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| """ | ||
| Returns the latest patches of the last n major versions | ||
| """ | ||
|
|
||
| import sys | ||
| import re | ||
| import subprocess | ||
| from collections import defaultdict | ||
|
|
||
| def is_release_tag(version): | ||
| return re.search(r"^\d+\.\d+\.\d+$", version) is not None | ||
|
|
||
| def filter_tags(rawtags): | ||
| return set([t for t in rawtags if is_release_tag(t)]) | ||
|
|
||
| def reduce_tags_to_latest_patch(tags): | ||
| top_patch_version = defaultdict(int) | ||
| for t in tags: | ||
| [major, minor, patch] = t.split('.') | ||
| k = '.'.join([major, minor]) | ||
| top_patch_version[k] = max(top_patch_version[k], int(patch)) | ||
| top_major_versions = sorted(list(top_patch_version.keys()), reverse=True) | ||
| return [t + '.' + str(top_patch_version[t]) for t in top_major_versions] | ||
|
|
||
| def make_image_tag(): | ||
| return subprocess.check_output(["make", "--quiet", "--no-print-directory", "tag"]).decode(encoding="utf-8") | ||
|
|
||
| def extract_x_y_from_main_image_tag(tag): | ||
| x_y = re.search(r"^(\d+)\.(\d+)", tag) | ||
| return int(x_y.group(1)), int(x_y.group(2)) | ||
|
|
||
| def get_latest_n_tags(tags, num_versions): | ||
| central_major, central_minor = extract_x_y_from_main_image_tag(make_image_tag()) | ||
| tags_older_than_central = [t for t in tags if (int(t.split('.')[0]) < central_major or (int(t.split('.')[0]) == central_major and int(t.split('.')[1]) <= central_minor))] | ||
| return tags_older_than_central[:num_versions] | ||
|
|
||
| # get_latest_release_versions gets the latest patches of the last num_versions major versions via Git CLI | ||
| def get_latest_release_versions(num_versions): | ||
| rawtags = subprocess.check_output(["git", "tag", "--list"]).decode(encoding="utf-8").splitlines() | ||
| tags = filter_tags(rawtags) | ||
| latest_patch_tags = reduce_tags_to_latest_patch(tags) | ||
| return get_latest_n_tags(latest_patch_tags, num_versions) | ||
|
|
||
| def main(argv): | ||
| n = int(argv[1]) if len(argv)>1 else 4 | ||
| latestversions = get_latest_release_versions(n) | ||
| print(f"Last {n} versions:") | ||
| print("\n".join(latestversions)) | ||
|
|
||
| if (__name__ == "__main__"): | ||
| main(sys.argv) | ||
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
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.