-
Notifications
You must be signed in to change notification settings - Fork 570
chore: add checking package file count comparison in release script #547
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
Changes from all commits
35b85a0
f6ad28e
35a78db
354cb62
f48f82c
447fdd5
ffabd49
dc2f85a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,13 +13,20 @@ | |
| # limitations under the License. | ||
| """Release script to publish release module to pipy.""" | ||
|
|
||
| import glob | ||
| import io | ||
| import os | ||
| import shutil | ||
| import subprocess | ||
| import sys | ||
| from typing import List | ||
|
|
||
| VERSION_FILE_PATH = os.path.join(os.path.dirname('__file__'), 'appium', 'version.py') | ||
| CHANGELOG_PATH = os.path.join(os.path.dirname('__file__'), 'CHANGELOG.rst') | ||
|
|
||
| APPIUM_DIR_PATH = os.path.join(os.path.dirname('__file__'), 'appium') | ||
| BUILT_APPIUM_DIR_PATH = os.path.join(os.path.dirname('__file__'), 'build', 'lib', 'appium') | ||
|
|
||
| MESSAGE_RED = '\033[1;31m{}\033[0m' | ||
| MESSAGE_GREEN = '\033[1;32m{}\033[0m' | ||
| MESSAGE_YELLOW = '\033[1;33m{}\033[0m' | ||
|
|
@@ -101,6 +108,41 @@ def validate_release_env(): | |
| exit("Please get twine via 'pip install gitchangelog' or 'pip install git+git://github.com/vaab/gitchangelog.git' for Python 3.7") | ||
|
|
||
|
|
||
| def build() -> None: | ||
| shutil.rmtree(BUILT_APPIUM_DIR_PATH, ignore_errors=True) | ||
| status, output = subprocess.getstatusoutput('{} setup.py install'.format(os.getenv('PYTHON_BIN_PATH'))) | ||
| if status != 0: | ||
| exit(f'Failed to build the package:\n{output}') | ||
|
|
||
|
|
||
| def get_py_files_in_dir(root_dir: str) -> List[str]: | ||
| return [ | ||
| file_path[len(root_dir):] | ||
|
Contributor
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. so pythonic 🙀 |
||
| for file_path in glob.glob(f"{root_dir}/**/*.py", recursive=True) + glob.glob(f"{root_dir}/**/*.typed", recursive=True) | ||
| ] | ||
|
|
||
|
|
||
| def assert_files_count_in_package() -> None: | ||
| original_files = get_py_files_in_dir(APPIUM_DIR_PATH) | ||
| built_files = get_py_files_in_dir(BUILT_APPIUM_DIR_PATH) | ||
|
|
||
| if len(original_files) != len(built_files): | ||
|
mykola-mokhnach marked this conversation as resolved.
|
||
| print(f"The count of files in '{APPIUM_DIR_PATH}' and '{BUILT_APPIUM_DIR_PATH}' were different.") | ||
|
|
||
| original_files_set = set(original_files) | ||
| built_files_set = set(built_files) | ||
|
|
||
| diff = original_files_set.difference(built_files_set) | ||
|
Contributor
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.
Member
Author
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. ah, often used the way in Ruby. Cool |
||
| if diff: | ||
| print(f"'{APPIUM_DIR_PATH}' has '{diff}' files than {BUILT_APPIUM_DIR_PATH}") | ||
| diff = built_files_set.difference(original_files_set) | ||
| if diff: | ||
| print(f"{BUILT_APPIUM_DIR_PATH} has {diff} files than {APPIUM_DIR_PATH}") | ||
|
|
||
| exit(f"Python files in '{BUILT_APPIUM_DIR_PATH}' may differ from '{APPIUM_DIR_PATH}'. " | ||
| "Please make sure setup.py is configured properly.") | ||
|
|
||
|
|
||
| def main(): | ||
| validate_release_env() | ||
|
|
||
|
|
@@ -109,6 +151,9 @@ def main(): | |
|
|
||
| update_version_file(new_version) | ||
|
|
||
| build() | ||
| assert_files_count_in_package() | ||
|
|
||
| ensure_publication(new_version) | ||
|
|
||
| commit_version_code(new_version) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
You can do the same thing as below. (maybe same?)
(jfyi) https://docs.python.org/3/library/glob.html
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.
ah, recursive is available in 3