-
Notifications
You must be signed in to change notification settings - Fork 55
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
Make rebuilding the app images smarter #694
Merged
Merged
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import argparse | ||
import requests | ||
from urllib.parse import urljoin | ||
from packaging.version import parse | ||
from packaging.requirements import Requirement | ||
|
||
PACKAGES = [ | ||
"pulp-ansible", | ||
"pulp-container", | ||
"pulp-deb", | ||
"pulp-gem", | ||
"pulp-maven", | ||
"pulp-python", | ||
"pulp-rpm", | ||
"pulp-ostree" | ||
] | ||
|
||
INDEX = "https://pypi.org" | ||
|
||
def check_update(branch, current_versions): | ||
""" | ||
Go through each of the image's main Pulp components and see if there is a new version available. | ||
""" | ||
new_versions = {} | ||
# Get the latest Z (or Y) pulpcore release for this branch | ||
core_pypi_response = requests.get(urljoin(INDEX, "pypi/pulpcore/json")) | ||
assert core_pypi_response.status_code == 200 | ||
core_version = parse(current_versions["pulpcore"]) | ||
for version, release in core_pypi_response.json()["releases"].items(): | ||
cur_version = parse(version) | ||
if cur_version > core_version: | ||
if branch != "latest": | ||
if cur_version.major != core_version.major or cur_version.minor != core_version.minor: | ||
continue | ||
core_version = cur_version | ||
new_versions["pulpcore"] = core_version | ||
|
||
# Now check each plugin to see if they need updates | ||
for plugin in PACKAGES: | ||
if plugin not in current_versions: | ||
continue | ||
plugin_version = parse(current_versions[plugin]) | ||
plugin_pypi_response = requests.get(urljoin(INDEX, f"pypi/{plugin}/json")) | ||
assert plugin_pypi_response.status_code == 200 | ||
plugin_versions = sorted((parse(v) for v in plugin_pypi_response.json()["releases"].keys()), reverse=True) | ||
for version in plugin_versions: | ||
if version <= plugin_version: | ||
break | ||
version_pypi_response = requests.get(urljoin(INDEX, f"pypi/{plugin}/{version}/json")) | ||
assert version_pypi_response.status_code == 200 | ||
deps = version_pypi_response.json()["info"]["requires_dist"] | ||
core_dep = next(filter(lambda dep: dep.startswith("pulpcore"), deps)) | ||
if core_version in Requirement(core_dep).specifier: | ||
new_versions[plugin] = version | ||
break | ||
|
||
if new_versions: | ||
print("Updates needed for:") | ||
for plugin, version in new_versions.items(): | ||
print(f"{plugin}: {current_versions[plugin]} -> {version!s}") | ||
exit(100) | ||
|
||
print("No updates needed :)") | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("branch") | ||
parser.add_argument("versions", type=argparse.FileType("r")) | ||
opts = parser.parse_args() | ||
versions = {} | ||
for line in opts.versions: | ||
plugin, _, version = line.rstrip("\n").partition("==") | ||
versions[plugin] = version | ||
check_update(opts.branch, versions) |
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
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
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.
Is this the same cache that we key with
base_images={{ env.VERSIONKEY }}
?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.
It's the same cache container, but not the same entry.
base_images={{ env.VERSIONKEY }}
was a typo left over from copy-pasting. I fixed it, now the key should only be{{ env.VERSIONKEY }}
for theversions.freeze
file.