From e8566298dc222e6c7176e61790f927f2f832af34 Mon Sep 17 00:00:00 2001 From: Alan Chin Date: Fri, 2 Dec 2022 14:25:34 -0800 Subject: [PATCH] Add lockfile creation to new releases Signed-off-by: Alan Chin --- Makefile | 8 +++++--- build_requirements.txt | 2 +- create-release.py | 27 +++++++++++++++++++++++---- pyproject.toml | 2 +- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 9f73c79d1..796d832fd 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ .PHONY: lint-dependencies lint-server black-format prettier-check-ui eslint-check-ui prettier-ui eslint-ui lint-ui lint .PHONY: dev-link dev-unlink .PHONY: build-dependencies dev-dependencies yarn-install build-ui package-ui package-ui-dev -.PHONY: build-server install-server-package install-server +.PHONY: build-server buiid-lockfile install-server-package install-server .PHONY: install install-all install-dev install-examples install-gitlab-dependency check-install watch release .PHONY: test-dependencies pytest test-server test-ui-unit test-integration test-integration-debug test-ui test .PHONY: docs-dependencies docs @@ -61,7 +61,7 @@ help: ## Clean targets purge: - rm -rf build *.egg-info yarn-error.log + rm -rf build *.egg-info requirements.txt yarn-error.log rm -rf node_modules lib dist rm -rf $$(find packages -name node_modules -type d -maxdepth 2) rm -rf $$(find packages -name dist -type d) @@ -173,6 +173,9 @@ package-ui-dev: dev-dependencies yarn-install dev-link lint-ui build-ui build-server: # Build backend $(PYTHON) -m build +build-lockfile: # Build requirements.txt + pip-compile --generate-hashes pyproject.toml + uninstall-server-package: @$(PYTHON_PIP) uninstall elyra -y @@ -206,7 +209,6 @@ watch: ## Watch packages. For use alongside jupyter lab --watch release: yarn-install build-ui build-server ## Build wheel file for release - elyra-image-env: ## Creates a conda env consisting of the dependencies used in images conda env remove -y -n $(ELYRA_IMAGE_ENV) conda create -y -n $(ELYRA_IMAGE_ENV) python=$(PYTHON_VERSION) --channel conda-forge diff --git a/build_requirements.txt b/build_requirements.txt index bed008151..8b330039d 100644 --- a/build_requirements.txt +++ b/build_requirements.txt @@ -1,3 +1,3 @@ jupyterlab>=3.4.6,<4.0 -jupyter-packaging>=0.10 build +pip-tools diff --git a/create-release.py b/create-release.py index 2609cb062..6ab212ec3 100755 --- a/create-release.py +++ b/create-release.py @@ -92,6 +92,8 @@ def validate_dependencies() -> None: raise DependencyException("Please install yarn https://classic.yarnpkg.com/") if not dependency_exists("twine"): raise DependencyException("Please install twine https://twine.readthedocs.io/en/latest/#installation") + if not dependency_exists("pip-compile"): + raise DependencyException("Please install pip-tools https://pypi.org/project/pip-tools/") def validate_environment() -> None: @@ -102,6 +104,8 @@ def validate_environment() -> None: def update_version_to_release() -> None: global config + print(f"Updating documentation to Release v{config.new_version}") + old_version = config.old_version old_npm_version = config.old_npm_version new_version = config.new_version @@ -258,6 +262,8 @@ def update_version_to_release() -> None: ) check_run(["yarn", "version", "--new-version", new_npm_version, "--no-git-tag-version"], cwd=config.source_dir) + print(f"Finished updating documentation to Release v{config.new_version}") + except Exception as ex: raise UpdateVersionException from ex @@ -500,6 +506,14 @@ def build_server(): print("") +def create_requirements_lockfile(): + print("-----------------------------------------------------------------") + print("--------------------- Creating Lockfile -------------------------") + print("-----------------------------------------------------------------") + check_run(["pip-compile", "--generate-hashes", "pyproject.toml"], cwd=config.source_dir, capture_output=False) + check_run(["git", "add", "requirements.txt"], cwd=config.source_dir, capture_output=False) + + def show_release_artifacts(): global config dist_dir = os.path.join(config.source_dir, "dist") @@ -734,7 +748,7 @@ def prepare_changelog() -> None: generate_changelog() # commit check_run( - ["git", "commit", "-a", "-m", f"Update changelog for release {config.new_version}"], cwd=config.source_dir + ["git", "commit", "-a", "-s", "-m", f"Update changelog for release {config.new_version}"], cwd=config.source_dir ) @@ -750,11 +764,16 @@ def prepare_release() -> None: checkout_code() # generate changelog with new release list of commits prepare_changelog() + # create requirements lock file + create_requirements_lockfile() # Update to new release version update_version_to_release() # commit and tag - check_run(["git", "commit", "-a", "-m", f"Release v{config.new_version}"], cwd=config.source_dir) - check_run(["git", "tag", config.tag], cwd=config.source_dir) + print(f"Committing changes for release v{config.new_version}") + check_run(["git", "commit", "-a", "-s", "-m", f"Release v{config.new_version}"], cwd=config.source_dir) + # Ensure you have tags.gpgSign set to True and user.signingkey configured via git config + print(f"Creating tag for release v{config.new_version}") + check_run(["git", "tag", config.tag, "-m", f"Release v{config.new_version}"], cwd=config.source_dir) # server-only wheel build_server() # build release wheel and npm artifacts @@ -764,7 +783,7 @@ def prepare_release() -> None: # back to development update_version_to_dev() # commit - check_run(["git", "commit", "-a", "-m", f"Prepare for next development iteration"], cwd=config.source_dir) + check_run(["git", "commit", "-a", "-s", "-m", f"Prepare for next development iteration"], cwd=config.source_dir) # prepare extensions prepare_extensions_release() # prepare runtime extsnsions diff --git a/pyproject.toml b/pyproject.toml index bd7f44f3b..1e9b897c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ maintainers = [ readme = "README.md" requires-python = ">=3.7" dependencies = [ - "autopep8>=1.5.0", + "autopep8>=1.5.0,<1.7.0", # Cap from python-lsp-server "click>=8", # elyra-ai/elyra#2579 "colorama", "deprecation",