-
Notifications
You must be signed in to change notification settings - Fork 50
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
cli: add git-upgrade-shared-modules command #371
cli: add git-upgrade-shared-modules command #371
Conversation
6bc5a28
to
e078cdd
Compare
82c518b
to
c06163b
Compare
98b4405
to
0458704
Compare
reana/reana_dev/utils.py
Outdated
return get_current_branch(get_srcdir(component)) != "master" | ||
|
||
|
||
def replace_version_string( |
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.
Thanks, looks great! 😊 This covers all the use cases in the create release commit. Just two observations:
- We could rename the function since this replaces strings in component files, no matter what they are
- What about renaming
module_grep
to something along the lines of:line_selector_expression
/line_regex
/line_pattern
(not very gifted today with the naming but you know what I mean)
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.
- Mmh what about
replace_string
,replace_regex
,sed_file
...? - Naming on these tricky functions is always hard, maybe
line_selector_regex
?
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.
Updated, feel free to change it if needed.
0458704
to
c42e205
Compare
"git branch --show-current", component, return_output=True | ||
) | ||
run_command( | ||
f"git push --force origin {branch}", component, |
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.
I'm not fully sure about this part. If one is checking out a feature branch of a colleague, will this upgrade their PR?
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.
Nope, if you are checking only, you are in "latest" or "debug" mode, so you wouldn't need to upgrade minimal versions. The command to upgrade common modules is only used by the integrator, where it is OK to update the PR, because it saves time since the integrator won't need to ask people "please bump r-commons in the other PR in this set". So I consider it as a "service provided by integrators so that developers don't have to do unnecessary bumping".
I would simply remove the old function, because the new functions can take over; a workflow like: $ reana-dev git-create-release-commit -c CLUSTER -c CLIENT
$ reana-dev git-upgrade-shared-modules -c CLUSTER -c CLIENT
$ reana-dev git-create-pr -c CLUSTER -c CLIENT If some functionality is missing, e.g. force creation of a release commit in order to pass from |
reana/reana_dev/utils.py
Outdated
line_selector_regex=f"{module}.*>=", | ||
component=component, | ||
) | ||
replace_version_string( |
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.
I get troubles with this branch:
$ reana-dev git-upgrade-shared-modules -c r-w-controller
...
File "/home/simko/.virtualenvs/reana/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/simko/.virtualenvs/reana/lib/python3.8/site-packages/reana/reana_dev/git.py", line 817, in git_upgrade_shared_modules
update_module_in_cluster_components(
File "/home/simko/.virtualenvs/reana/lib/python3.8/site-packages/reana/reana_dev/utils.py", line 437, in update_module_in_cluster_components
replace_version_string(
NameError: name 'replace_version_string' is not defined
c42e205
to
ef7c49d
Compare
reana/reana_dev/git.py
Outdated
) | ||
_create_commit_or_amend(components) | ||
ctx.invoke(git_diff, component=component) | ||
if click.confirm("Do you want to push your feature branches?"): |
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.
Instead of having an interactive question, what about adding a new --push
CLI option, similarly to the git-merge
command, and only push when --push
option is passed? (By default, it would not be.) Advantage: consistent behaviour of several git-...
commands improves UX.
reana/reana_dev/utils.py
Outdated
component=component, | ||
) | ||
replace_string( | ||
file_="requirements.txt", |
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.
Updating requirements.txt
should be optional, because e.g. r-client
does not contain it.
Currently it gives an error:
$ reana-dev git-upgrade-shared-modules -c r-client --create-new-version-bump-commit
...
[2020-08-11T11:10:33] : cat requirements.txt | grep -n -e "reana-commons.*==" | cut -f1 -d:
cat: requirements.txt: No such file or directory
Expected behaviour is: if requirements.txt file exists, update it; otherwise continue.
reana/reana_dev/git.py
Outdated
" shared modules points at a tag, in other case, the command will be aborted.", | ||
) | ||
@click.option( | ||
"--create-new-version-bump-commit", |
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.
Upon second thought, what about inverting the logic and creating new version bump commit by default unless --amend
is passed? Advantage: it would behave just like git
, so less surprises for people.
If we like it, then:
- let's rename
--create-new-version-bump-commit
to--amend
- let's make it false by default
- let's invert the implementation to always make release commits unless
--amend
is used.
WDYT?
ef7c49d
to
2299fde
Compare
2299fde
to
45fe7a6
Compare
reana/reana_dev/git.py
Outdated
" If so, a commit and a PR with" | ||
' "installation: shared packages version bump" message will' | ||
" be created for all affected CLUSTER components.", | ||
help="Should the changes be integrated as part of the latest commit of each component?.", |
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.
End phrase with ?
instead of ?.
reana/reana_dev/git.py
Outdated
"--push", | ||
is_flag=True, | ||
default=False, | ||
help="Should the feature branches with the upgrades be pushed?.", |
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.
End phrase with ?
instead of ?.
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.
... also, "be pushed to origin?" because elsewhere in other r-dev commands we are pushing to both origin/upstream... so it may help to be more explicit here.
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.
All good, left final 2-3 cosmetic comments for the help strings
45fe7a6
to
ccb00ee
Compare
closes #365
TODO
git-upgrade-shared-modules
(the one that creates PRs)