Skip to content

Commit

Permalink
fix version cal detect version and pkg name (Azure#7840)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllyW authored Aug 1, 2024
1 parent 5eff11a commit a4a91d6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
36 changes: 21 additions & 15 deletions .github/workflows/VersionCalPRComment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
branches:
- main
paths:
- '**.py'
- '!**/test_*.py'

permissions: {}
Expand Down Expand Up @@ -79,26 +78,32 @@ jobs:
git --no-pager diff --diff-filter=ACMRT "$base_branch_pre"/"$base_branch"..."$diff_branch" > "$diff_code_file"
- name: Display PR Diff Modules
run: |
for mod in "$changed_module_list"
do
echo changed module: "${mod}"
done
for mod in "$changed_module_list"
do
echo changed module: "${mod}"
done
if [ -z "$changed_module_list" ]; then
echo "no_changed_mod=true" >> $GITHUB_ENV
else
echo "no_changed_mod=false" >> $GITHUB_ENV
fi
- name: Checkout CLI main repo
if: ${{ env.no_changed_mod == 'false' }}
uses: actions/checkout@v4
with:
repository: Azure/azure-cli
path: ./azure-cli
- name: Show workdirectory after cli cloned
run: |
pwd
ls
- name: Move the main repo to the same level as the extension repo
if: ${{ env.no_changed_mod == 'false' }}
run: |
mv azure-cli ../
cd ../
pwd
ls
pwd
ls
mv azure-cli ../
cd ../
pwd
ls
- name: Install azdev
if: ${{ env.no_changed_mod == 'false' }}
run: |
python -m pip install --upgrade pip
set -ev
Expand All @@ -112,6 +117,7 @@ jobs:
az --version
pip list -v
- name: Gen Base and Diff Metadata
if: ${{ env.no_changed_mod == 'false' }}
id: get_comment_message
env:
pr_label_list: ${{ toJson(github.event.pull_request.labels.*.name) }}
Expand Down Expand Up @@ -141,12 +147,12 @@ jobs:
for mod in "$changed_module_list"
do
echo changed module: "${mod}"
azdev extension add "${mod}" && azdev command-change meta-export "${mod}" --meta-output-path ./"$diff_meta_path"/ && azdev extension remove "${mod}"
azdev extension add "${mod}" && azdev command-change meta-export "${mod}" --meta-output-path ./"$diff_meta_path"/
done
ls ./"$base_meta_path"/
ls ./"$diff_meta_path"/
ls "$result_path"
git checkout "$base_branch_pre"/"$base_branch"
git checkout "$base_branch_pre"/"$base_branch" -- scripts
python scripts/ci/release_version_cal.py
ls "$result_path"
cat "$result_path"/"$remove_labels_file"
Expand Down
14 changes: 12 additions & 2 deletions scripts/ci/release_version_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import re
import json
import subprocess
from packaging.version import parse

from azdev.utilities.path import get_cli_repo_path, get_ext_repo_paths
Expand Down Expand Up @@ -62,9 +63,10 @@ def extract_module_version_update_info(mod_update_info, mod):
-VERSION = '1.0.1'
+VERSION = '1.1.1'
--- a/src/monitor-control-service/HISTORY.RST
py files exclude tests, vendored_sdks and aaz folder
"""
mod_update_info["setup_updated"] = False
module_setup_update_pattern = re.compile(r"\+\+\+.*?src/%s/setup.py" % mod)
module_setup_update_pattern = re.compile(r"\+\+\+.*?src/%s/(?!.*(?:tests|vendored_sdks|aaz)/).*?.py" % mod)
module_version_update_pattern = re.compile(r"\+\s?VERSION\s?\=\s?[\'\"]([0-9\.b]+)[\'\"]")
with open(diff_code_file, "r") as f:
for line in f:
Expand Down Expand Up @@ -118,6 +120,14 @@ def extract_module_metadata_update_info(mod_update_info, mod):
mod_update_info["meta_updated"] = True


def find_module_metadata_of_latest_version(mod):
cmd = ["azdev", "extension", "show", "--mod-name", mod, "--query", "pkg_name", "-o", "tsv"]
result = subprocess.run(cmd, stdout=subprocess.PIPE)
if result.returncode == 0:
mod = result.stdout.decode("utf8").strip()
return get_module_metadata_of_max_version(mod)


def extract_module_version_info(mod_update_info, mod):
next_version_pre_tag = get_next_version_pre_tag()
next_version_segment_tag = get_next_version_segment_tag()
Expand All @@ -135,7 +145,7 @@ def extract_module_version_info(mod_update_info, mod):
elif not os.path.exists(diff_meta_file):
print("no diff meta file found for {0}".format(mod))
return
pre_release = get_module_metadata_of_max_version(mod)
pre_release = find_module_metadata_of_latest_version(mod)
if pre_release is None:
next_version = cal_next_version(base_meta_file=base_meta_file, diff_meta_file=diff_meta_file,
current_version=DEFAULT_VERSION,
Expand Down

0 comments on commit a4a91d6

Please sign in to comment.