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
Merged
Show file tree
Hide file tree
Changes from 111 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
082974d
Initial test pipeline
gurkanindibay Mar 31, 2021
e332ab5
Fix path problem
gurkanindibay Mar 31, 2021
831ca88
Add update_package_properties and its unit tests
gurkanindibay Mar 31, 2021
27f2c88
Remove github token from scripts
gurkanindibay Mar 31, 2021
5fcd72b
Fix requirements.txt path
gurkanindibay Mar 31, 2021
2eae7db
Remove unattended upgrades since gives error
gurkanindibay Mar 31, 2021
ffeeaa4
Remove unneccessary pkgvars file
gurkanindibay Mar 31, 2021
6c7332f
Merge branch 'tools-transition' of https://github.com/citusdata/tools…
gurkanindibay Mar 31, 2021
02f4452
Update tool-tests.yml
gurkanindibay Mar 31, 2021
271e0d4
Update requirements path
gurkanindibay Mar 31, 2021
6f2f692
Update test path
gurkanindibay Mar 31, 2021
0d5079a
Add missing requirements
gurkanindibay Mar 31, 2021
09fcf54
Remove missing package from requirements
gurkanindibay Mar 31, 2021
eddb078
Fix Paths for test
gurkanindibay Mar 31, 2021
e8318ad
Install python 3.9
gurkanindibay Mar 31, 2021
a98f448
Install python 3.9
gurkanindibay Mar 31, 2021
28ffcd1
Change removeprefix and removesuffix since this features are python 3…
gurkanindibay Apr 1, 2021
9189081
Add validation for GITHUB_TOKEN
gurkanindibay Apr 1, 2021
b34d6e5
Fix validation for GITHUB_TOKEN
gurkanindibay Apr 1, 2021
cb83901
Add parameter GH_TOKEN into pipeline yml
gurkanindibay Apr 1, 2021
a325539
Remove logs and fix name for the last task
gurkanindibay Apr 1, 2021
476ab31
Fix missing parameter problems on update_al_changes
gurkanindibay Apr 1, 2021
72605a5
Fix bash command
gurkanindibay Apr 1, 2021
f353723
Add update package properties
gurkanindibay Apr 1, 2021
7e86b5d
Add flags to make script fail when a step fail
gurkanindibay Apr 1, 2021
db00b6a
remove parameter set on update_package_properties.sh to get these par…
gurkanindibay Apr 1, 2021
03f4e8f
Fix some static code warnings
gurkanindibay Apr 2, 2021
69f06f0
Merge branch 'tools-transition' of https://github.com/citusdata/tools…
gurkanindibay Apr 2, 2021
9cf2e12
Remove unnecessary files
gurkanindibay Apr 2, 2021
6fa30fe
Change pipeline name
gurkanindibay Apr 2, 2021
eaa0484
Add pycache files into gitignore
gurkanindibay Apr 3, 2021
094699d
Add prepare release script
gurkanindibay Apr 7, 2021
25d7ebb
Add checkout for citus project for testing
gurkanindibay Apr 7, 2021
b35c6ef
Change directory to execute tests in folder
gurkanindibay Apr 7, 2021
b4078c6
Add test suffix into branch name to test the branch
gurkanindibay Apr 7, 2021
3c95b3d
Fix master update branch name
gurkanindibay Apr 7, 2021
365dede
Add unit tests,fix problems on prepare_release
gurkanindibay Apr 9, 2021
ec33dba
Remove unnecessary local test file
gurkanindibay Apr 9, 2021
a737746
Add Prepare release into tools test pipeline
gurkanindibay Apr 9, 2021
0d7ba17
Add git config info to pull git repo for
gurkanindibay Apr 9, 2021
fecb105
Simplified git ignore of pycache
gurkanindibay Apr 12, 2021
eb6ea07
Remove useless files
gurkanindibay Apr 12, 2021
394fae4
Merge branch 'tools-transition' of https://github.com/citusdata/tools…
gurkanindibay Apr 12, 2021
3e039cf
Removed useless comments on pipeline file
gurkanindibay Apr 12, 2021
d9e267c
Add missing emptylines
gurkanindibay Apr 12, 2021
4fa9f9d
Transform long methpod parameters into class
gurkanindibay Apr 12, 2021
ad2bffc
Use getenv default values handling logic
gurkanindibay Apr 12, 2021
fb4199e
Add new line at the end of some files
gurkanindibay Apr 12, 2021
3855dd2
Add missing dependencies for pycurl
gurkanindibay Apr 12, 2021
0b47a81
Remove unnecessary package unattended-upgrades
gurkanindibay Apr 12, 2021
ef50082
Add pytest execution command on pipeline file
gurkanindibay Apr 12, 2021
46c07f2
Add __init__.py files for module definitions
gurkanindibay Apr 12, 2021
4aa84b4
Propagate PR #90 update_package_properties changes into PR #91 prepa…
gurkanindibay Apr 13, 2021
9bff43c
Add validation controls into ChangelogParams
gurkanindibay Apr 13, 2021
b015bf6
Propagate validation changes
gurkanindibay Apr 13, 2021
872ff5c
Remove unused imports
gurkanindibay Apr 13, 2021
22fc213
Change the release_date datatype into datetime to
gurkanindibay Apr 13, 2021
8a706d0
Propagate datatime type match of release_date
gurkanindibay Apr 13, 2021
39606ba
Move test_prepare_release into pytest
gurkanindibay Apr 13, 2021
e55710c
Fix spec file rpm version problem which causes
gurkanindibay Apr 13, 2021
8698ee1
Fix missing project name problem on rpm spec
gurkanindibay Apr 13, 2021
1bb9bea
Remove empty character that cause tests fail
gurkanindibay Apr 13, 2021
b4d1761
Fix pkgvars version style
gurkanindibay Apr 13, 2021
b68a5bc
Propagate PR #90 update_package_properties fixes into PR #91 prepare…
gurkanindibay Apr 13, 2021
c13b72c
Simplify method find_nth_overlapping_line_by_regex
gurkanindibay May 3, 2021
a2e8aef
Fix pr #91 comments
gurkanindibay May 4, 2021
85dc231
Clarify method name
gurkanindibay May 4, 2021
acf19f7
Fix for unit tests
gurkanindibay May 4, 2021
3aa3f98
Fix for unit tests
gurkanindibay May 4, 2021
a956c2a
Fix unit test method rename problem
gurkanindibay May 4, 2021
1330096
Fix round 2 PR #91 comments
gurkanindibay May 7, 2021
0b9b606
* Merge Develop into this branch
gurkanindibay May 20, 2021
ffb1142
Fix python build problem related to ubuntu
gurkanindibay May 20, 2021
c40558f
Add GitPython to fix build
gurkanindibay May 20, 2021
217ccf2
Add git credentials to checkout fix
gurkanindibay May 20, 2021
8461511
Add new lines into the end of files that don't
gurkanindibay May 20, 2021
1273fe2
Shorten getting date from environment to make
gurkanindibay May 20, 2021
89c0e63
Shorten getting date from environment to make
gurkanindibay May 20, 2021
b89e7eb
Remove project_version parameter from input parameters
gurkanindibay May 24, 2021
14159a4
Fix for @hanefi's review round 1 for PR #91
gurkanindibay May 25, 2021
551fade
Fix for first part of comments of @onur for PR #91
gurkanindibay May 26, 2021
b869041
Fix for second part of comments of @onur for PR #91
gurkanindibay May 27, 2021
48ff45c
Remove unnecessary test file
gurkanindibay May 27, 2021
d75a8cf
Fix missing method import problem for
gurkanindibay May 27, 2021
e62e3bc
Execute unit tests and fix bugs
gurkanindibay May 27, 2021
a85e2f2
Merge remote-tracking branch 'origin/develop' into tools-transition-p…
gurkanindibay May 28, 2021
34b2514
ADd missing MAIN_BRANCH variable to fix build
gurkanindibay May 28, 2021
7e72c1f
Fix formatting of python command
gurkanindibay May 28, 2021
6860248
Fix round 3 of comments of @hanefi and @onur
gurkanindibay May 28, 2021
901ea18
Fix test execution problem
gurkanindibay May 28, 2021
fa1005a
Format log messages
gurkanindibay May 28, 2021
9193cf6
Add init function for prepare_release to execute
gurkanindibay May 31, 2021
cd390b6
Add extension updates on multi_extension files
gurkanindibay Jun 1, 2021
addc33e
* Implement clone in init function
gurkanindibay Jun 2, 2021
7307718
* Fix some bugs in corner cases
gurkanindibay Jun 2, 2021
634c931
* Remove unnecessary logs
gurkanindibay Jun 2, 2021
5e1e907
Fix round #4 review notes from @onur
gurkanindibay Jun 3, 2021
9c1c198
Fix unit test error on test release branch
gurkanindibay Jun 3, 2021
ae37809
Use store_true argument for boolean values
gurkanindibay Jun 3, 2021
080f34a
Remove unnecessary log
gurkanindibay Jun 3, 2021
616f253
Add remote and local branch checks
gurkanindibay Jun 4, 2021
48768d9
Fix unit test for local branch check
gurkanindibay Jun 4, 2021
ee70e54
Fix unit test for remote branch check
gurkanindibay Jun 4, 2021
3ba99ef
Add remote and local branch checks on prepare
gurkanindibay Jun 4, 2021
bfffcb8
Use citus as test source
gurkanindibay Jun 7, 2021
3aac329
Fix version update error on major execution
gurkanindibay Jun 9, 2021
81a4413
Fix unit test errors while teardown test
gurkanindibay Jun 9, 2021
db1b32e
* Remove unnecessary imports
gurkanindibay Jun 9, 2021
5fbb9bc
* Add comment on append line and prepend line
gurkanindibay Jun 10, 2021
1d4ec86
Fix configure.in project name for citus enterprise
gurkanindibay Jun 10, 2021
2abe570
Add readme for prepare-release script
gurkanindibay Jun 10, 2021
f91c2dc
Remove sudo from rm statement
gurkanindibay Jun 10, 2021
25ff7c1
Remove does prefix from does_branch_exist
gurkanindibay Jun 11, 2021
64aec37
Fix parameter names in README
gurkanindibay Jun 11, 2021
c53aa9c
Remove unnecessary files
gurkanindibay Jun 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/tool-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 👍

