|
| 1 | +# Build kxo kernel module and run full test suite. |
| 2 | +# |
| 3 | +# Parallelism (4 independent jobs, 1 sequential): |
| 4 | +# commit-hygiene -- vanity hash prefix + subject format + AI trailer detection |
| 5 | +# lint -- clang-format, newline, banned functions, cppcheck, shfmt |
| 6 | +# unit-tests -- test-game, test-coro (no kernel dependency) |
| 7 | +# build -- kernel module + xo-user compile check |
| 8 | +# integration -- same-runner build, insmod, device I/O, game completion, |
| 9 | +# graceful stop via sysfs, clean unload |
| 10 | +# |
| 11 | +# commit-hygiene, lint, unit-tests, and build run in parallel. |
| 12 | +# integration-tests waits for build only. |
| 13 | +name: Build and Test |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + branches: [main, master] |
| 18 | + pull_request: |
| 19 | + branches: [main, master] |
| 20 | + |
| 21 | +jobs: |
| 22 | + # ---- Commit hygiene: vanity hash prefix + subject format ---- |
| 23 | + commit-hygiene: |
| 24 | + runs-on: ubuntu-24.04 |
| 25 | + steps: |
| 26 | + - name: Checkout (full history for commit validation) |
| 27 | + uses: actions/checkout@v6 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Validate commit log |
| 32 | + env: |
| 33 | + EVENT_NAME: ${{ github.event_name }} |
| 34 | + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} |
| 35 | + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
| 36 | + PUSH_BEFORE_SHA: ${{ github.event.before }} |
| 37 | + PUSH_HEAD_SHA: ${{ github.sha }} |
| 38 | + run: | |
| 39 | + range= |
| 40 | + if [ "$EVENT_NAME" = "pull_request" ]; then |
| 41 | + range="${PR_BASE_SHA}..${PR_HEAD_SHA}" |
| 42 | + elif [ -n "$PUSH_BEFORE_SHA" ] && [ "$PUSH_BEFORE_SHA" != "0000000000000000000000000000000000000000" ]; then |
| 43 | + range="${PUSH_BEFORE_SHA}..${PUSH_HEAD_SHA}" |
| 44 | + fi |
| 45 | +
|
| 46 | + if [ -n "$range" ]; then |
| 47 | + scripts/check-commitlog.sh --range "$range" |
| 48 | + else |
| 49 | + scripts/check-commitlog.sh |
| 50 | + fi |
| 51 | +
|
| 52 | + # ---- Lint: formatting + static analysis (consolidated, one apt install) ---- |
| 53 | + lint: |
| 54 | + runs-on: ubuntu-24.04 |
| 55 | + steps: |
| 56 | + - name: Checkout |
| 57 | + uses: actions/checkout@v6 |
| 58 | + |
| 59 | + - name: Cache apt packages |
| 60 | + uses: actions/cache@v5 |
| 61 | + with: |
| 62 | + path: ~/apt-cache |
| 63 | + key: apt-lint-${{ runner.os }}-${{ hashFiles('.github/workflows/main.yml') }} |
| 64 | + |
| 65 | + - name: Install tools |
| 66 | + run: | |
| 67 | + mkdir -p ~/apt-cache |
| 68 | + sudo apt-get update |
| 69 | + sudo apt-get install -y -o Dir::Cache::Archives=$HOME/apt-cache \ |
| 70 | + clang-format-20 cppcheck shfmt aspell |
| 71 | +
|
| 72 | + - name: Check trailing newline |
| 73 | + run: .ci/check-newline.sh |
| 74 | + |
| 75 | + - name: Check clang-format |
| 76 | + run: .ci/check-format.sh |
| 77 | + |
| 78 | + - name: Check banned functions |
| 79 | + run: .ci/check-banned.sh |
| 80 | + |
| 81 | + - name: Static analysis (cppcheck) |
| 82 | + run: .ci/check-cppcheck.sh |
| 83 | + |
| 84 | + - name: Check shell scripts (shfmt) |
| 85 | + run: .ci/check-shell.sh |
| 86 | + |
| 87 | + # ---- Unit tests: no kernel dependency, fast ---- |
| 88 | + unit-tests: |
| 89 | + runs-on: ubuntu-24.04 |
| 90 | + steps: |
| 91 | + - name: Checkout |
| 92 | + uses: actions/checkout@v6 |
| 93 | + |
| 94 | + - name: Run unit tests |
| 95 | + run: make check-unit |
| 96 | + |
| 97 | + # ---- Build kernel module + userspace compile check ---- |
| 98 | + build: |
| 99 | + runs-on: ubuntu-24.04 |
| 100 | + steps: |
| 101 | + - name: Checkout |
| 102 | + uses: actions/checkout@v6 |
| 103 | + |
| 104 | + - name: Install kernel headers |
| 105 | + run: | |
| 106 | + sudo apt-get update |
| 107 | + sudo apt-get install -y linux-headers-$(uname -r) |
| 108 | +
|
| 109 | + - name: Build kernel module and userspace |
| 110 | + run: make -j$(nproc) |
| 111 | + |
| 112 | + # ---- Integration tests: builds and loads module on the same runner ---- |
| 113 | + integration-tests: |
| 114 | + needs: build |
| 115 | + runs-on: ubuntu-24.04 |
| 116 | + timeout-minutes: 10 |
| 117 | + steps: |
| 118 | + - name: Checkout |
| 119 | + uses: actions/checkout@v6 |
| 120 | + |
| 121 | + - name: Install kernel headers |
| 122 | + run: | |
| 123 | + sudo apt-get update |
| 124 | + sudo apt-get install -y linux-headers-$(uname -r) |
| 125 | +
|
| 126 | + - name: Build kernel module and userspace |
| 127 | + run: make -j$(nproc) |
| 128 | + |
| 129 | + - name: Integration tests |
| 130 | + run: sudo tests/test-integration.sh |
| 131 | + |
| 132 | + - name: Kernel log diagnosis |
| 133 | + if: always() |
| 134 | + run: | |
| 135 | + echo "=== dmesg (last 100 lines) ===" |
| 136 | + sudo dmesg | tail -100 |
| 137 | + echo "" |
| 138 | + echo "=== Module info ===" |
| 139 | + modinfo kxo.ko 2>/dev/null || echo "(module not found)" |
| 140 | + echo "" |
| 141 | + echo "=== Loaded modules (kxo) ===" |
| 142 | + lsmod | grep kxo || echo "(not loaded)" |
0 commit comments