summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yml
blob: e4fed5a6e03a66fa4d0bff1a13bc5f479e6a1bdf (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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# GSP vGPU-IO CI/CD Pipeline

name: GSP vGPU-IO CI

on:
  push:
    branches: [main, develop]
    paths:
      - 'open-iov/**'
  pull_request:
    branches: [main, develop]
    paths:
      - 'open-iov/**'

env:
  KERNEL_VERSION: ${{ matrix.kernel }}
  GCC_VERSION: ${{ matrix.gcc }}

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
        with:
          path: open-iov

      - 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: Build driver
        run: |
          cd open-iov/driver
          make KDIR=/lib/modules/$(uname -r)/build

      - name: Build kernel tests
        run: |
          cd open-iov/kernel/tests
          make KDIR=/lib/modules/$(uname -r)/build

      - name: Run comprehensive test module
        run: |
          cd open-iov/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 open-iov/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 open-iov/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
  # ============================================================
  firmware-validation:
    name: Firmware Validation
    runs-on: ubuntu-latest
    timeout-minutes: 15
    
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          path: open-iov

      - name: Verify firmware exists
        run: |
          ls -la open-iov/firmware/570-GSP/gsp-570.144.fwimage.bin
          
      - name: Verify firmware MD5
        run: |
          cd open-iov/firmware/570-GSP
          expected="13ce12a392a31eeb79a2e6ebd3a4a93a"
          actual=$(md5sum gsp-570.144.fwimage.bin | cut -d' ' -f1)
          echo "Expected: $expected"
          echo "Actual:   $actual"
          if [ "$expected" != "$actual" ]; then
            echo "MD5 mismatch!"
            exit 1
          fi
          echo "MD5 verified ✓"

      - name: Verify firmware size
        run: |
          cd open-iov/firmware/570-GSP
          size=$(stat -c%s gsp-570.144.fwimage.bin)
          expected=29622272  # 28.5 MB
          echo "Size: $size bytes"
          if [ "$size" -lt 28000000 ] || [ "$size" -gt 31000000 ]; then
            echo "Unexpected firmware size!"
            exit 1
          fi
          echo "Size verified ✓"

      - name: Verify decompiled output
        run: |
          cd open-iov/firmware/570-GSP/decompiled
          count=$(ls *.c | wc -l)
          echo "Decompiled files: $count"
          if [ "$count" -lt 80 ]; then
            echo "Expected at least 80 decompiled files!"
            exit 1
          fi
          echo "Decompilation verified ✓"

      - name: Verify key addresses in decompiled output
        run: |
          cd open-iov/firmware/570-GSP/decompiled
          # Check critical functions exist
          for func in \
            "FUN_ram_057a1ac0" \
            "FUN_ram_04cb8188" \
            "FUN_ram_04f00b0c" \
            "FUN_ram_04f00c78" \
            "FUN_ram_057e94ec" \
            "FUN_ram_051efbf4" \
            "FUN_ram_059be7f4" \
            "entry_ram_04009000"; do
            if [ ! -f "${func}_ram_*.c" ]; then
              echo "Missing: $func"
              exit 1
            fi
          done
          echo "Key functions verified ✓"

  # ============================================================
  # Documentation Validation
  # ============================================================
  docs-validation:
    name: Documentation Validation
    runs-on: ubuntu-latest
    timeout-minutes: 10
    
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          path: open-iov

      - name: Check wiki files exist
        run: |
          cd open-iov/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: Validate markdown syntax
        run: |
          cd open-iov/wiki
          # Check for basic markdown structure
          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 open-iov/wiki
          # Verify internal links resolve
          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
        with:
          path: open-iov

      - name: Install checkpatch.pl
        run: |
          sudo apt-get update
          sudo apt-get install -y linux-headers-$(uname -r)
          # checkpatch.pl comes with kernel headers

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

      - name: Run sparse
        run: |
          cd open-iov/driver
          make C=1 CHECK="/usr/bin/sparse" 2>&1 | head -100 || true

      - name: Run cppcheck
        run: |
          sudo apt-get install -y cppcheck
          cd open-iov/driver
          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
        with:
          path: open-iov

      - name: Build userspace tests
        run: |
          cd open-iov/userspace/tests
          make

      - name: Verify binary
        run: |
          cd open-iov/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
        with:
          path: open-iov

      - name: Run full integration test
        run: |
          cd open-iov
          sudo ./tools/test/run_integration_tests.sh all

  # ============================================================
  # Release Artifacts
  # ============================================================
  release:
    name: Create Release
    needs: [kernel-test, firmware-validation, docs-validation, static-analysis, userspace-build]
    if: github.event_name == 'release' && github.event.action == 'published'
    runs-on: ubuntu-latest
    timeout-minutes: 15
    
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          path: open-iov

      - name: Build release artifacts
        run: |
          cd open-iov
          # Create release package
          mkdir -p release
          cp firmware/570-GSP/gsp-570.144.fwimage.bin release/
          cp -r wiki release/
          cp -r driver release/
          cp -r kernel/tests release/
          cp -r userspace/tests release/
          cp README.md release/
          tar -czf gsp-vgpu-io-${{ github.event.release.tag_name }}.tar.gz release/

      - name: Upload release assets
        uses: softprops/action-gh-release@v1
        with:
          files: open-iov/gsp-vgpu-io-${{ github.event.release.tag_name }}.tar.gz

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