env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
MICROSOFT_EMAIL: [email protected]
USER_NAME: Gurkan Indibay
MAIN_BRANCH: all-citus

on:
push:
Expand All @@ -25,10 +28,14 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Define git credentials
run: git config --global user.email "${MICROSOFT_EMAIL}"&& git config --global user.name "${USER_NAME}"
- name: Install package dependencies
run: sudo apt install libcurl4-openssl-dev libssl-dev
- name: Install python requirements
run: python -m pip install -r python/requirements.txt
- name: Execute unit tests
run: python -m pytest -q python/tests/test_update_package_properties.py
run: python -m pip install -r packaging_automation/requirements.txt
- name: Execute unit tests for "Update Package Properties"
run: python -m pytest -q packaging_automation/tests/test_update_package_properties.py
- name: Execute unit tests for "Prepare Release"
run: python -m pytest -q packaging_automation/tests/test_prepare_release.py

14 changes: 11 additions & 3 deletions bash/update_package_properties.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@ commit_message="Bump to ${PRJ_NAME} ${PRJ_VER}"

git checkout -b "${pr_branch_name}"

python tools/python/update_package_properties.py --gh_token "${GH_TOKEN}" --prj_name "${PRJ_NAME}" --prj_ver "${PRJ_VER}" --tag_name "${TAG_NAME}" --fancy "${FANCY}" \
--fancy_ver_no "${FANCY_VERSION_NO}" --email "${MICROSOFT_EMAIL}" --name "${NAME}" --date "$(date '+%Y.%m.%d %H:%M:%S %z')" --exec_path "$(pwd)"
python tools/python/update_package_properties.py --gh_token "${GH_TOKEN}" \
--prj_name "${PRJ_NAME}" \
--tag_name "${TAG_NAME}" \
--fancy "${FANCY}" \
--fancy_ver_no "${FANCY_VERSION_NO}" \
--email "${MICROSOFT_EMAIL}" \
--name "${NAME}" \
--date "$(date '+%Y.%m.%d %H:%M:%S %z')" \
--exec_path "$(pwd)"

