Merge pull request #8204 from zmstone/0612-build-exclude-sub-build-dirs

build: add strict-semver version bump check for apps
This commit is contained in:
Zaiming (Stone) Shi 2022-06-13 19:33:06 +01:00 committed by GitHub
commit 3a17fb2522
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 1 deletions

View File

@ -8,6 +8,10 @@ bad_app_count=0
no_comment_re='(^[^\s?%])' no_comment_re='(^[^\s?%])'
## TODO: c source code comments re (in $app_path/c_src dirs) ## TODO: c source code comments re (in $app_path/c_src dirs)
parse_semver() {
echo "$1" | tr '.|-' ' '
}
while read -r app; do while read -r app; do
if [ "$app" != "emqx" ]; then if [ "$app" != "emqx" ]; then
app_path="$app" app_path="$app"
@ -15,7 +19,7 @@ while read -r app; do
app_path="." app_path="."
fi fi
src_file="$app_path/src/$(basename "$app").app.src" src_file="$app_path/src/$(basename "$app").app.src"
old_app_version="$(git show "$latest_release":"$src_file" | grep vsn | grep -oE '"[0-9]+.[0-9]+.[0-9]+"' | tr -d '"')" old_app_version="$(git show "$latest_release":"$src_file" | grep vsn | grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"')"
now_app_version=$(grep -E 'vsn' "$src_file" | grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"') now_app_version=$(grep -E 'vsn' "$src_file" | grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"')
if [ "$old_app_version" = "$now_app_version" ]; then if [ "$old_app_version" = "$now_app_version" ]; then
changed_lines="$(git diff "$latest_release"...HEAD --ignore-blank-lines -G "$no_comment_re" \ changed_lines="$(git diff "$latest_release"...HEAD --ignore-blank-lines -G "$no_comment_re" \
@ -36,6 +40,19 @@ while read -r app; do
echo "$src_file needs a vsn bump to ensure plugins loaded after upgrade" echo "$src_file needs a vsn bump to ensure plugins loaded after upgrade"
bad_app_count=$(( bad_app_count + 1)) bad_app_count=$(( bad_app_count + 1))
fi fi
else
# shellcheck disable=SC2207
old_app_version_semver=($(parse_semver "$old_app_version"))
# shellcheck disable=SC2207
now_app_version_semver=($(parse_semver "$now_app_version"))
if [ "${old_app_version_semver[0]}" = "${now_app_version_semver[0]}" ] && \
[ "${old_app_version_semver[1]}" = "${now_app_version_semver[1]}" ] && \
[ "$(( "${old_app_version_semver[2]}" + 1 ))" = "${now_app_version_semver[2]}" ]; then
true
else
echo "$src_file: non-strict semver version bump from $old_app_version to $now_app_version"
bad_app_count=$(( bad_app_count + 1))
fi
fi fi
done < <(./scripts/find-apps.sh) done < <(./scripts/find-apps.sh)