diff --git a/Makefile b/Makefile index 34c00d989..6f0d25291 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,8 @@ lint-services: flake8 --toml-config core/pyproject.toml --black-config core/pyproject.toml examples; # lint services @for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};poetry install --no-root --only dev; flake8 .; cd ../..; done + # lint versions + @./scripts/lint-versions.sh test: echo "Testing service ${service}" diff --git a/scripts/lint-versions.sh b/scripts/lint-versions.sh new file mode 100755 index 000000000..62c8e50db --- /dev/null +++ b/scripts/lint-versions.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Immediate exit on failure +set -e + +echo ">> Linting SDK module versions..." + +# Check all pyproject.toml files +for file in $(find . -print | sed 's|^./||' | grep -E "(^services/[^/]+/pyproject.toml$|^core/pyproject.toml$)"); do + # Extract the current version + dirpath=$(dirname "$file") + version=$(scripts/helper.sh "$dirpath") + + # skip iaasalpha + case "$dirpath" in + "services/iaasalpha") + continue + ;; + esac + + # special handling for CDN (is in v2 by accident) + if [[ "$dirpath" == "services/cdn" ]]; then + if [[ ! "$version" =~ ^v[0-2]\.[0-9]+\.[0-9]+$ ]]; then + echo ">> $dirpath" + echo "The version '$version' is invalid." + exit 1 + fi + continue + fi + + # verify version + if [[ ! "$version" =~ ^v[0-1]\.[0-9]+\.[0-9]+$ ]]; then + echo ">> $dirpath" + echo "The version '$version' is invalid." + exit 1 + fi +done