Ci/build workflow #36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | |
| # SPDX-License-Identifier: BSD-3-Clause | |
| name: Build | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| # Least-privilege permissions: jobs only need to read the repository contents | |
| # (for actions/checkout). All other permissions are explicitly denied. | |
| permissions: | |
| contents: read | |
| jobs: | |
| # ============================================================ | |
| # Linux: build kernel modules | |
| # ============================================================ | |
| build-linux: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-22.04, ubuntu-latest] | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| - name: Install kernel headers and build tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| linux-headers-$(uname -r) \ | |
| linux-modules-$(uname -r) \ | |
| kmod | |
| - name: Build kernel modules | |
| working-directory: src/linux | |
| # KBUILD_MODPOST_WARN=1 demotes unresolved-symbol errors from modpost to | |
| # warnings. This is intentional for CI: usbnet and usbserial are kernel | |
| # built-ins on some runners (no .ko files, no Module.symvers entries), | |
| # so modpost cannot verify their CRCs. The compilation itself is valid; | |
| # we are checking that the source builds, not that it loads on this runner. | |
| run: | | |
| make KBUILD_MODPOST_WARN=1 | |
| - name: Verify build outputs | |
| working-directory: src/linux | |
| run: | | |
| echo "=== Built kernel modules ===" | |
| find . -name "*.ko" | sort | |
| test -f InfParser/qtiDevInf.ko || (echo "ERROR: qtiDevInf.ko not found" && exit 1) | |
| test -f qcom_usb/qcom_usb.ko || (echo "ERROR: qcom_usb.ko not found" && exit 1) | |
| test -f qcom_usbnet/qcom_usbnet.ko || (echo "ERROR: qcom_usbnet.ko not found" && exit 1) | |
| - name: Upload Linux build artifacts | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: linux-kernel-modules-${{ matrix.os }} | |
| path: | | |
| src/linux/**/*.ko | |
| retention-days: 7 | |
| # ============================================================ | |
| # Linux: build .deb package (ubuntu-22.04 only) | |
| # ============================================================ | |
| build-deb: | |
| runs-on: ubuntu-22.04 | |
| needs: build-linux | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| - name: Install dpkg tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y dpkg | |
| - name: Build .deb package | |
| working-directory: src/linux | |
| run: bash build-deb.sh | |
| - name: Verify .deb package | |
| working-directory: src/linux | |
| run: | | |
| DEB=$(find build -name "*.deb" | head -n 1) | |
| echo "Package: $DEB" | |
| test -n "$DEB" || (echo "ERROR: No .deb file produced" && exit 1) | |
| dpkg-deb -I "$DEB" | |
| dpkg-deb -c "$DEB" | |
| - name: Upload .deb artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: linux-deb-package | |
| path: src/linux/build/*.deb | |
| retention-days: 7 | |
| # ============================================================ | |
| # Windows: build drivers (x86, x64, arm64) | |
| # ============================================================ | |
| build-windows-drivers: | |
| runs-on: windows-2022 | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2 | |
| - name: Install WDK | |
| shell: pwsh | |
| run: | | |
| # Pinned to WDK 10.0.26100.6584 (Windows 11 25H2), the latest WDK | |
| # supported with Visual Studio 2022, which is what the windows-2022 | |
| # runner provides. Using a direct linkid instead of the latest-WDK | |
| # redirect prevents silent breakage when Microsoft ships a new WDK. | |
| # To upgrade: verify the new WDK + VS2022 combination builds cleanly, | |
| # then update this linkid and the comment above. | |
| $wdkUrl = "https://go.microsoft.com/fwlink/?linkid=2335869" | |
| $wdkInstaller = "$env:TEMP\wdksetup.exe" | |
| Write-Host "Downloading WDK via curl (follows redirects)..." | |
| & curl.exe -L --retry 3 --retry-delay 5 -o $wdkInstaller $wdkUrl | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Host "ERROR: curl download failed with exit code $LASTEXITCODE" -ForegroundColor Red | |
| exit $LASTEXITCODE | |
| } | |
| $fileSize = (Get-Item $wdkInstaller).Length | |
| Write-Host "Downloaded installer size: $fileSize bytes" | |
| if ($fileSize -lt 1MB) { | |
| Write-Host "ERROR: Downloaded file is too small ($fileSize bytes) -- likely corrupted or a redirect page." -ForegroundColor Red | |
| exit 1 | |
| } | |
| Write-Host "Installing WDK silently..." | |
| $proc = Start-Process -FilePath $wdkInstaller ` | |
| -ArgumentList "/quiet /norestart" ` | |
| -PassThru -Wait | |
| if ($proc.ExitCode -ne 0) { | |
| Write-Host "ERROR: WDK installer exited with code $($proc.ExitCode)" -ForegroundColor Red | |
| exit $proc.ExitCode | |
| } | |
| Write-Host "WDK installation complete." | |
| - name: Build Windows drivers (x86, x64, arm64) | |
| shell: pwsh | |
| working-directory: build | |
| run: | | |
| powershell -ExecutionPolicy Bypass -File "build_drivers.ps1" -OutputTo "$env:GITHUB_WORKSPACE\build\target" | |
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | |
| - name: Verify driver build outputs | |
| shell: pwsh | |
| run: | | |
| $driversDir = "build\target\drivers" | |
| Write-Host "=== Driver build outputs ===" | |
| Get-ChildItem -Path $driversDir -Recurse -File | Select-Object FullName | Format-Table -AutoSize | |
| $sysFiles = Get-ChildItem -Path $driversDir -Recurse -Filter "*.sys" | |
| if ($sysFiles.Count -eq 0) { | |
| Write-Host "ERROR: No .sys files found in $driversDir" -ForegroundColor Red | |
| exit 1 | |
| } | |
| Write-Host "Found $($sysFiles.Count) .sys file(s)." -ForegroundColor Green | |
| - name: Upload Windows driver artifacts | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: windows-drivers | |
| path: build/target/drivers/ | |
| retention-days: 7 | |
| # ============================================================ | |
| # Windows: build installers (x86, x64, arm64) | |
| # ============================================================ | |
| build-windows-installer: | |
| runs-on: windows-2022 | |
| needs: build-windows-drivers | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2 | |
| - name: Download Windows driver artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | |
| with: | |
| name: windows-drivers | |
| path: build/target/drivers | |
| - name: Build Windows installers (x86, x64, arm64) — skip signing | |
| shell: pwsh | |
| working-directory: build | |
| run: | | |
| & cmd.exe /c "build_installer.bat --no_sign_required" | |
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | |
| - name: Verify installer outputs | |
| shell: pwsh | |
| run: | | |
| $targetDir = "build\target" | |
| Write-Host "=== Installer build outputs ===" | |
| Get-ChildItem -Path $targetDir -Filter "*.exe" | Select-Object FullName | Format-Table -AutoSize | |
| $exeFiles = Get-ChildItem -Path $targetDir -Filter "qcom_usb_kernel_drivers_*.exe" | |
| if ($exeFiles.Count -eq 0) { | |
| Write-Host "ERROR: No installer .exe files found in $targetDir" -ForegroundColor Red | |
| exit 1 | |
| } | |
| Write-Host "Found $($exeFiles.Count) installer(s)." -ForegroundColor Green | |
| - name: Upload Windows installer artifacts | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: windows-installers | |
| path: build/target/qcom_usb_kernel_drivers_*.exe | |
| retention-days: 7 |