Skip to content

Commit 4941e1f

Browse files
authored
feat(sdk): add version linter (#2602)
1 parent ff85676 commit 4941e1f

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ lint-services:
2525
flake8 --toml-config core/pyproject.toml --black-config core/pyproject.toml examples;
2626
# lint services
2727
@for f in $(shell ls ${SERVICES_DIR}); do set -e; cd ${SERVICES_DIR}/$${f};poetry install --no-root --only dev; flake8 .; cd ../..; done
28+
# lint versions
29+
@./scripts/lint-versions.sh
2830

2931
test:
3032
echo "Testing service ${service}"

scripts/lint-versions.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
# Immediate exit on failure
4+
set -e
5+
6+
echo ">> Linting SDK module versions..."
7+
8+
# Check all pyproject.toml files
9+
for file in $(find . -print | sed 's|^./||' | grep -E "(^services/[^/]+/pyproject.toml$|^core/pyproject.toml$)"); do
10+
# Extract the current version
11+
dirpath=$(dirname "$file")
12+
version=$(scripts/helper.sh "$dirpath")
13+
14+
# skip iaasalpha
15+
case "$dirpath" in
16+
"services/iaasalpha")
17+
continue
18+
;;
19+
esac
20+
21+
# special handling for CDN (is in v2 by accident)
22+
if [[ "$dirpath" == "services/cdn" ]]; then
23+
if [[ ! "$version" =~ ^v[0-2]\.[0-9]+\.[0-9]+$ ]]; then
24+
echo ">> $dirpath"
25+
echo "The version '$version' is invalid."
26+
exit 1
27+
fi
28+
continue
29+
fi
30+
31+
# verify version
32+
if [[ ! "$version" =~ ^v[0-1]\.[0-9]+\.[0-9]+$ ]]; then
33+
echo ">> $dirpath"
34+
echo "The version '$version' is invalid."
35+
exit 1
36+
fi
37+
done

0 commit comments

Comments
 (0)