git commit -a -m "${commit_message}"

echo "{\"title\":\"${commit_message}\", \"head\":\"${pr_branch_name}\", \"base\":\"${main_branch_name}\"}"

git push origin "${pr_branch_name}"

curl -g -H "Accept: application/vnd.github.v3.full+json" -X POST --user "${GH_TOKEN}:x-oauth-basic" -d "{\"title\":\"${commit_message}\", \"head\":\"${pr_branch_name}\", \"base\":\"${main_branch_name}\"}" https://api.github.com/repos/citusdata/packaging/pulls
curl -g -H "Accept: application/vnd.github.v3.full+json" -X POST --user "${GH_TOKEN}:x-oauth-basic" -d \
"{\"title\":\"${commit_message}\", \"head\":\"${pr_branch_name}\", \"base\":\"${main_branch_name}\"}" https://api.github.com/repos/citusdata/packaging/pulls
79 changes: 79 additions & 0 deletions packaging_automation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# **Prepare Release Usage**

prepare-release.py script performs the pre-packaging configurations in citus/citus-enterprise projects.

## Installation

Before using script, you need to make sure that Python > 3.8 is installed in your system.

### Clone Tools Repository

git clone https://github.com/citusdata/tools.git

Enter 'tools' directory

``` console
cd tools
```

