|
| 1 | +# SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | +name: Language Policy Enforcement |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [main, master] |
| 7 | + pull_request: |
| 8 | + branches: [main, master] |
| 9 | + |
| 10 | +permissions: read-all |
| 11 | + |
| 12 | +jobs: |
| 13 | + check-banned-languages: |
| 14 | + name: Check for Banned Languages |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 19 | + |
| 20 | + - name: Check for TypeScript files |
| 21 | + run: | |
| 22 | + if find . -name "*.ts" -o -name "*.tsx" | grep -v node_modules | grep -v ".d.ts" | head -1 | grep -q .; then |
| 23 | + echo "::error::TypeScript files found. Use ReScript instead." |
| 24 | + find . -name "*.ts" -o -name "*.tsx" | grep -v node_modules | grep -v ".d.ts" |
| 25 | + exit 1 |
| 26 | + fi |
| 27 | + echo "✓ No TypeScript files found" |
| 28 | +
|
| 29 | + - name: Check for Go files |
| 30 | + run: | |
| 31 | + if find . -name "*.go" | head -1 | grep -q .; then |
| 32 | + echo "::error::Go files found. Use Rust instead." |
| 33 | + find . -name "*.go" |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | + echo "✓ No Go files found" |
| 37 | +
|
| 38 | + - name: Check for Python files (except Ansible) |
| 39 | + run: | |
| 40 | + # Allow Python only in ansible/ directories or for Ansible-specific files |
| 41 | + PYTHON_FILES=$(find . -name "*.py" | grep -v __pycache__ | grep -v ".venv" | grep -v "ansible" | grep -v "molecule" || true) |
| 42 | + if [ -n "$PYTHON_FILES" ]; then |
| 43 | + echo "::error::Python files found outside Ansible context. Rewrite in Rust/ReScript." |
| 44 | + echo "$PYTHON_FILES" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + echo "✓ No unauthorized Python files found" |
| 48 | +
|
| 49 | + - name: Check for Makefiles |
| 50 | + run: | |
| 51 | + MAKEFILES=$(find . -name "Makefile" -o -name "Makefile.*" -o -name "*.mk" | grep -v ".github" || true) |
| 52 | + if [ -n "$MAKEFILES" ]; then |
| 53 | + echo "::error::Makefiles found. Use Mustfile/justfile instead." |
| 54 | + echo "$MAKEFILES" |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | + echo "✓ No Makefiles found" |
| 58 | +
|
| 59 | + - name: Check for package.json (npm/node) |
| 60 | + run: | |
| 61 | + if [ -f "package.json" ]; then |
| 62 | + # Allow if it only contains devDependencies for tooling |
| 63 | + if grep -q '"dependencies"' package.json; then |
| 64 | + echo "::error::package.json with runtime dependencies found. Use deno.json instead." |
| 65 | + exit 1 |
| 66 | + fi |
| 67 | + fi |
| 68 | + echo "✓ No npm runtime dependencies found" |
| 69 | +
|
| 70 | + - name: Check for Java/Kotlin files |
| 71 | + run: | |
| 72 | + if find . -name "*.java" -o -name "*.kt" -o -name "*.kts" | head -1 | grep -q .; then |
| 73 | + echo "::error::Java/Kotlin files found. Use Rust/Tauri/Dioxus instead." |
| 74 | + find . -name "*.java" -o -name "*.kt" -o -name "*.kts" |
| 75 | + exit 1 |
| 76 | + fi |
| 77 | + echo "✓ No Java/Kotlin files found" |
| 78 | +
|
| 79 | + - name: Check for Swift files |
| 80 | + run: | |
| 81 | + if find . -name "*.swift" | head -1 | grep -q .; then |
| 82 | + echo "::error::Swift files found. Use Tauri/Dioxus instead." |
| 83 | + find . -name "*.swift" |
| 84 | + exit 1 |
| 85 | + fi |
| 86 | + echo "✓ No Swift files found" |
| 87 | +
|
| 88 | + check-required-files: |
| 89 | + name: Check Required Files |
| 90 | + runs-on: ubuntu-latest |
| 91 | + steps: |
| 92 | + - name: Checkout |
| 93 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 94 | + |
| 95 | + - name: Check for .machine_readable directory |
| 96 | + run: | |
| 97 | + if [ ! -d ".machine_readable" ]; then |
| 98 | + echo "::warning::.machine_readable/ directory not found" |
| 99 | + else |
| 100 | + echo "✓ .machine_readable/ directory exists" |
| 101 | + for scm in STATE META ECOSYSTEM AGENTIC NEUROSYM PLAYBOOK; do |
| 102 | + if [ ! -f ".machine_readable/${scm}.scm" ]; then |
| 103 | + echo "::warning::Missing .machine_readable/${scm}.scm" |
| 104 | + else |
| 105 | + echo "✓ .machine_readable/${scm}.scm exists" |
| 106 | + fi |
| 107 | + done |
| 108 | + fi |
| 109 | +
|
| 110 | + - name: Check for Mustfile/justfile |
| 111 | + run: | |
| 112 | + if [ ! -f "Mustfile" ] && [ ! -f "justfile" ]; then |
| 113 | + echo "::warning::Neither Mustfile nor justfile found" |
| 114 | + else |
| 115 | + echo "✓ Build system files present" |
| 116 | + fi |
| 117 | +
|
| 118 | + - name: Check SPDX headers |
| 119 | + run: | |
| 120 | + MISSING_SPDX=0 |
| 121 | + for ext in rs res js jsx mjs ts tsx py go java kt swift sh bash; do |
| 122 | + while IFS= read -r file; do |
| 123 | + if [ -n "$file" ] && ! head -5 "$file" | grep -q "SPDX-License-Identifier"; then |
| 124 | + echo "::warning::Missing SPDX header: $file" |
| 125 | + MISSING_SPDX=$((MISSING_SPDX + 1)) |
| 126 | + fi |
| 127 | + done < <(find . -name "*.$ext" -type f 2>/dev/null | grep -v node_modules | grep -v .git | head -50) |
| 128 | + done |
| 129 | + if [ $MISSING_SPDX -gt 0 ]; then |
| 130 | + echo "::warning::$MISSING_SPDX files missing SPDX headers" |
| 131 | + fi |
0 commit comments