|
| 1 | +name: Windows CI |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + run_whpx_smoke: |
| 7 | + description: Run WHPX smoke tests on self-hosted runner |
| 8 | + required: false |
| 9 | + type: boolean |
| 10 | + default: false |
| 11 | + whpx_test_filter: |
| 12 | + description: Optional cargo test filter for WHPX smoke |
| 13 | + required: false |
| 14 | + type: string |
| 15 | + default: test_whpx_ |
| 16 | + rootfs_dir: |
| 17 | + description: Optional rootfs dir path on self-hosted runner |
| 18 | + required: false |
| 19 | + type: string |
| 20 | + default: '' |
| 21 | + cleanup_rootfs: |
| 22 | + description: Remove rootfs directory after smoke run |
| 23 | + required: false |
| 24 | + type: boolean |
| 25 | + default: false |
| 26 | + max_rootfs_age_hours: |
| 27 | + description: Rebuild rootfs if marker age exceeds this value |
| 28 | + required: false |
| 29 | + type: string |
| 30 | + default: '168' |
| 31 | + dry_run_rootfs_decision: |
| 32 | + description: Only evaluate rootfs reuse/rebuild decision and exit |
| 33 | + required: false |
| 34 | + type: boolean |
| 35 | + default: false |
| 36 | + fail_if_rootfs_rebuild: |
| 37 | + description: Fail run if rootfs decision is rebuild |
| 38 | + required: false |
| 39 | + type: boolean |
| 40 | + default: false |
| 41 | + rootfs_marker_format: |
| 42 | + description: Rootfs marker format/version used for reuse checks |
| 43 | + required: false |
| 44 | + type: string |
| 45 | + default: libkrun-windows-smoke-rootfs-v1 |
| 46 | + compatible_rootfs_marker_formats: |
| 47 | + description: Additional compatible marker formats (comma-separated) |
| 48 | + required: false |
| 49 | + type: string |
| 50 | + default: '' |
| 51 | + promote_compatible_marker: |
| 52 | + description: Rewrite compatible marker to primary marker format |
| 53 | + required: false |
| 54 | + type: boolean |
| 55 | + default: true |
| 56 | + |
| 57 | +jobs: |
| 58 | + windows-build-and-tests: |
| 59 | + name: Windows build and tests |
| 60 | + runs-on: windows-latest |
| 61 | + continue-on-error: true |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v4 |
| 64 | + |
| 65 | + - name: Setup Rust toolchain |
| 66 | + uses: dtolnay/rust-toolchain@stable |
| 67 | + with: |
| 68 | + targets: x86_64-pc-windows-msvc |
| 69 | + |
| 70 | + - name: Create a fake init |
| 71 | + shell: pwsh |
| 72 | + run: | |
| 73 | + New-Item -ItemType File -Path "init/init" -Force | Out-Null |
| 74 | +
|
| 75 | + - name: Build check (Windows target) |
| 76 | + run: cargo check -p utils -p polly -p devices -p vmm -p libkrun --target x86_64-pc-windows-msvc |
| 77 | + continue-on-error: true |
| 78 | + |
| 79 | + - name: Utils tests (Windows) |
| 80 | + run: cargo test -p utils --target x86_64-pc-windows-msvc --lib |
| 81 | + continue-on-error: true |
| 82 | + |
| 83 | + - name: Polly tests |
| 84 | + run: cargo test -p polly --target x86_64-pc-windows-msvc --lib |
| 85 | + continue-on-error: true |
| 86 | + |
| 87 | + - name: VMM tests (Windows) |
| 88 | + run: cargo test -p vmm --target x86_64-pc-windows-msvc --lib |
| 89 | + continue-on-error: true |
| 90 | + |
| 91 | + windows-whpx-smoke: |
| 92 | + name: Windows WHPX smoke (manual) |
| 93 | + if: github.event_name == 'workflow_dispatch' && inputs.run_whpx_smoke |
| 94 | + runs-on: [self-hosted, windows, hyperv] |
| 95 | + steps: |
| 96 | + - uses: actions/checkout@v4 |
| 97 | + |
| 98 | + - name: Setup Rust toolchain |
| 99 | + uses: dtolnay/rust-toolchain@stable |
| 100 | + with: |
| 101 | + targets: x86_64-pc-windows-msvc |
| 102 | + |
| 103 | + - name: Create a fake init |
| 104 | + shell: pwsh |
| 105 | + run: | |
| 106 | + New-Item -ItemType File -Path "init/init" -Force | Out-Null |
| 107 | +
|
| 108 | + - name: WHPX smoke suite |
| 109 | + shell: pwsh |
| 110 | + run: | |
| 111 | + $rootfsArgs = @() |
| 112 | + $cleanupArgs = @() |
| 113 | + $dryRunArgs = @() |
| 114 | + $failIfRebuildArgs = @() |
| 115 | + $promoteArgs = @() |
| 116 | + if ("${{ inputs.rootfs_dir }}") { |
| 117 | + $rootfsArgs = @("-RootfsDir", "${{ inputs.rootfs_dir }}") |
| 118 | + } |
| 119 | + if ("${{ inputs.cleanup_rootfs }}" -eq "true") { |
| 120 | + $cleanupArgs = @("-CleanupRootfs") |
| 121 | + } |
| 122 | + if ("${{ inputs.dry_run_rootfs_decision }}" -eq "true") { |
| 123 | + $dryRunArgs = @("-DryRunRootfsDecision") |
| 124 | + } |
| 125 | + if ("${{ inputs.fail_if_rootfs_rebuild }}" -eq "true") { |
| 126 | + $failIfRebuildArgs = @("-FailIfRootfsRebuild") |
| 127 | + } |
| 128 | + if ("${{ inputs.promote_compatible_marker }}" -eq "true") { |
| 129 | + $promoteArgs = @("-PromoteCompatibleMarker") |
| 130 | + } |
| 131 | + ./tests/windows/run_whpx_smoke.ps1 -Target x86_64-pc-windows-msvc -TestFilter "${{ inputs.whpx_test_filter }}" -LogDir "$env:RUNNER_TEMP/libkrun-whpx-smoke" -RootfsMarkerFormat "${{ inputs.rootfs_marker_format }}" -CompatibleRootfsMarkerFormats "${{ inputs.compatible_rootfs_marker_formats }}" -MaxRootfsAgeHours "${{ inputs.max_rootfs_age_hours }}" @rootfsArgs @cleanupArgs @dryRunArgs @failIfRebuildArgs @promoteArgs |
| 132 | +
|
| 133 | + - name: Publish WHPX smoke summary |
| 134 | + if: always() |
| 135 | + shell: pwsh |
| 136 | + run: | |
| 137 | + $summaryFile = "$env:RUNNER_TEMP/libkrun-whpx-smoke/summary.txt" |
| 138 | + $summaryJsonFile = "$env:RUNNER_TEMP/libkrun-whpx-smoke/summary.json" |
| 139 | + $phaseFile = "$env:RUNNER_TEMP/libkrun-whpx-smoke/phases.log" |
| 140 | +
|
| 141 | + if ((-not (Test-Path $summaryFile)) -and (-not (Test-Path $summaryJsonFile))) { |
| 142 | + "## Windows WHPX smoke`n`nFAIL: summary artifact not found." >> $env:GITHUB_STEP_SUMMARY |
| 143 | + exit 0 |
| 144 | + } |
| 145 | +
|
| 146 | + $summary = @{} |
| 147 | + if (Test-Path $summaryJsonFile) { |
| 148 | + $json = Get-Content $summaryJsonFile -Raw | ConvertFrom-Json |
| 149 | + foreach ($prop in $json.PSObject.Properties) { |
| 150 | + $summary[$prop.Name] = [string]$prop.Value |
| 151 | + } |
| 152 | + } |
| 153 | + else { |
| 154 | + Get-Content $summaryFile | ForEach-Object { |
| 155 | + if ($_ -match "^([^=]+)=(.*)$") { |
| 156 | + $summary[$matches[1]] = $matches[2] |
| 157 | + } |
| 158 | + } |
| 159 | + } |
| 160 | +
|
| 161 | + $status = $summary["status"] |
| 162 | + if (-not $status) { $status = "unknown" } |
| 163 | + $icon = if ($status -eq "passed") { "OK" } else { "FAIL" } |
| 164 | +
|
| 165 | + "## Windows WHPX smoke" >> $env:GITHUB_STEP_SUMMARY |
| 166 | + "" >> $env:GITHUB_STEP_SUMMARY |
| 167 | + "$icon status: **$status**" >> $env:GITHUB_STEP_SUMMARY |
| 168 | + "- git_sha: $($summary['git_sha'])" >> $env:GITHUB_STEP_SUMMARY |
| 169 | + "- runner_name: $($summary['runner_name'])" >> $env:GITHUB_STEP_SUMMARY |
| 170 | + "- runner_os: $($summary['runner_os'])" >> $env:GITHUB_STEP_SUMMARY |
| 171 | + "- target: $($summary['target'])" >> $env:GITHUB_STEP_SUMMARY |
| 172 | + "- filter: $($summary['test_filter'])" >> $env:GITHUB_STEP_SUMMARY |
| 173 | + "- cleanup_rootfs: $($summary['cleanup_rootfs'])" >> $env:GITHUB_STEP_SUMMARY |
| 174 | + "- dry_run_rootfs_decision: $($summary['dry_run_rootfs_decision'])" >> $env:GITHUB_STEP_SUMMARY |
| 175 | + "- fail_if_rootfs_rebuild: $($summary['fail_if_rootfs_rebuild'])" >> $env:GITHUB_STEP_SUMMARY |
| 176 | + "- rootfs_marker_format: $($summary['rootfs_marker_format'])" >> $env:GITHUB_STEP_SUMMARY |
| 177 | + "- compatible_rootfs_marker_formats: $($summary['compatible_rootfs_marker_formats'])" >> $env:GITHUB_STEP_SUMMARY |
| 178 | + "- promote_compatible_marker: $($summary['promote_compatible_marker'])" >> $env:GITHUB_STEP_SUMMARY |
| 179 | + "- max_rootfs_age_hours: $($summary['max_rootfs_age_hours'])" >> $env:GITHUB_STEP_SUMMARY |
| 180 | + "- rootfs_reused: $($summary['rootfs_reused'])" >> $env:GITHUB_STEP_SUMMARY |
| 181 | + "- rootfs_action: $($summary['rootfs_action'])" >> $env:GITHUB_STEP_SUMMARY |
| 182 | + "- rootfs_reuse_reason: $($summary['rootfs_reuse_reason'])" >> $env:GITHUB_STEP_SUMMARY |
| 183 | + "- marker_promoted: $($summary['marker_promoted'])" >> $env:GITHUB_STEP_SUMMARY |
| 184 | + "- log: $($summary['log_path'])" >> $env:GITHUB_STEP_SUMMARY |
| 185 | + "" >> $env:GITHUB_STEP_SUMMARY |
| 186 | +
|
| 187 | + if (Test-Path $phaseFile) { |
| 188 | + "<details><summary>Phase timeline</summary>" >> $env:GITHUB_STEP_SUMMARY |
| 189 | + "" >> $env:GITHUB_STEP_SUMMARY |
| 190 | + "```text" >> $env:GITHUB_STEP_SUMMARY |
| 191 | + Get-Content $phaseFile | ForEach-Object { $_ >> $env:GITHUB_STEP_SUMMARY } |
| 192 | + "```" >> $env:GITHUB_STEP_SUMMARY |
| 193 | + "</details>" >> $env:GITHUB_STEP_SUMMARY |
| 194 | + } |
| 195 | +
|
| 196 | + - name: Upload WHPX smoke logs |
| 197 | + if: always() |
| 198 | + uses: actions/upload-artifact@v4 |
| 199 | + with: |
| 200 | + name: windows-whpx-smoke-logs |
| 201 | + path: ${{ runner.temp }}/libkrun-whpx-smoke |
| 202 | + if-no-files-found: ignore |
0 commit comments