summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yml
blob: 125a43f93e7ffe12d26bf7fb8186bf56836f004b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# Open-IOV CI/CD Pipeline

name: Open-IOV CI

on:
  push:
    branches: [main, master, develop]
  pull_request:
    branches: [main, master, develop]

env:
  KERNEL_VERSION: ${{ matrix.kernel }}
  GCC_VERSION: ${{ matrix.gcc }}
  GSP_VERSION: '570.144'
  FW_RAW_BASE: https://raw.githubusercontent.com/NVIDIA/linux-firmware/2237b99e29d09bebffdb706ae05005d9026fd7e4/nvidia/tu102/gsp
  FW_MD5: 13ce12a392a31eeb79a2e6ebd3a4a93a

jobs:
  # ============================================================
  # Kernel Build & Test Matrix
  # ============================================================
  kernel-test:
    name: Kernel ${{ matrix.kernel }} / GCC ${{ matrix.gcc }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        kernel: ['6.1', '6.6', '6.8']
        gcc: ['11', '12', '13']
        include:
          - kernel: '6.1'
            gcc: '11'
            kernel_package: 'linux-headers-6.1.0-18-generic'
          - kernel: '6.6'
            gcc: '12'
            kernel_package: 'linux-headers-6.6.0-14-generic'
          - kernel: '6.8'
            gcc: '13'
            kernel_package: 'linux-headers-6.8.0-48-generic'
    timeout-minutes: 30

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install kernel headers
        run: |
          sudo apt-get update
          sudo apt-get install -y ${{ matrix.kernel_package }} build-essential gcc-${{ matrix.gcc }} kunit

      - name: Set GCC
        run: |
          sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.gcc }} 100
          gcc --version

      - name: Fetch GSP firmware (linux-firmware)
        run: |
          mkdir -p firmware/57X-GSP/570.144
          curl -fSL --retry 3 -o firmware/57X-GSP/570.144/gsp-${{ env.GSP_VERSION }}.bin \
            "${{ env.FW_RAW_BASE }}/gsp-${{ env.GSP_VERSION }}.bin"
          objcopy -O binary --only-section=.fwimage \
            firmware/57X-GSP/570.144/gsp-${{ env.GSP_VERSION }}.bin \
            firmware/57X-GSP/570.144/gsp-${{ env.GSP_VERSION }}.fwimage.bin
          echo "${{ env.FW_MD5 }}  firmware/57X-GSP/570.144/gsp-${{ env.GSP_VERSION }}.fwimage.bin" | md5sum -c -

      - name: Build host kernel module
        run: make kernel

      - name: Build legacy guest driver
        run: make -C driver KDIR=/lib/modules/$(uname -r)/build

      - name: Build kernel tests
        run: make -C kernel/tests KDIR=/lib/modules/$(uname -r)/build

      - name: Run comprehensive test module
        run: |
          cd kernel/tests
          sudo insmod gsp_vgpu_comprehensive_test.ko
          sleep 2
          dmesg -T | tail -50
          sudo rmmod gsp_vgpu_comprehensive_test

      - name: Run KUnit tests
        if: matrix.kernel == '6.6' && matrix.gcc == '12'
        run: |
          cd kernel/tests
          sudo insmod gsp_vgpu_kunit_test.ko
          sleep 2
          dmesg -T | grep -E "(kunit|KUNIT|PASS|FAIL)" | tail -50
          sudo rmmod gsp_vgpu_kunit_test

      - name: Run mock tests
        run: |
          cd kernel/tests
          sudo insmod gsp_vgpu_mock_test.ko
          sleep 2
          dmesg -T | grep -E "(PASS|FAIL|Test Results)" | tail -50
          sudo rmmod gsp_vgpu_mock_test

  # ============================================================
  # Firmware Validation (fetched from linux-firmware.git)
  # ============================================================
  firmware-validation:
    name: Firmware Validation
    runs-on: ubuntu-latest
    timeout-minutes: 15

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Fetch and extract firmware
        run: |
          mkdir -p firmware/57X-GSP/570.144
          curl -fSL --retry 3 -o firmware/57X-GSP/570.144/gsp-${{ env.GSP_VERSION }}.bin \
            "${{ env.FW_RAW_BASE }}/gsp-${{ env.GSP_VERSION }}.bin"
          objcopy -O binary --only-section=.fwimage \
            firmware/57X-GSP/570.144/gsp-${{ env.GSP_VERSION }}.bin \
            firmware/57X-GSP/570.144/gsp-${{ env.GSP_VERSION }}.fwimage.bin

      - name: Verify firmware MD5
        run: |
          cd firmware/57X-GSP/570.144
          actual=$(md5sum gsp-${{ env.GSP_VERSION }}.fwimage.bin | cut -d' ' -f1)
          echo "Expected: ${{ env.FW_MD5 }}"
          echo "Actual:   $actual"
          [ "$actual" = "${{ env.FW_MD5 }}" ]
          echo "MD5 verified"

      - name: Verify firmware size
        run: |
          cd firmware/57X-GSP/570.144
          size=$(stat -c%s gsp-${{ env.GSP_VERSION }}.fwimage.bin)
          echo "Size: $size bytes"
          if [ "$size" -lt 28000000 ] || [ "$size" -gt 31000000 ]; then
            echo "Unexpected firmware size!"
            exit 1
          fi
          echo "Size verified"

  # ============================================================
  # Documentation Validation
  # ============================================================
  docs-validation:
    name: Documentation Validation
    runs-on: ubuntu-latest
    timeout-minutes: 10

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Check wiki files exist
        run: |
          cd wiki
          required=(
            "GSP-570.144W-Firmware-Analysis.md"
            "RPC-Message-Format.md"
            "BAR-Emulation-Specification.md"
            "WPR-Management.md"
            "Migration-Protocol.md"
            "vGPU-IO-Integration-Guide.md"
            "Address-Reference.md"
            "Error-Codes.md"
            "Glossary.md"
            "README.md"
          )
          for f in "${required[@]}"; do
            if [ ! -f "$f" ]; then
              echo "Missing: $f"
              exit 1
            fi
            echo "Found: $f"
          done

      - name: Check documentation links
        run: python3 scripts/check-docs-links.py

      - name: Validate markdown syntax
        run: |
          cd wiki
          for f in *.md; do
            if ! head -1 "$f" | grep -q "^#"; then
              echo "Warning: $f missing H1 header"
            fi
          done

      - name: Check cross-references
        run: |
          cd wiki
          for f in *.md; do
            grep -o '\[.*\](.*\.md)' "$f" | while read link; do
              target=$(echo "$link" | sed -n 's/.*(\(.*\))/\1/p')
              if [ ! -f "$target" ]; then
                echo "Broken link in $f: $target"
                exit 1
              fi
            done
          done

  # ============================================================
  # Static Analysis
  # ============================================================
  static-analysis:
    name: Static Analysis
    runs-on: ubuntu-latest
    timeout-minutes: 20

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y linux-headers-$(uname -r) cppcheck

      - name: Run checkpatch on host kernel module
        run: |
          cd kernel
          find . -name "*.c" -o -name "*.h" | xargs /usr/src/linux-headers-$(uname -r)/scripts/checkpatch.pl --no-tree --strict || true

      - name: Run cppcheck
        run: |
          cd kernel
          cppcheck --enable=all --std=c11 --force -I include . 2>&1 | head -100 || true

  # ============================================================
  # Userspace Test Build
  # ============================================================
  userspace-build:
    name: Userspace Build Test
    runs-on: ubuntu-latest
    timeout-minutes: 10

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Build userspace
        run: make userspace examples

      - name: Build userspace tests
        run: make -C userspace/tests

      - name: Verify binary
        run: |
          cd userspace/tests
          ./test_vgpu_userspace 2>&1 | head -20 || true
          # Expected to fail without driver, but should run

  # ============================================================
  # Integration Test (requires hardware - manual trigger)
  # ============================================================
  integration-test:
    name: Integration Test (Manual)
    runs-on: [self-hosted, gpu, nvidia]
    if: github.event_name == 'workflow_dispatch'
    timeout-minutes: 60

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Full install
        run: ./install.sh --no-load

      - name: Run full integration test
        run: sudo ./tools/test/run_integration_tests.sh all

# ============================================================
# Workflow Permissions
# ============================================================
permissions:
  contents: read
  checks: write
  pull-requests: write