From f2d9016d1fddbcc2c7f41e01ab1c5c9d09408410 Mon Sep 17 00:00:00 2001 From: Ruben Hoenle Date: Thu, 4 Dec 2025 18:30:18 +0100 Subject: [PATCH] feat(sdk): add version linter --- Makefile | 2 ++ scripts/lint-versions.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 scripts/lint-versions.sh 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