name: CI on: pull_request: branches: - main jobs: validate: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Validate Python syntax run: | FAIL=0 for f in $(find . -name '*.py' -not -path './venv/*'); do if ! python3 -c "import py_compile; py_compile.compile('$f', doraise=True)" 2>/dev/null; then echo "FAIL: $f" FAIL=1 else echo "OK: $f" fi done exit $FAIL - name: Validate JSON run: | FAIL=0 for f in $(find . -name '*.json' -not -path './venv/*'); do if ! python3 -c "import json; json.load(open('$f'))"; then echo "FAIL: $f" FAIL=1 else echo "OK: $f" fi done exit $FAIL - name: Validate YAML run: | pip install pyyaml -q FAIL=0 for f in $(find . -name '*.yaml' -o -name '*.yml' | grep -v '.gitea/'); do if ! python3 -c "import yaml; yaml.safe_load(open('$f'))"; then echo "FAIL: $f" FAIL=1 else echo "OK: $f" fi done exit $FAIL - name: "HARD RULE: 10-line net addition limit" run: | ADDITIONS=$(git diff --numstat origin/main...HEAD | awk '{s+=$1} END {print s+0}') DELETIONS=$(git diff --numstat origin/main...HEAD | awk '{s+=$2} END {print s+0}') NET=$((ADDITIONS - DELETIONS)) echo "Additions: +$ADDITIONS | Deletions: -$DELETIONS | Net: $NET" if [ "$NET" -gt 10 ]; then echo "" echo "═══════════════════════════════════════════════════" echo " BLOCKED: Net addition is $NET lines (max: 10)." echo " Delete code elsewhere to compensate." echo "═══════════════════════════════════════════════════" exit 1 fi echo "✓ Net addition ($NET) within 10-line limit."