forked from libkrun/libkrun
-
Notifications
You must be signed in to change notification settings - Fork 0
234 lines (210 loc) · 9 KB
/
Copy pathwindows_ci.yml
File metadata and controls
234 lines (210 loc) · 9 KB
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
name: Windows CI
on:
pull_request:
workflow_dispatch:
inputs:
run_whpx_smoke:
description: Run WHPX smoke tests on self-hosted runner
required: false
type: boolean
default: false
whpx_test_filter:
description: Optional cargo test filter for WHPX smoke
required: false
type: string
default: test_whpx_
rootfs_dir:
description: Optional rootfs dir path on self-hosted runner
required: false
type: string
default: ''
cleanup_rootfs:
description: Remove rootfs directory after smoke run
required: false
type: boolean
default: false
max_rootfs_age_hours:
description: Rebuild rootfs if marker age exceeds this value
required: false
type: string
default: '168'
dry_run_rootfs_decision:
description: Only evaluate rootfs reuse/rebuild decision and exit
required: false
type: boolean
default: false
fail_if_rootfs_rebuild:
description: Fail run if rootfs decision is rebuild
required: false
type: boolean
default: false
rootfs_marker_format:
description: Rootfs marker format/version used for reuse checks
required: false
type: string
default: libkrun-windows-smoke-rootfs-v1
compatible_rootfs_marker_formats:
description: Additional compatible marker formats (comma-separated)
required: false
type: string
default: ''
promote_compatible_marker:
description: Rewrite compatible marker to primary marker format
required: false
type: boolean
default: true
jobs:
windows-build-and-tests:
name: Windows build and tests
runs-on: windows-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- name: Create a fake init
shell: pwsh
run: |
New-Item -ItemType File -Path "init/init" -Force | Out-Null
- name: Build check (Windows target)
run: cargo check -p utils -p polly -p devices -p vmm -p libkrun --target x86_64-pc-windows-msvc
continue-on-error: true
- name: Utils tests (Windows)
run: cargo test -p utils --target x86_64-pc-windows-msvc --lib
continue-on-error: true
- name: Polly tests
run: cargo test -p polly --target x86_64-pc-windows-msvc --lib
continue-on-error: true
- name: VMM tests (Windows)
run: cargo test -p vmm --target x86_64-pc-windows-msvc --lib
continue-on-error: true
windows-build-dll:
name: Build krun.dll (Windows release)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- name: Create a fake init
shell: pwsh
run: New-Item -ItemType File -Path "init/init" -Force | Out-Null
- name: Build krun.dll
run: cargo build --release -p libkrun --target x86_64-pc-windows-msvc
- name: Prepare artifact
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist | Out-Null
Copy-Item target/x86_64-pc-windows-msvc/release/krun.dll dist/krun.dll
Copy-Item target/x86_64-pc-windows-msvc/release/krun.dll.lib dist/krun.lib
Copy-Item include/libkrun_windows.h dist/libkrun_windows.h
- name: Upload krun.dll artifact
uses: actions/upload-artifact@v4
with:
name: krun-windows-x64
path: dist/
windows-whpx-smoke:
name: Windows WHPX smoke (manual)
if: github.event_name == 'workflow_dispatch' && inputs.run_whpx_smoke
runs-on: [self-hosted, windows, hyperv]
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- name: Create a fake init
shell: pwsh
run: |
New-Item -ItemType File -Path "init/init" -Force | Out-Null
- name: WHPX smoke suite
shell: pwsh
run: |
$rootfsArgs = @()
$cleanupArgs = @()
$dryRunArgs = @()
$failIfRebuildArgs = @()
$promoteArgs = @()
if ("${{ inputs.rootfs_dir }}") {
$rootfsArgs = @("-RootfsDir", "${{ inputs.rootfs_dir }}")
}
if ("${{ inputs.cleanup_rootfs }}" -eq "true") {
$cleanupArgs = @("-CleanupRootfs")
}
if ("${{ inputs.dry_run_rootfs_decision }}" -eq "true") {
$dryRunArgs = @("-DryRunRootfsDecision")
}
if ("${{ inputs.fail_if_rootfs_rebuild }}" -eq "true") {
$failIfRebuildArgs = @("-FailIfRootfsRebuild")
}
if ("${{ inputs.promote_compatible_marker }}" -eq "true") {
$promoteArgs = @("-PromoteCompatibleMarker")
}
./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
- name: Publish WHPX smoke summary
if: always()
shell: pwsh
run: |
$summaryFile = "$env:RUNNER_TEMP/libkrun-whpx-smoke/summary.txt"
$summaryJsonFile = "$env:RUNNER_TEMP/libkrun-whpx-smoke/summary.json"
$phaseFile = "$env:RUNNER_TEMP/libkrun-whpx-smoke/phases.log"
if ((-not (Test-Path $summaryFile)) -and (-not (Test-Path $summaryJsonFile))) {
"## Windows WHPX smoke`n`nFAIL: summary artifact not found." >> $env:GITHUB_STEP_SUMMARY
exit 0
}
$summary = @{}
if (Test-Path $summaryJsonFile) {
$json = Get-Content $summaryJsonFile -Raw | ConvertFrom-Json
foreach ($prop in $json.PSObject.Properties) {
$summary[$prop.Name] = [string]$prop.Value
}
}
else {
Get-Content $summaryFile | ForEach-Object {
if ($_ -match "^([^=]+)=(.*)$") {
$summary[$matches[1]] = $matches[2]
}
}
}
$status = $summary["status"]
if (-not $status) { $status = "unknown" }
$icon = if ($status -eq "passed") { "OK" } else { "FAIL" }
"## Windows WHPX smoke" >> $env:GITHUB_STEP_SUMMARY
"" >> $env:GITHUB_STEP_SUMMARY
"$icon status: **$status**" >> $env:GITHUB_STEP_SUMMARY
"- git_sha: $($summary['git_sha'])" >> $env:GITHUB_STEP_SUMMARY
"- runner_name: $($summary['runner_name'])" >> $env:GITHUB_STEP_SUMMARY
"- runner_os: $($summary['runner_os'])" >> $env:GITHUB_STEP_SUMMARY
"- target: $($summary['target'])" >> $env:GITHUB_STEP_SUMMARY
"- filter: $($summary['test_filter'])" >> $env:GITHUB_STEP_SUMMARY
"- cleanup_rootfs: $($summary['cleanup_rootfs'])" >> $env:GITHUB_STEP_SUMMARY
"- dry_run_rootfs_decision: $($summary['dry_run_rootfs_decision'])" >> $env:GITHUB_STEP_SUMMARY
"- fail_if_rootfs_rebuild: $($summary['fail_if_rootfs_rebuild'])" >> $env:GITHUB_STEP_SUMMARY
"- rootfs_marker_format: $($summary['rootfs_marker_format'])" >> $env:GITHUB_STEP_SUMMARY
"- compatible_rootfs_marker_formats: $($summary['compatible_rootfs_marker_formats'])" >> $env:GITHUB_STEP_SUMMARY
"- promote_compatible_marker: $($summary['promote_compatible_marker'])" >> $env:GITHUB_STEP_SUMMARY
"- max_rootfs_age_hours: $($summary['max_rootfs_age_hours'])" >> $env:GITHUB_STEP_SUMMARY
"- rootfs_reused: $($summary['rootfs_reused'])" >> $env:GITHUB_STEP_SUMMARY
"- rootfs_action: $($summary['rootfs_action'])" >> $env:GITHUB_STEP_SUMMARY
"- rootfs_reuse_reason: $($summary['rootfs_reuse_reason'])" >> $env:GITHUB_STEP_SUMMARY
"- marker_promoted: $($summary['marker_promoted'])" >> $env:GITHUB_STEP_SUMMARY
"- log: $($summary['log_path'])" >> $env:GITHUB_STEP_SUMMARY
"" >> $env:GITHUB_STEP_SUMMARY
if (Test-Path $phaseFile) {
"<details><summary>Phase timeline</summary>" >> $env:GITHUB_STEP_SUMMARY
"" >> $env:GITHUB_STEP_SUMMARY
"```text" >> $env:GITHUB_STEP_SUMMARY
Get-Content $phaseFile | ForEach-Object { $_ >> $env:GITHUB_STEP_SUMMARY }
"```" >> $env:GITHUB_STEP_SUMMARY
"</details>" >> $env:GITHUB_STEP_SUMMARY
}
- name: Upload WHPX smoke logs
if: always()
uses: actions/upload-artifact@v4
with:
name: windows-whpx-smoke-logs
path: ${{ runner.temp }}/libkrun-whpx-smoke
if-no-files-found: ignore