75 lines
3.5 KiB
YAML
75 lines
3.5 KiB
YAML
# Ampel-CI fuer MC2 — auf dieses Multi-Service-Monorepo zugeschnitten (24.07.2026).
|
||
#
|
||
# Die universelle Vorlage (deploy/ampel-ci.yml) passt fuer EIN-Service-Repos. MC2 hat
|
||
# 5 Python-Dienste (backend/voice_service/mem0_service/mcp/client) mit schweren ML-
|
||
# Abhaengigkeiten (Whisper/TTS/Embeddings) + ein Frontend. "pip install ALLER requirements
|
||
# + pytest repo-weit" in einem stateless Container ist weder machbar (GB-schwere Wheels,
|
||
# CUDA) noch aussagekraeftig — die echten Tests sind der Pruefstand (deploy/pruefstand)
|
||
# und die Integration auf der Box mit LIVE-Diensten/Modellen, nicht isolierte Unit-Tests.
|
||
#
|
||
# Darum prueft die MC2-Ampel, was im Container EHRLICH gruen sein kann und trotzdem echte
|
||
# Fehler faengt: Lint (ruff, Projekt-Politik in ruff.toml) + Import/Syntax (compileall) +
|
||
# Frontend-Build inkl. TypeScript-Typecheck (tsc). Rot ist ein Ergebnis, kein Aergernis.
|
||
name: Ampel
|
||
on: [push, pull_request]
|
||
|
||
jobs:
|
||
ampel:
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
|
||
- name: Ampel — Lint + Import + Frontend-Build (MC2-Zuschnitt)
|
||
shell: bash
|
||
run: |
|
||
# Runner-bash laeuft mit -e; abschalten und JEDEN Fehler selbst werten (rot=1),
|
||
# am Ende EIN Klartext-Urteil (Lehre Ampel-Lauf #5).
|
||
set -u +e
|
||
rot=0
|
||
|
||
echo "== Python: Lint (ruff, Projekt-Politik aus ruff.toml) =="
|
||
python3 -m venv /tmp/ampel-venv && . /tmp/ampel-venv/bin/activate || { echo "❌ venv kaputt"; exit 1; }
|
||
pip install -q ruff || { echo "❌ ruff-Install kaputt"; exit 1; }
|
||
ruff check . || rot=1
|
||
|
||
echo "== Python: Import/Syntax (compileall) =="
|
||
python3 -m compileall -q backend voice_service mem0_service mcp client deploy hermes scripts || rot=1
|
||
|
||
echo "== Frontend: reproduzierbarer Build (npm ci + tsc + vite) =="
|
||
if [ -f frontend/package.json ]; then
|
||
if [ ! -f frontend/package-lock.json ]; then
|
||
echo "❌ frontend/: kein package-lock.json — Build nicht reproduzierbar."
|
||
rot=1
|
||
else
|
||
( cd frontend && npm ci --no-audit --no-fund && npm run build ) || rot=1
|
||
|
||
if [ $rot -eq 0 ]; then
|
||
echo "== Frontend: Push nach release-dist =="
|
||
git config --global user.name "Gitea Actions"
|
||
git config --global user.email "actions@gitea.local"
|
||
# Erzeuge (oder hole) den orphan branch 'release-dist'
|
||
git checkout --orphan release-dist 2>/dev/null || git checkout release-dist
|
||
git rm -rf . >/dev/null 2>&1 || true
|
||
# Checkout nur frontend/dist vom aktuellen Stand
|
||
git checkout $GITHUB_SHA -- frontend/dist
|
||
git add frontend/dist
|
||
if ! git diff-index --quiet HEAD; then
|
||
git commit -m "Automatischer Frontend Build ($GITHUB_SHA) [skip ci]"
|
||
# Push to release-dist. Token auth from runner is expected to work for Gitea Actions.
|
||
git push origin HEAD:release-dist -f
|
||
else
|
||
echo "Keine Änderungen am Frontend-Build."
|
||
fi
|
||
# Zurück zum originalen Branch für den Rest des Skripts
|
||
git checkout $GITHUB_SHA
|
||
fi
|
||
fi
|
||
fi
|
||
|
||
if [ $rot -ne 0 ]; then
|
||
echo "❌ AMPEL ROT — nichts heißt ‚fertig', solange das rot ist."
|
||
else
|
||
echo "✅ AMPEL GRÜN — Lint + Import + Frontend-Build sauber."
|
||
fi
|
||
exit $rot
|