|
| 1 | +#!/usr/bin/env bash |
| 2 | +# SPDX-License-Identifier: PMPL-1.0-or-later |
| 3 | +# validate_structure.sh — CRG C structural tests for methodologies |
| 4 | +# |
| 5 | +# Validates the methodologies documentation repository structure. |
| 6 | +# |
| 7 | +# Usage: bash tests/validate_structure.sh [repo-root] |
| 8 | + |
| 9 | +set -euo pipefail |
| 10 | + |
| 11 | +ROOT="${1:-$(cd "$(dirname "$0")/.." && pwd)}" |
| 12 | +PASS=0; FAIL=0 |
| 13 | + |
| 14 | +check() { |
| 15 | + local desc="$1"; local path="$2" |
| 16 | + if [ -e "$ROOT/$path" ]; then |
| 17 | + echo " PASS: $desc" |
| 18 | + ((PASS++)) || true |
| 19 | + else |
| 20 | + echo " FAIL: $desc — missing $path" |
| 21 | + ((FAIL++)) || true |
| 22 | + fi |
| 23 | +} |
| 24 | + |
| 25 | +echo "=== methodologies structure validation ===" |
| 26 | +echo "" |
| 27 | + |
| 28 | +check "README.adoc" "README.adoc" |
| 29 | +check "EXPLAINME.adoc" "EXPLAINME.adoc" |
| 30 | +check "0-AI-MANIFEST.a2ml" "0-AI-MANIFEST.a2ml" |
| 31 | +check "methodologies/ directory" "methodologies" |
| 32 | +check "decisions/ directory" "decisions" |
| 33 | +check "CHANGELOG.md" "CHANGELOG.md" |
| 34 | + |
| 35 | +# methodologies/ should have at least one doc |
| 36 | +if [ -d "$ROOT/methodologies" ]; then |
| 37 | + count=$(find "$ROOT/methodologies" -type f | wc -l) |
| 38 | + if [ "$count" -gt 0 ]; then |
| 39 | + echo " PASS: methodologies/ has $count file(s)" |
| 40 | + ((PASS++)) || true |
| 41 | + else |
| 42 | + echo " FAIL: methodologies/ is empty" |
| 43 | + ((FAIL++)) || true |
| 44 | + fi |
| 45 | +fi |
| 46 | + |
| 47 | +# decisions/ should have at least one ADR |
| 48 | +if [ -d "$ROOT/decisions" ]; then |
| 49 | + adr_count=$(find "$ROOT/decisions" -type f | wc -l) |
| 50 | + if [ "$adr_count" -gt 0 ]; then |
| 51 | + echo " PASS: decisions/ has $adr_count ADR(s)" |
| 52 | + ((PASS++)) || true |
| 53 | + else |
| 54 | + echo " WARN: decisions/ is empty — add ADRs" |
| 55 | + fi |
| 56 | +fi |
| 57 | + |
| 58 | +echo "" |
| 59 | +echo "Results: $PASS passed, $FAIL failed" |
| 60 | +[ "$FAIL" -eq 0 ] |
0 commit comments