-
Notifications
You must be signed in to change notification settings - Fork 9
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
[Extend] version-automation to rockcraft.yaml
#636
Merged
sergio-costas
merged 3 commits into
ubuntu:stable
from
rudra-iitm:version-automation-rock
Jul 1, 2024
Merged
Changes from 2 commits
Commits
Show all changes
3 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 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 |
---|---|---|
|
@@ -62,6 +62,33 @@ def process_snap_version_data(upstreamversion, snap_name, version_schema, has_up | |
return f"{upstreamversion}-{packagerelease}" | ||
|
||
|
||
def process_rock_version_data(upstream_version, previous_version, version_schema, has_update): | ||
""" Returns processed rock version""" | ||
|
||
match = re.match(version_schema, upstream_version) | ||
if not match: | ||
logging.warning("Version schema does not match with rock repository version") | ||
return None | ||
upstream_version = match.group(1).replace('_', '.') | ||
|
||
def version_tuple(v): | ||
return tuple(map(int, v.split('.'))) | ||
|
||
upstream_tuple = version_tuple(upstream_version) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ehm... Is this a problem in github, or the function is really still there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I forgot to remove that functions... Now fixed it |
||
upstream_tuple = tuple(map(int, upstream_version.split('.'))) | ||
prev_tuple = tuple(map(int, previous_version.split('-')[0].split('.'))) | ||
|
||
if upstream_tuple > prev_tuple: | ||
return f"{upstream_version}-1" | ||
# Determine package release number | ||
if has_update: | ||
packagerelease = int(previous_version.split('-')[-1]) + 1 | ||
else: | ||
packagerelease = int(previous_version.split('-')[-1]) | ||
|
||
return f"{upstream_version}-{packagerelease}" | ||
|
||
|
||
def is_version_update(snap, manager_yaml, arguments, has_update): | ||
""" Returns if snap version update available """ | ||
has_version_update = False | ||
|
@@ -87,3 +114,30 @@ def is_version_update(snap, manager_yaml, arguments, has_update): | |
version_file.write(f"{snap_version}") | ||
|
||
return has_version_update | ||
|
||
|
||
def is_rock_version_update(rock, manager_yaml, arguments, has_update): | ||
""" Returns if rock version update available """ | ||
has_version_update = False | ||
if arguments.rock_version_schema == 'None': | ||
return False | ||
metadata = rock.process_metadata() | ||
rock_version = process_rock_version_data(metadata['upstream-version'], metadata['version'], | ||
arguments.rock_version_schema, has_update) | ||
if rock_version is None: | ||
return False | ||
if metadata['version'] != rock_version: | ||
rock_version_data = manager_yaml.get_part_metadata('version') | ||
if rock_version_data is not None: | ||
logging.info("Updating rock version from %s to %s", | ||
metadata['version'], rock_version) | ||
rock_version_data['data'] = f"version: '{rock_version}'" | ||
has_version_update = True | ||
else: | ||
logging.warning("Version is not defined in metadata") | ||
|
||
if has_version_update: | ||
with open('version_file', 'w', encoding="utf8") as version_file: | ||
version_file.write(f"{rock_version}") | ||
|
||
return has_version_update |
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
Oops, something went wrong.
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.
Do we really need to create a function just for this?
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.
Removed function and now using inline tuple to resolve version