Files
kai a62e48116a
release / which version (push) Successful in 3s
release / olares chart · sanity (push) Successful in 3s
release / app (push) Successful in 55s
release / tag and release (push) Successful in 3s
Scaffold app, chart, CI and release (26.11.1) (#2)
2026-11-06 19:14:55 +00:00

97 lines
5.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Prüft das Olares-Chart vor jedem Commit und in der CI. Jede Regel steht
# für einen Fehler, der bei Rocket oder Insilo auf der Box Geld gekostet hat
# (Vorbild: aimighty/rocket scripts/check-chart.sh).
set -euo pipefail
cd "$(dirname "$0")/.."
FEHLER=0
melde() { echo " FEHLER: $*"; FEHLER=1; }
echo "→ Versionen im Gleichschritt"
CHART_VERSION=$(grep -E '^version:' olares/Chart.yaml | awk '{print $2}')
CHART_APPVERSION=$(grep -E '^appVersion:' olares/Chart.yaml | awk '{print $2}' | tr -d '"')
MANIFEST_VERSION=$(grep -E '^ version:' olares/OlaresManifest.yaml | awk '{print $2}')
MANIFEST_VERSIONNAME=$(grep -E '^ versionName:' olares/OlaresManifest.yaml | awk '{print $2}' | tr -d "'")
[ "$CHART_VERSION" = "$CHART_APPVERSION" ] || melde "Chart.yaml: version ($CHART_VERSION) != appVersion ($CHART_APPVERSION)"
[ "$CHART_VERSION" = "$MANIFEST_VERSION" ] || melde "OlaresManifest metadata.version ($MANIFEST_VERSION) != Chart-version ($CHART_VERSION)"
[ "$CHART_APPVERSION" = "$MANIFEST_VERSIONNAME" ] || melde "OlaresManifest spec.versionName ($MANIFEST_VERSIONNAME) != appVersion ($CHART_APPVERSION)"
# YY.M.<n>, Monat ohne führende Null — mit Null ist es kein gültiges SemVer.
echo "$CHART_VERSION" | grep -Eq '^[0-9]{2}\.([1-9]|1[0-2])\.[1-9][0-9]*$' \
|| melde "Version '$CHART_VERSION' folgt nicht YY.M.<n> (z. B. 26.11.1)"
echo "→ Root-Manifest ist eine Kopie des Chart-Manifests"
cmp -s OlaresManifest.yaml olares/OlaresManifest.yaml \
|| melde "OlaresManifest.yaml (Wurzel) weicht von olares/OlaresManifest.yaml ab — cp olares/OlaresManifest.yaml ."
echo "→ Namen identisch (Chart, metadata.name, appid)"
for wert in \
"$(grep -E '^name:' olares/Chart.yaml | awk '{print $2}')" \
"$(grep -E '^ name: ' olares/OlaresManifest.yaml | head -1 | awk '{print $2}')" \
"$(grep -E '^ appid:' olares/OlaresManifest.yaml | awk '{print $2}')"
do
[ "$wert" = "lunch" ] || melde "Name weicht ab: '$wert' (erwartet: lunch)"
done
ohne_kommentare() { grep -rhvE '^[[:space:]]*#' olares/templates/; }
suche_verboten() {
if ohne_kommentare | grep -qE "$1"; then melde "$2 gefunden"; ohne_kommentare | grep -nE "$1" | head -3; fi
}
echo "→ Kein .Files.Get, keine Helm-Hooks, kein NodePort/LoadBalancer/hostNetwork"
suche_verboten '\.Files\.Get' ".Files.Get"
suche_verboten 'helm\.sh/hook' "Helm-Hook"
suche_verboten 'NodePort|LoadBalancer|hostNetwork' "verbotener Netzwerktyp"
echo "→ Manifest v3"
API_VERSION=$(grep -E '^apiVersion:' olares/OlaresManifest.yaml | awk '{print $2}' | tr -d "'\"")
DEP_VERSION=$(awk '/^[[:space:]]*-[[:space:]]*name:[[:space:]]*olares[[:space:]]*$/{f=1} f&&/^[[:space:]]*version:/{gsub(/.*version:[[:space:]]*/,""); gsub(/['"'"'"]/,""); print; exit}' olares/OlaresManifest.yaml)
[ "$API_VERSION" = "v3" ] || melde "OlaresManifest ohne apiVersion v3"
[ "$DEP_VERSION" = ">=1.12.6-0" ] || melde "options.dependencies[olares].version muss '>=1.12.6-0' sein, ist '$DEP_VERSION'"
grep -qE '^[[:space:]]*runAsInternal:[[:space:]]*true' olares/OlaresManifest.yaml && melde "runAsInternal: true im Manifest"
grep -rq 'OLARES_USER' olares/ && melde "OLARES_USER kommt in olares/ vor (v3 verbietet das Präfix)"
for tpl in olares/templates/deployment*.yaml; do
grep -q 'index .Values.workloads' "$tpl" || melde "$tpl liest replicas nicht aus .Values.workloads"
done
echo "→ Abbild: Pfad fest im Template, Tag aus Chart.AppVersion"
if grep -n 'image:' olares/templates/deployment*.yaml | grep -q 'repository'; then
melde "ein Template liest den Abbild-Pfad aus values.yaml"
fi
grep -q 'image: "git.aimighty.olares.de/aimighty/lunch-app:' olares/templates/deployment.yaml \
|| melde "deployment.yaml zieht nicht git.aimighty.olares.de/aimighty/lunch-app"
grep -q 'default .Chart.AppVersion' olares/templates/deployment.yaml \
|| melde "deployment.yaml liest den Tag nicht aus Chart.AppVersion"
if grep -qE '^\s+tag: "[^"]+"' olares/values.yaml; then
echo " Hinweis: values.yaml pinnt einen Tag — nur für ein Release ohne neue Abbilder richtig."
fi
echo "→ Bilder aus aimighty/bilder, nichts von GitHub"
grep -qi 'github' olares/OlaresManifest.yaml && melde "OlaresManifest.yaml nennt GitHub"
BILDER="https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/"
for feld in icon featuredImage; do
grep -E "^[[:space:]]*$feld:" olares/OlaresManifest.yaml | grep -vqF "$BILDER" && melde "$feld liegt nicht unter $BILDER"
done
echo "→ Entrance erst public, wenn die eigene Anmeldung steht (E-0001)"
if grep -qE '^[[:space:]]*authLevel:[[:space:]]*public' olares/OlaresManifest.yaml && [ ! -f lib/auth/session.ts ]; then
melde "Entrance ist public, aber lib/auth/session.ts fehlt — erst die eigene Anmeldung, dann öffnen"
fi
echo "→ Markt-Notiz zur Version"
MV="$CHART_VERSION"
if [ ! -f "olares/markt/$MV.md" ]; then
melde "olares/markt/$MV.md fehlt — '# Titel', 'v$MV: …' (Englisch), '## Deutsch', 'v$MV: …'"
else
head -1 "olares/markt/$MV.md" | grep -q '^# ' || melde "olares/markt/$MV.md: erste Zeile '# <Titel>'"
sed -n 2p "olares/markt/$MV.md" | grep -q "^v$MV: " || melde "olares/markt/$MV.md: Text beginnt mit 'v$MV: '"
! grep -q '`' "olares/markt/$MV.md" || melde "olares/markt/$MV.md: kein Backtick"
awk '/^## Deutsch[[:space:]]*$/{f=1;next} f&&NF{print;exit}' "olares/markt/$MV.md" | grep -q "^v$MV: " \
|| melde "olares/markt/$MV.md: deutscher Teil fehlt — Zeile '## Deutsch', darunter 'v$MV: …'"
fi
echo "→ helm lint und helm template"
helm lint olares -f olares/values-olares-stub.yaml > /dev/null || melde "helm lint fehlgeschlagen"
helm template lunch olares -f olares/values-olares-stub.yaml > /dev/null || melde "helm template fehlgeschlagen"
if [ "$FEHLER" -eq 0 ]; then echo "Alles in Ordnung."; else echo "Prüfung fehlgeschlagen."; exit 1; fi