|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | +name: ci |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + pull_request: |
| 8 | + branches: [main] |
| 9 | + |
| 10 | +jobs: |
| 11 | + validate: |
| 12 | + name: Validate repository integrity |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Verify license headers present |
| 18 | + run: | |
| 19 | + MISSING=0 |
| 20 | + while IFS= read -r -d '' f; do |
| 21 | + if ! grep -qE 'SPDX-License-Identifier|Apache License|Apache-2.0' "$f"; then |
| 22 | + echo "MISSING LICENSE HEADER: $f" |
| 23 | + MISSING=$((MISSING+1)) |
| 24 | + fi |
| 25 | + done < <(find cmd lib -name '*.c' -o -name '*.h' -print0 2>/dev/null) |
| 26 | + if [ "$MISSING" -gt 0 ]; then |
| 27 | + echo "::error::$MISSING source files are missing Apache-2.0 SPDX headers" |
| 28 | + exit 1 |
| 29 | + fi |
| 30 | + echo "All source files have license headers." |
| 31 | +
|
| 32 | + - name: Validate operator-index.json |
| 33 | + run: | |
| 34 | + python3 - << 'PY' |
| 35 | + import json, sys, os |
| 36 | +
|
| 37 | + with open("operator-index.json") as f: |
| 38 | + idx = json.load(f) |
| 39 | +
|
| 40 | + errors = [] |
| 41 | + ops = idx.get("operators", []) |
| 42 | + print(f"Operator count in index: {len(ops)}") |
| 43 | +
|
| 44 | + # Verify every binary in cmd/ is in the index |
| 45 | + indexed = {op["binary"] for op in ops} |
| 46 | + on_disk = {d for d in os.listdir("cmd") if os.path.isdir(f"cmd/{d}")} |
| 47 | + missing_from_index = on_disk - indexed |
| 48 | + extra_in_index = indexed - on_disk |
| 49 | + if missing_from_index: |
| 50 | + errors.append(f"Operators on disk but not in index: {sorted(missing_from_index)}") |
| 51 | + if extra_in_index: |
| 52 | + errors.append(f"Operators in index but not on disk: {sorted(extra_in_index)}") |
| 53 | +
|
| 54 | + # Verify all required fields present |
| 55 | + REQUIRED = {"binary","akai_command","category","abi","source"} |
| 56 | + for op in ops: |
| 57 | + missing = REQUIRED - op.keys() |
| 58 | + if missing: |
| 59 | + errors.append(f"{op.get('binary','?')} missing fields: {missing}") |
| 60 | +
|
| 61 | + if errors: |
| 62 | + for e in errors: |
| 63 | + print(f"::error::{e}", file=sys.stderr) |
| 64 | + sys.exit(1) |
| 65 | + print("operator-index.json is valid.") |
| 66 | + PY |
| 67 | +
|
| 68 | + - name: Validate format-bridge.json |
| 69 | + run: | |
| 70 | + python3 - << 'PY' |
| 71 | + import json, sys |
| 72 | + with open("schemas/format-bridge.json") as f: |
| 73 | + bridge = json.load(f) |
| 74 | + formats = bridge.get("formats", []) |
| 75 | + assert len(formats) >= 10, f"Expected >=10 format entries, got {len(formats)}" |
| 76 | + for entry in formats: |
| 77 | + assert "bonfyre_ext" in entry and "aurekai_ext" in entry, f"Bad entry: {entry}" |
| 78 | + print(f"format-bridge.json valid ({len(formats)} format mappings).") |
| 79 | + PY |
| 80 | +
|
| 81 | + build-matrix: |
| 82 | + name: Build sample operators (${{ matrix.os }}) |
| 83 | + runs-on: ${{ matrix.os }} |
| 84 | + strategy: |
| 85 | + fail-fast: false |
| 86 | + matrix: |
| 87 | + os: [ubuntu-latest, macos-latest] |
| 88 | + operator: |
| 89 | + - BonfyreHash |
| 90 | + - BonfyreTag |
| 91 | + - BonfyreFragment |
| 92 | + - BonfyrePack |
| 93 | + - BonfyreBrief |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + |
| 97 | + - name: Install build dependencies (Ubuntu) |
| 98 | + if: runner.os == 'Linux' |
| 99 | + run: sudo apt-get install -y gcc make |
| 100 | + |
| 101 | + - name: Build ${{ matrix.operator }} |
| 102 | + run: | |
| 103 | + if [ -f "cmd/${{ matrix.operator }}/Makefile" ]; then |
| 104 | + make -C "cmd/${{ matrix.operator }}" MARCH= |
| 105 | + elif [ -f "cmd/${{ matrix.operator }}/src/main.c" ]; then |
| 106 | + mkdir -p "cmd/${{ matrix.operator }}/bin" |
| 107 | + cc -O2 -std=c11 -D_DEFAULT_SOURCE \ |
| 108 | + -o "cmd/${{ matrix.operator }}/bin/${{ matrix.operator }}" \ |
| 109 | + cmd/${{ matrix.operator }}/src/*.c \ |
| 110 | + $(find lib -name '*.a' 2>/dev/null | head -5 | tr '\n' ' ') \ |
| 111 | + -lm 2>&1 | tail -20 || true |
| 112 | + echo "build attempted (may need lib deps)" |
| 113 | + else |
| 114 | + echo "no Makefile or src/main.c found — skipping" |
| 115 | + fi |
| 116 | +
|
| 117 | + operator-index-sync: |
| 118 | + name: Check operator index is up to date |
| 119 | + runs-on: ubuntu-latest |
| 120 | + steps: |
| 121 | + - uses: actions/checkout@v4 |
| 122 | + |
| 123 | + - name: Verify index total matches cmd/ count |
| 124 | + run: | |
| 125 | + DISK=$(find cmd -maxdepth 1 -mindepth 1 -type d | wc -l | tr -d ' ') |
| 126 | + INDEX=$(python3 -c "import json; print(json.load(open('operator-index.json'))['total_operators'])") |
| 127 | + echo "Operators on disk: $DISK" |
| 128 | + echo "Operators in index: $INDEX" |
| 129 | + if [ "$DISK" != "$INDEX" ]; then |
| 130 | + echo "::error::Operator count mismatch — run scripts to regenerate operator-index.json" |
| 131 | + exit 1 |
| 132 | + fi |
| 133 | + echo "Counts match: $DISK" |
0 commit comments