Files
spring-ai/cloud-providers/scripts/azure-starter-check.sh
T

53 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Shows what happened to the dedicated Azure OpenAI starter: it is not managed by the Spring AI 2.1.0 BOM, and the
# newest version on Maven Central is a 2.0 milestone. Needs network access to Maven Central. Writes output/00-*.txt.
set -uo pipefail
cd "$(dirname "$0")/.."
out=output/00-azure-starter.txt
tmp=$(mktemp -d)
mkdir -p output
# Maven Central answers 429 when polled quickly; retry, and refuse to write a transcript from an empty answer.
fetch() {
local r
for _ in 1 2 3 4 5 6 7 8; do
if r=$(curl -sf "$1") && [ -n "$r" ]; then printf '%s' "$r"; return 0; fi
sleep 10
done
echo "could not fetch $1" >&2; return 1
}
declare -A meta
for a in spring-ai-starter-model-azure-openai spring-ai-starter-model-openai spring-ai-starter-model-bedrock-converse; do
meta[$a]=$(fetch "https://repo1.maven.org/maven2/org/springframework/ai/$a/maven-metadata.xml") || exit 1
sleep 3
done
bom=$(fetch https://repo1.maven.org/maven2/org/springframework/ai/spring-ai-bom/2.1.0/spring-ai-bom-2.1.0.pom) || exit 1
{
echo "# What happened to spring-ai-starter-model-azure-openai?"
echo
echo "A. Versions on Maven Central (maven-metadata.xml)"
for a in spring-ai-starter-model-azure-openai spring-ai-starter-model-openai spring-ai-starter-model-bedrock-converse; do
xml=${meta[$a]}
printf ' %-45s newest listed version=%s\n' "$a" "$(grep -o '<version>[^<]*' <<<"$xml" | tail -1 | sed 's/<version>//')"
done
echo
echo "B. Does the Spring AI 2.1.0 BOM manage the Azure starter?"
for a in spring-ai-starter-model-azure-openai spring-ai-azure-openai spring-ai-starter-model-openai spring-ai-starter-model-bedrock-converse; do
if grep -q "<artifactId>$a</artifactId>" <<<"$bom"; then r=managed; else r="NOT managed"; fi
printf ' %-45s %s\n' "$a" "$r"
done
echo
echo "C. Maven asked to resolve the Azure starter with no version under that BOM"
cat > "$tmp/pom.xml" <<POM
<project xmlns="http://maven.apache.org/POM/4.0.0"><modelVersion>4.0.0</modelVersion>
<groupId>x</groupId><artifactId>x</artifactId><version>1</version>
<dependencyManagement><dependencies><dependency><groupId>org.springframework.ai</groupId><artifactId>spring-ai-bom</artifactId><version>2.1.0</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement>
<dependencies><dependency><groupId>org.springframework.ai</groupId><artifactId>spring-ai-starter-model-azure-openai</artifactId></dependency></dependencies>
</project>
POM
(cd "$tmp" && mvn -B -q validate 2>&1 | grep -E "ERROR.*(version|missing)" | sort -u | head -1 | sed -E 's/^\[ERROR\] *//; s#/tmp/[^ ]*/pom.xml#pom.xml#')
} > "$out"
grep -q "is missing" "$out" || { echo "maven did not report the missing version" >&2; exit 1; }
cat "$out"
rm -rf "$tmp"