Skip to content

Commit

Permalink
{CI} Fix shell and version extract scripts (#7847)
Browse files Browse the repository at this point in the history
* fix scripts
  • Loading branch information
AllyW authored Aug 2, 2024
1 parent f5a571f commit 5a62f9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/VersionCalPRComment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ jobs:
cat changed_files | grep azext_ | awk -F"azext_" '{print $1}'| awk -F"/" '{print $2}' | sort | uniq > changed_modules
echo "changed_module_list=$(cat changed_files | grep azext_ | awk -F"azext_" '{print $1}'| awk -F"/" '{print $2}' | sort | uniq | xargs)" >> $GITHUB_ENV
git --no-pager diff --diff-filter=ACMRT "$base_branch_pre"/"$base_branch"..."$diff_branch" > "$diff_code_file"
- name: Display PR Diff Modules
- name: Display PR Diff Modules
run: |
for mod in "$changed_module_list"
for mod in ${changed_module_list[@]}
do
echo changed module: "${mod}"
done
if [ -z "$changed_module_list" ]; then
if [ ${#changed_module_list[@]} -eq 0 ]; then
echo "no_changed_mod=true" >> $GITHUB_ENV
else
echo "no_changed_mod=false" >> $GITHUB_ENV
Expand Down Expand Up @@ -135,14 +135,14 @@ jobs:
set -ev
git checkout "$base_branch_pre"/"$base_branch"
mkdir "$base_meta_path"
for mod in "$changed_module_list"
for mod in ${changed_module_list[@]}
do
echo changed module: "${mod}"
azdev extension add "${mod}" && azdev command-change meta-export "${mod}" --meta-output-path ./"$base_meta_path"/ && azdev extension remove "${mod}"
done
git checkout "$diff_branch"
mkdir "$diff_meta_path"
for mod in "$changed_module_list"
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"/
Expand Down
17 changes: 10 additions & 7 deletions scripts/ci/release_version_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,24 @@ def extract_module_version_update_info(mod_update_info, mod):
--- a/src/monitor-control-service/HISTORY.RST
py files exclude tests, vendored_sdks and aaz folder
"""
mod_update_info["setup_updated"] = False
diff_file_started = False
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:
if mod_update_info["setup_updated"]:
if line.find("---") == 0 or mod_update_info.get("version_diff", None):
if diff_file_started:
if mod_update_info.get("version_diff", None):
break
if line.find("diff") == 0:
diff_file_started = False
continue
mod_version_update_match = re.findall(module_version_update_pattern, line)
if mod_version_update_match and len(mod_version_update_match) == 1:
mod_update_info["version_diff"] = mod_version_update_match[0]
else:
mod_setup_update_match = re.findall(module_setup_update_pattern, line)
if mod_setup_update_match:
mod_update_info["setup_updated"] = True
diff_file_started = True


def extract_module_metadata_update_info(mod_update_info, mod):
Expand Down Expand Up @@ -220,7 +223,7 @@ def gen_history_comment_message(mod, mod_update_info, mod_message):

def gen_version_comment_message(mod, mod_update_info, mod_message):
global block_pr
if not mod_update_info["setup_updated"]:
if not mod_update_info.get("version_diff", None):
if mod_update_info.get("version", None):
mod_message.append(" - Update `VERSION` to `{0}` in `src/{1}/setup.py`".format(mod_update_info.get("version", "-"), mod))
else:
Expand All @@ -241,7 +244,7 @@ def gen_preview_comment_message(mod, mod_update_info, mod_message):
if mod_update_info.get("preview_tag", "-") == mod_update_info.get("preview_tag_diff", "-"):
return
preview_comment_message = " - "
if mod_update_info["setup_updated"] and mod_update_info.get("version_diff", None):
if mod_update_info.get("version_diff", None):
block_pr = 1
preview_comment_message += ":warning: "
if mod_update_info.get("preview_tag", None) and mod_update_info.get("preview_tag_diff", None):
Expand All @@ -267,7 +270,7 @@ def gen_exp_comment_message(mod, mod_update_info, mod_message):
if mod_update_info.get("exp_tag", "-") == mod_update_info.get("exp_tag_diff", "-"):
return
exp_comment_message = " - "
if mod_update_info["setup_updated"]:
if mod_update_info.get("version_diff", None):
block_pr = 1
exp_comment_message += ":warning: "
if mod_update_info.get("exp_tag", None) and mod_update_info.get("exp_tag_diff", None):
Expand Down

0 comments on commit 5a62f9a

Please sign in to comment.