### Install Required Python Libraries

Verify pip installation

``` console
python -m pip --version
```
Output should be like following

``` console
pip 21.1.2 from /home/vagrant/.local/lib/python3.8/site-packages/pip (python 3.8)
```

If you get error, you should first install pip
``` console
sudo apt install python3-pip
```
Install the required libraries to execute the script
``` console
python -m pip install -r packaging_automation/requirements.txt
```
If all the steps above completed successfully , you are ready for script execution

## Script Usage

Script can be used for either major release (i.e. third digit of release is '0' e.g. 10.1.0) or
patch release (i.e. third digit of release is other than '0' e.g. 10.0.4).

### Available flags

**--gh_token:** Personal access token that is authorized to commit citus/citus-enterprise projects. (Required)

**--prj_name:** Project to be released. Allowed values 'citus' and 'citus-enterprise (Required)

**--prj_ver:** Upcoming version to be used for release. should include three level of digits separated by dots, e.g: 10.0.1
(Required)

**--main-branch:** Branch to be used as base to be used for configuration changes. There is no need for base scenario.
onurctirtir marked this conversation as resolved.
Show resolved Hide resolved
This flag can be used for testing purposes. If not used, default branch value is used; i.e. for 'citus' 'master, for 'citus-enterprise' 'enterprise-master'

**--is_test:** If used, branches would not be pushed remote repository and created release branches would be prefixed with 'test'. Default value is False

**--cherry_pick_enabled:** Available only for patch release. If used, --earliest_pr_date flag also should be used.Gets all PR's with 'backport' label created after earliest_pr_date

**--earliest_pr_date:** Used with --cherry-pick-enabled flag. Date format is 'Y.m.d' e.g 2012.01.21. PR's merged after this date would be listed and cherry-picked.

**--schema-version:** Available only for patch release. If used, schema version in citus.control file would be updated.

###Example Usage

####Major
``` console
python -m packaging_automation.prepare_release --gh_token <your-personal-token> --prj_name citus --prj_ver 10.1.0
```
#### 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"]

```



File renamed without changes.
Loading