|
| 1 | +name: PR Validation |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +env: |
| 10 | + # Consistent image tag for CI |
| 11 | + IMAGE_TAG: ci-${{ github.sha }} |
| 12 | + |
| 13 | +jobs: |
| 14 | + lint: |
| 15 | + name: Lint |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Install just |
| 22 | + uses: extractions/setup-just@v2 |
| 23 | + |
| 24 | + - name: Setup Go |
| 25 | + uses: actions/setup-go@v5 |
| 26 | + with: |
| 27 | + go-version: '1.25' |
| 28 | + cache-dependency-path: device-plugin/go.sum |
| 29 | + |
| 30 | + - name: Setup Rust |
| 31 | + uses: dtolnay/rust-toolchain@stable |
| 32 | + with: |
| 33 | + components: rustfmt, clippy |
| 34 | + |
| 35 | + - name: Check formatting |
| 36 | + run: just fmt-check |
| 37 | + |
| 38 | + - name: Run linters |
| 39 | + run: just lint-strict |
| 40 | + |
| 41 | + build: |
| 42 | + name: Build |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - name: Checkout |
| 46 | + uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - name: Install just |
| 49 | + uses: extractions/setup-just@v2 |
| 50 | + |
| 51 | + - name: Setup Go |
| 52 | + uses: actions/setup-go@v5 |
| 53 | + with: |
| 54 | + go-version: '1.25' |
| 55 | + cache-dependency-path: device-plugin/go.sum |
| 56 | + |
| 57 | + - name: Build device plugin |
| 58 | + run: just plugin-build |
| 59 | + |
| 60 | + integration: |
| 61 | + name: Integration Tests |
| 62 | + runs-on: ubuntu-24.04 |
| 63 | + needs: [lint, build] |
| 64 | + steps: |
| 65 | + - name: Checkout |
| 66 | + uses: actions/checkout@v4 |
| 67 | + |
| 68 | + - name: Setup Go |
| 69 | + uses: actions/setup-go@v5 |
| 70 | + with: |
| 71 | + go-version: '1.25' |
| 72 | + cache-dependency-path: device-plugin/go.sum |
| 73 | + |
| 74 | + - name: Enable KVM |
| 75 | + run: | |
| 76 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 77 | + sudo udevadm control --reload-rules |
| 78 | + sudo udevadm trigger --name-match=kvm |
| 79 | + |
| 80 | + # Verify KVM is available |
| 81 | + if [ ! -e /dev/kvm ]; then |
| 82 | + echo "::error::KVM is not available on this runner" |
| 83 | + exit 1 |
| 84 | + fi |
| 85 | + ls -la /dev/kvm |
| 86 | + echo "✓ KVM enabled" |
| 87 | +
|
| 88 | + - name: Install just |
| 89 | + uses: extractions/setup-just@v2 |
| 90 | + |
| 91 | + - name: Install kind |
| 92 | + run: | |
| 93 | + go install sigs.k8s.io/kind@latest |
| 94 | + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH |
| 95 | +
|
| 96 | + - name: Install kubectl |
| 97 | + uses: azure/setup-kubectl@v4 |
| 98 | + |
| 99 | + - name: Create KIND cluster |
| 100 | + run: | |
| 101 | + just local-up |
| 102 | + echo "✓ KIND cluster created" |
| 103 | +
|
| 104 | + - name: Build device plugin |
| 105 | + run: | |
| 106 | + just plugin-build |
| 107 | + echo "✓ Device plugin built" |
| 108 | +
|
| 109 | + - name: Push device plugin to local registry |
| 110 | + run: | |
| 111 | + just plugin-local-push |
| 112 | + echo "✓ Device plugin pushed to local registry" |
| 113 | +
|
| 114 | + - name: Deploy device plugin |
| 115 | + run: | |
| 116 | + just plugin-local-deploy |
| 117 | + echo "✓ Device plugin deployed" |
| 118 | +
|
| 119 | + - name: Wait for device plugin to be ready |
| 120 | + run: | |
| 121 | + echo "Waiting for device plugin DaemonSet..." |
| 122 | + kubectl rollout status daemonset/hyperlight-device-plugin -n hyperlight-system --timeout=120s |
| 123 | + |
| 124 | + # Wait for node resources to be advertised |
| 125 | + echo "Waiting for node resources..." |
| 126 | + for i in {1..30}; do |
| 127 | + capacity=$(kubectl get nodes -o jsonpath='{.items[0].status.allocatable.hyperlight\.dev/hypervisor}' 2>/dev/null || echo "0") |
| 128 | + if [ "$capacity" != "0" ] && [ -n "$capacity" ]; then |
| 129 | + echo "✓ Node advertising $capacity hyperlight.dev/hypervisor devices" |
| 130 | + break |
| 131 | + fi |
| 132 | + echo "Waiting for device plugin to register resources... ($i/30)" |
| 133 | + sleep 2 |
| 134 | + done |
| 135 | +
|
| 136 | + - name: Run device plugin tests |
| 137 | + run: | |
| 138 | + ./scripts/test.sh plugin |
| 139 | + ./scripts/test.sh nodes |
| 140 | + ./scripts/test.sh kvm |
| 141 | + echo "✓ Device plugin tests passed" |
| 142 | +
|
| 143 | + - name: Build Hyperlight app |
| 144 | + run: | |
| 145 | + just app-build |
| 146 | + echo "✓ Hyperlight app built" |
| 147 | +
|
| 148 | + - name: Push Hyperlight app to local registry |
| 149 | + run: | |
| 150 | + just app-local-push |
| 151 | + echo "✓ Hyperlight app pushed to local registry" |
| 152 | +
|
| 153 | + - name: Deploy Hyperlight app |
| 154 | + run: | |
| 155 | + just app-local-deploy |
| 156 | + echo "✓ Hyperlight app deployed" |
| 157 | +
|
| 158 | + - name: Wait for Hyperlight app to be ready |
| 159 | + run: | |
| 160 | + echo "Waiting for Hyperlight app deployment..." |
| 161 | + kubectl rollout status deployment/hyperlight-hello-kvm --timeout=180s |
| 162 | +
|
| 163 | + - name: Validate Hyperlight app output |
| 164 | + run: | |
| 165 | + ./scripts/test.sh app |
| 166 | + echo "✓ Hyperlight app tests passed" |
| 167 | +
|
| 168 | + - name: Show status |
| 169 | + if: always() |
| 170 | + run: | |
| 171 | + echo "=== Pods ===" |
| 172 | + kubectl get pods -A |
| 173 | + echo "" |
| 174 | + echo "=== Device Plugin Logs ===" |
| 175 | + kubectl logs -n hyperlight-system -l app.kubernetes.io/name=hyperlight-device-plugin --tail=50 || true |
| 176 | + echo "" |
| 177 | + echo "=== Hyperlight App Logs ===" |
| 178 | + kubectl logs -l app=hyperlight-hello --tail=50 || true |
| 179 | +
|
| 180 | + - name: Cleanup |
| 181 | + if: always() |
| 182 | + run: | |
| 183 | + just local-down || true |
0 commit comments