Skip to content
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

Tools transition prepare release #91

Merged
merged 115 commits into from
Jun 11, 2021

Conversation

gurkanindibay
Copy link
Contributor

No description provided.

gurkanindibay and others added 30 commits March 31, 2021 18:00
Move changelog into test dir
….9 features but GithubActions environment is 3.8.5
Add checks to prevent
Add checks and test cases to prevent multiple changelog add
Add trigger to run on all branches and pr requests
@@ -2,6 +2,9 @@ name: Tool Tests

Copy link
Member

@onurctirtir onurctirtir Jun 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sharing some additional comments from my manual testing:

  • Minor release flow seems pretty fine.

  • Major release flow:
    Release branch creation works fine.
    But the changes made for master branch doesn't seem to be correct. Please check with the commit that I shared before

  • Getting some errors after running the script for the second time:

....
....
subprocess.CalledProcessError: Command 'git checkout -b release-10.2-test' returned non-zero exit status 128.
  • For the missing/incorrect parameters, I would expect throwing errors beforehand, but for the most, we throw the error in very deeper levels (like when using github api or when splitting a string etc.).
    Let's make some correctness checks for them at the very beginning of our main entrypoint.
    I think we can have a function to do those checks such as check_args or something.

  • In initialize_env function, we should decide which repo to clone according to prj_name arg.
    It can be either "citus" or "citus-enterprise". So I think we can use add_arg(..choices=..) for that.

  • For --is_test & cherry_pick_enabled params, I think we can use add_arg(..action='store_true'.., instead of requiring to pass "True" string.

  • For schema_version, I think we should error if it's passed for major release.
    But we should be okay if it is passed or not passed for patch release.

  • I think we should set add_arg(..required=true..), for prj_ver, main_branch & gh_token.

  • We should error if either of cherry_pick_enabled or earliest_pr_date is set for major release.
    But we should be okay if it is passed or not passed for patch release.

  • We should error if cherry_pick_enabled is set to true but earliest_pr_date is not given.

  • Can we simplify earliest_pr_date format, like just '%Y.%m.%d ? I don't think we need to know hour, minute etc. ever.

  • Seems that we currently don't use exec_path arg, can we remove that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed all of them except the action="store_true" parameters because when this parameter is used, it can not be set by user. It sets a constant variable not suitable for user-defined parameters

Copy link
Member

@onurctirtir onurctirtir Jun 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually think it cannot be set by user.
Assuming is_test arg, using store_true means:
If user doesn't add --is_test, then is_test would automatically evaluate to false, so we will disable test mode.
If user puts --is_test into the args (without any additional strings), then argparese should interpret is_test as true.

https://stackoverflow.com/a/8203679/13370386

Is there any reason for not using that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't totally grasped the parameter. As you referenced, I understood and changed that way thanks 👍

* Fix  cloned directory deletion error
* Add repo parameter to support citus-enterprise
* Add default value for main branch
* Use some argparse features to improve UX
* Add some more validations
@gurkanindibay gurkanindibay requested a review from onurctirtir June 3, 2021 08:44
@hanefi hanefi self-requested a review June 8, 2021 15:10
Copy link
Member

@onurctirtir onurctirtir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine for community releases, but there are some problems with enterprise releases.
Please fix those problems by comparing the example commits that I shared via Teams chat.


Also, please add a good readme on how to use this script. Sharing an example in below, let's use a nicer wording.
Also please use your reasoning to make our README user-friendly. For example, you can consider a scenario where someone other than me or Hanefi does the prepare release stage:

(file name is something like README-prepare-release / README-prepare-release.txt)

First make sure that you have the dependencies for our script:
< one liner instruction to install dependencies >

For both major & patch release, provide `--prj-name` either as "citus" or "citus-enterprise".
Also provide `--main_branch` as `master` or `enterprise-master` depending on --prj-name` param.

For major release, do:
python3.x something --some params -- other params --an example version

For patch release, do:
python3.x something --some params -- other params --an example version

If you would like to bump the schema version for the patch release, also add X param like:
python3.x something --some params -- other params --an example version

If you would like to cherry pick commits for a patch release, also add Y, X .. params like:
python3.x something --some params -- other params --an example version

packaging_automation/common_tool_methods.py Outdated Show resolved Hide resolved
return has_match


def append_line_in_file(file: str, match_regex: str, append_str: str) -> bool:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't quite understand what we are exactly doing in append_line_in_file & prepend_line_in_file.

Can you improve the readability of those two functions, or at least let's comment why do we do anIndex +1 / anIndex +2 kind of things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

packaging_automation/common_tool_methods.py Outdated Show resolved Hide resolved
packaging_automation/common_tool_methods.py Outdated Show resolved Hide resolved
commits = pr.get_commits()
for single_commit in commits:
if not is_merge_commit(single_commit):
cp_result = run(f"git cherry-pick {single_commit.commit.sha}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually use -x parameter to cherry-pick the commits:

       -x
           When recording the commit, append a line that says "(cherry picked from commit ...)" to the original
           commit message in order to indicate which commit this change was cherry-picked from. ...
Suggested change
cp_result = run(f"git cherry-pick {single_commit.commit.sha}")
cp_result = run(f"git cherry-pick -x {single_commit.commit.sha}")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Member

@onurctirtir onurctirtir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty much fine to me, thank you for all the work & addressing the comments.
Please follow squash strategy to merge your pr.

Left some minor final notes:

  1. I run the script a few times and only in one of them it asked for sudo, not in the others.
    Might worth to make sure that we fixed that issue.

  2. Seeing three files like test1e58b070-b0bb-4f78-9ae4-3672bd131097, do we ever use them (and why) ? If not, can we remove them ?

  3. For patch releases, we create two (release) test branches, can we avoid creating the later one (the one with uuid suffix) ?:

  release-10.0-test
  release-10.0-test_da502a7a-109e-44d5-92c6-d042e095b7e0

```
#### Patch
``` console
python -m packaging_automation.prepare_release --gh_token <your-personal-token> --prj_name citus-enterprise --prj_ver 10.0.4 --schema_version 10.0-5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also add here --main-branch enterprise-master

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to add main-branch because main branch is set by project_name if not given as parameter

main_branch = arguments.main_branch if arguments.main_branch else repo_details[arguments.prj_name]["branch"]

packaging_automation/README.md Outdated Show resolved Hide resolved
@gurkanindibay
Copy link
Contributor Author

Looks pretty much fine to me, thank you for all the work & addressing the comments.
Please follow squash strategy to merge your pr.

Left some minor final notes:

  1. I run the script a few times and only in one of them it asked for sudo, not in the others.
    Might worth to make sure that we fixed that issue.
  2. Seeing three files like test1e58b070-b0bb-4f78-9ae4-3672bd131097, do we ever use them (and why) ? If not, can we remove them ?
  3. For patch releases, we create two (release) test branches, can we avoid creating the later one (the one with uuid suffix) ?:
  release-10.0-test
  release-10.0-test_da502a7a-109e-44d5-92c6-d042e095b7e0
  1. I haven't experiences such an issue. I opened an issue about it. prepare release sometimes needs sudo #106
  2. Fixed
  3. The latter one with uuid is the one being used for PR. The other one with test is the release branch for test. If test is not used this branch will not be created. This branch is for testing purposes not to break release branches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants