-
Notifications
You must be signed in to change notification settings - Fork 14
LITE-33583: bump extension projects to the latest runner #254
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
base: fix/LITE-33583-bootstrap-dependency-mismatch
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ | |
| get_event_definitions, | ||
| get_pypi_runner_requirements, | ||
| get_pypi_runner_version, | ||
| get_pypi_runner_version_by_connect_version, | ||
| initialize_git_repository, | ||
| ) | ||
| from connect.cli.plugins.project.extension.wizard import ( | ||
|
|
@@ -246,11 +245,37 @@ def _update_docker_file_runner_from(dockerfile: str, latest_version: str): | |
| return to_be_replaced | ||
|
|
||
|
|
||
| def _update_pyproject_runner_deps(pyproject_file, latest_version): | ||
| connect_eaas_core_version, python_version = get_pypi_runner_requirements(latest_version) | ||
| new_values = {'python': python_version, 'connect-eaas-core': connect_eaas_core_version} | ||
| to_be_replaced = False | ||
| section = None | ||
| lines = [] | ||
| with open(pyproject_file, 'r') as f: | ||
| for line in f.readlines(): | ||
| stripped = line.strip() | ||
| if stripped.startswith('['): | ||
| section = stripped | ||
| elif section == '[tool.poetry.dependencies]': | ||
| # ponytail: handles the plain `name = "spec"` form bootstrap emits; a | ||
| # table form ({ version = ... }) gets rewritten to the plain form | ||
| key = stripped.split('=', 1)[0].strip() | ||
| new_value = new_values.get(key) | ||
| if new_value and stripped != f'{key} = "{new_value}"': | ||
| line = f'{key} = "{new_value}"\n' | ||
| to_be_replaced = True | ||
|
Comment on lines
+264
to
+266
Member
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. This loop only matches keys written as |
||
| lines.append(line) | ||
| if to_be_replaced: | ||
| with open(pyproject_file, 'w') as f: | ||
| f.writelines(lines) | ||
| return to_be_replaced | ||
|
|
||
|
|
||
| def bump_runner_extension_project(project_dir: str): # noqa: CCR001 | ||
| console.secho(f'Bumping runner version on project {project_dir}...\n', fg='blue') | ||
|
|
||
| updated_files = set() | ||
| latest_version = get_pypi_runner_version_by_connect_version() | ||
| latest_version = get_pypi_runner_version() | ||
| latest_runner_version = f'cloudblueconnect/connect-extension-runner:{latest_version}' | ||
| docker_compose_file = os.path.join(project_dir, 'docker-compose.yml') | ||
| if not os.path.isfile(docker_compose_file): | ||
|
|
@@ -294,6 +319,13 @@ def bump_runner_extension_project(project_dir: str): # noqa: CCR001 | |
| f'Error: {error}', | ||
| ) | ||
|
|
||
| pyproject_file = os.path.join(project_dir, 'pyproject.toml') | ||
| if os.path.isfile(pyproject_file) and _update_pyproject_runner_deps( | ||
| pyproject_file, | ||
| latest_version, | ||
| ): | ||
| updated_files.add(pyproject_file) | ||
|
|
||
| if updated_files: | ||
| console.secho( | ||
| f'Runner version has been successfully updated to {latest_version}. The following ' | ||
|
|
||
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.
Two things about this comment. First, rewriting a table form to the plain form also drops any extra fields on that line, such as
extras,markers,optional, orsource. Second, and worse, a value that spans more than one line breaks. The code only rewrites the first line, so the leftover lines ({ ... },and]) stay behind and the file is no longer valid TOML. This is unlikely forpythonandconnect-eaas-core, but if it happens the project stops building. If you keep this approach, please add one line to the comment saying it only supports single-line values.