chore(ci, quality): introduce PR Guard workflow to detect hardcoded dependency versions
- Added `check-no-hardcoded-versions.sh` script to enforce centralized dependency version management. - Configured GitHub Actions workflow (`pr-guard.yml`) to run the script on pull requests.
This commit is contained in:
parent
9e5e0512ce
commit
8155707ba1
16
.github/workflows/pr-guard.yml
vendored
Normal file
16
.github/workflows/pr-guard.yml
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
name: PR Guard
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [ "**" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
no-hardcoded-versions:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Run hardcoded versions check
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
chmod +x config/quality/check-no-hardcoded-versions.sh
|
||||||
|
config/quality/check-no-hardcoded-versions.sh
|
||||||
48
config/quality/check-no-hardcoded-versions.sh
Normal file
48
config/quality/check-no-hardcoded-versions.sh
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Guard: prevent hardcodierte Versionsangaben in Modul-Builddateien
|
||||||
|
# Erlaubt sind ausschließlich:
|
||||||
|
# - Zentrale Verwaltung in gradle/libs.versions.toml
|
||||||
|
# - Referenzen über libs.* Aliases oder ${libs.versions.*.get()} im :platform BOM
|
||||||
|
# - Ausnahmen müssen dokumentiert sein und mit // ALLOW_VERSION_JUSTIFIED kommentiert werden
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||||
|
|
||||||
|
echo "[PR-GUARD] Prüfe auf hartcodierte Versionen in build.gradle(.kts) Dateien..."
|
||||||
|
|
||||||
|
# 1) Finde Abhängigkeits-Notation mit expliziter Versionsnummer z.B. "group:artifact:1.2.3"
|
||||||
|
# Erlaube explizit Einträge, die mit einem Kommentar ALLOW_VERSION_JUSTIFIED versehen sind
|
||||||
|
VIOLATIONS_A=$(grep -RIn \
|
||||||
|
--include='build.gradle' --include='build.gradle.kts' \
|
||||||
|
-E '"[^"\$]+:[0-9]+\.[0-9]+' \
|
||||||
|
--exclude-dir='.git' \
|
||||||
|
--exclude-dir='build' \
|
||||||
|
--exclude-dir='.gradle' \
|
||||||
|
--exclude='**/platform-bom/build.gradle.kts' \
|
||||||
|
--exclude='**/platform-dependencies/build.gradle.kts' \
|
||||||
|
"$ROOT_DIR" | grep -v 'ALLOW_VERSION_JUSTIFIED' || true)
|
||||||
|
|
||||||
|
# 2) Finde version = "1.2.3" in Gradle-Dateien (selten genutzt, aber absichern)
|
||||||
|
VIOLATIONS_B=$(grep -RIn \
|
||||||
|
--include='build.gradle' --include='build.gradle.kts' \
|
||||||
|
-E 'version\s*=\s*"[0-9]+\.[0-9]+' \
|
||||||
|
--exclude-dir='.git' \
|
||||||
|
--exclude-dir='build' \
|
||||||
|
--exclude-dir='.gradle' \
|
||||||
|
"$ROOT_DIR" | grep -v 'ALLOW_VERSION_JUSTIFIED' || true)
|
||||||
|
|
||||||
|
# 3) Ausnahmen: zentrale Dateien sind erlaubt
|
||||||
|
# - gradle/libs.versions.toml (nicht in include)
|
||||||
|
# - :platform BOM darf ${libs.versions.*.get()} verwenden (kein Match)
|
||||||
|
|
||||||
|
if [[ -n "$VIOLATIONS_A" || -n "$VIOLATIONS_B" ]]; then
|
||||||
|
echo "[PR-GUARD] Verletzungen gefunden (hartcodierte Versionen):"
|
||||||
|
[[ -n "$VIOLATIONS_A" ]] && echo "$VIOLATIONS_A"
|
||||||
|
[[ -n "$VIOLATIONS_B" ]] && echo "$VIOLATIONS_B"
|
||||||
|
echo "\n[HINWEIS] Bitte Versionen in gradle/libs.versions.toml pflegen und über libs.* / Platform-BOM referenzieren."
|
||||||
|
echo "[AUSNAHME] Falls zwingend erforderlich, kommentiere die betroffene Zeile mit // ALLOW_VERSION_JUSTIFIED und dokumentiere die Ausnahme in docs/01_Architecture/README.md."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[PR-GUARD] OK – keine hartcodierten Versionen gefunden."
|
||||||
Loading…
Reference in New Issue
Block a user