-
Notifications
You must be signed in to change notification settings - Fork 1.5k
{CI} Fix extension release scripts #7275
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: main
Are you sure you want to change the base?
Changes from all commits
2517e69
bc3aed8
f2b7bab
87f519a
8906e0b
b6017d4
2c3d7a3
5de410e
0c3bb06
bfe5ed1
8a844b7
29f00c6
148eaf3
e8c767a
212f082
08f3b0a
bb4a4e2
218ca95
690b7ce
e8572a7
7447487
868a7b2
80a3c1c
6ac4465
9beaa14
8578db6
ac63598
50d18b4
6d0db41
9c84141
eac3fb4
49d26d1
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 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,13 +6,15 @@ | |||||||||||||||||||||
| import filecmp | ||||||||||||||||||||||
| import json | ||||||||||||||||||||||
| import os | ||||||||||||||||||||||
| import subprocess | ||||||||||||||||||||||
| import sys | ||||||||||||||||||||||
| import subprocess | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| from azure.cli.core import get_default_cli | ||||||||||||||||||||||
| from azure.cli.core._session import Session | ||||||||||||||||||||||
| from azure.cli.core.commands import _load_extension_command_loader | ||||||||||||||||||||||
| from azure.cli.core.extension import get_extension_modname, get_extension_path | ||||||||||||||||||||||
| from sync_extensions import download_file | ||||||||||||||||||||||
| from util import run_az_cmd | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| STORAGE_ACCOUNT = os.getenv('AZURE_EXTENSION_CMD_TREE_STORAGE_ACCOUNT') | ||||||||||||||||||||||
| STORAGE_CONTAINER = os.getenv('AZURE_EXTENSION_CMD_TREE_STORAGE_CONTAINER') | ||||||||||||||||||||||
|
|
@@ -22,6 +24,36 @@ | |||||||||||||||||||||
| file_name = 'extCmdTreeToUpload.json' | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def execute_command(command): | ||||||||||||||||||||||
| """Execute a shell command and return the output.""" | ||||||||||||||||||||||
| try: | ||||||||||||||||||||||
| result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) | ||||||||||||||||||||||
| if result.returncode == 0: | ||||||||||||||||||||||
| return result.stdout.strip() | ||||||||||||||||||||||
| else: | ||||||||||||||||||||||
| return f"Error: {result.stderr.strip()}" | ||||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||||
| return f"Exception: {str(e)}" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def get_package_version(package_name): | ||||||||||||||||||||||
| """Get the current version of a Python package.""" | ||||||||||||||||||||||
| command = ["pip", "show", package_name] | ||||||||||||||||||||||
| output = execute_command(command) | ||||||||||||||||||||||
| if "Version:" in output: | ||||||||||||||||||||||
| for line in output.splitlines(): | ||||||||||||||||||||||
| if line.startswith("Version:"): | ||||||||||||||||||||||
| version = line.split(":")[1].strip() | ||||||||||||||||||||||
| print(f"{package_name} current version: {version}") | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def upgrade_package(package_name): | ||||||||||||||||||||||
| """Upgrade a Python package to the latest version.""" | ||||||||||||||||||||||
| command = ["pip", "install", "--upgrade", package_name] | ||||||||||||||||||||||
| print(f"{command}") | ||||||||||||||||||||||
| return execute_command(command) | ||||||||||||||||||||||
|
Comment on lines
+39
to
+54
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def merge(data, key, value): | ||||||||||||||||||||||
| if isinstance(value, str): | ||||||||||||||||||||||
| if key in data: | ||||||||||||||||||||||
|
|
@@ -35,6 +67,16 @@ def merge(data, key, value): | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| def update_cmd_tree(ext_name): | ||||||||||||||||||||||
| print(f"Processing {ext_name}") | ||||||||||||||||||||||
| if ext_name == 'ml': | ||||||||||||||||||||||
| get_package_version("azure-storage-blob") | ||||||||||||||||||||||
| upgrade_package("azure-storage-blob") | ||||||||||||||||||||||
| get_package_version("azure-storage-blob") | ||||||||||||||||||||||
| get_package_version("rpds") | ||||||||||||||||||||||
| upgrade_package("rpds") | ||||||||||||||||||||||
| get_package_version("rpds") | ||||||||||||||||||||||
| get_package_version("rpds-py") | ||||||||||||||||||||||
| upgrade_package("rpds-py") | ||||||||||||||||||||||
| get_package_version("rpds-py") | ||||||||||||||||||||||
|
Comment on lines
+70
to
+79
|
||||||||||||||||||||||
| if ext_name == 'ml': | |
| get_package_version("azure-storage-blob") | |
| upgrade_package("azure-storage-blob") | |
| get_package_version("azure-storage-blob") | |
| get_package_version("rpds") | |
| upgrade_package("rpds") | |
| get_package_version("rpds") | |
| get_package_version("rpds-py") | |
| upgrade_package("rpds-py") | |
| get_package_version("rpds-py") |
Copilot
AI
Apr 1, 2026
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.
This PR is described as updating scripts per #7273 (encoding + --overwrite), but it also adds runtime package upgrades for ml and new helper functions. If these additions are intentional, it would help to update the PR description (or link the specific issue) so reviewers understand the extra scope and rationale.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,15 +3,14 @@ | |||||||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||||||||
| # -------------------------------------------------------------------------------------------- | ||||||||
|
|
||||||||
| import json | ||||||||
| import logging | ||||||||
| import os | ||||||||
| import re | ||||||||
| import shlex | ||||||||
| import json | ||||||||
| import subprocess | ||||||||
| import zipfile | ||||||||
|
|
||||||||
| from subprocess import check_output | ||||||||
|
|
||||||||
| logger = logging.getLogger(__name__) | ||||||||
|
|
||||||||
| # copy from wheel==0.30.0 | ||||||||
|
|
@@ -136,7 +135,7 @@ def diff_code(start, end): | |||||||
|
|
||||||||
| # If running in Travis CI, only run tests for edited extensions | ||||||||
| commit_range = os.environ.get('TRAVIS_COMMIT_RANGE') | ||||||||
| if commit_range and not check_output( | ||||||||
| if commit_range and not subprocess.check_output( | ||||||||
| ['git', '--no-pager', 'diff', '--name-only', commit_range, '--', src_d_full]): | ||||||||
| continue | ||||||||
|
|
||||||||
|
|
@@ -154,7 +153,7 @@ def diff_code(start, end): | |||||||
| else: | ||||||||
| cmd = cmd_tpl.format(start=start, end=end, | ||||||||
| code_dir=src_d_full) | ||||||||
| if not check_output(shlex.split(cmd)): | ||||||||
| if not subprocess.check_output(shlex.split(cmd)): | ||||||||
| continue | ||||||||
|
|
||||||||
| diff_ref.append((pkg_name, src_d_full)) | ||||||||
|
|
@@ -163,3 +162,26 @@ def diff_code(start, end): | |||||||
| f'end: {end}, ' | ||||||||
| f'diff_ref: {diff_ref}.') | ||||||||
| return diff_ref | ||||||||
|
|
||||||||
|
|
||||||||
| def run_az_cmd(cmd, message=False, raise_error=True): | ||||||||
| """ | ||||||||
| :param cmd: The entire command line to run. | ||||||||
| :param message: A custom message to print, or True (bool) to use a default. | ||||||||
| :param raise_error: Whether to raise an exception if the command fails. | ||||||||
| """ | ||||||||
| # use default message if custom not provided | ||||||||
| if message is True: | ||||||||
| print(f'Running: {cmd}') | ||||||||
|
|
||||||||
| if message: | ||||||||
|
Comment on lines
+176
to
+177
|
||||||||
| if message: | |
| elif isinstance(message, str): |
Copilot
AI
Apr 1, 2026
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.
On failure, error_message = ex.stderr will usually be bytes (because subprocess.run is not using text=True). This makes the raised Exception message hard to read (e.g., b'...'). Consider running with text=True (or decoding ex.stderr) so error output is readable and consistent.
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.
The new
execute_commandhelper swallows failures by returning strings like"Error: ..."/"Exception: ...", but callers (e.g.,upgrade_package) don't check these and the script continues. For CI tooling, it would be safer to raise on non-zero return codes (or return(rc, stdout, stderr)and explicitly fail) so command-tree generation doesn’t silently proceed with a broken environment.