forked from dokan-dev/dokany
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appveyor.yml
397 lines (358 loc) · 18.7 KB
/
appveyor.yml
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
-
environment:
AccessTokenDokanDoc:
secure: Omu2AD4ooK5Owx+v4XS3VPuWc0xJyZXGZlgv4ipJqmt0wY2LN7bzev8y3OLHsARU
SonarQubeToken:
secure: /gni/fn6VjMyw7qdAvkHuB2h3NoRFdXNqlQSAvqiYsuODhOPDkGGX/yNeOP5F2On
global:
DOKAN_CI_CACHE: C:\dokan_ci_cache
DOXYGEN_INST_DIR: '%DOKAN_CI_CACHE%\doxygen'
CYG_CACHE: '%DOKAN_CI_CACHE%\cygwin'
MSYS2_CACHE: '%DOKAN_CI_CACHE%\msys2-cache'
# CHOCO_CACHE: '%DOKAN_CI_CACHE%\choco'
WLK_INST_CACHE: '%DOKAN_CI_CACHE%\wlk_inst'
DOKAN_MAIN_BUILD_JOB_NAME: "Image: Visual Studio 2019; Configuration: All"
skip_tags: true
version: 2.0.3-{build}
configuration:
- All
- SonarQube
- FsTest
- Documentation
image:
- Visual Studio 2019
- Visual Studio 2017
- Visual Studio 2015
# If you suspect some changes on the AppVeyor-side breaking things,
# uncomment below. https://www.appveyor.com/updates/
# - Previous Visual Studio 2019
# - Previous Visual Studio 2015
# - Previous Visual Studio 2017
matrix:
exclude:
- configuration: All
image: Visual Studio 2015
- configuration: SonarQube
image: Visual Studio 2015
- configuration: Documentation
image: Visual Studio 2015
- configuration: All
image: Visual Studio 2017
- configuration: SonarQube
image: Visual Studio 2017
- configuration: Documentation
image: Visual Studio 2017
max_jobs: 1
cache:
- '%DOKAN_CI_CACHE% -> appveyor.yml'
# To debug build issues, add your own fork to AppVeyor and uncomment below.
# Connection details will be printed to the console output.
# $blockRdp makes the build block until a file is deleted from the desktop.
# init:
# - ps: Invoke-Expression (Invoke-WebRequest 'https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')
# on_finish:
# - ps: $blockRdp = $true; Invoke-Expression (Invoke-WebRequest 'https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')
install:
- ps: |
New-Item -ItemType Directory -Force -Path ${env:DOKAN_CI_CACHE} | Out-Null
- ps: |
if ($env:CONFIGURATION -eq "FsTest" -or $env:CONFIGURATION -eq "All") {
.\cert\dokan-import.ps1
}
- ps: |
if ($env:CONFIGURATION -eq "FsTest") {
& verifier /standard /driver dokan2.sys
Write-Host "Before reboot"
Start-Sleep -s 30 # Wait appveyor to be ready https://github.com/appveyor/ci/issues/3650
Restart-Computer
Start-Sleep -s 240 # will reboot before this is finished and proceed with next build step
Write-Host "Did not reboot for some reason, trying Restart-Computer -Force"
Start-Sleep -s 2
Restart-Computer -Force
Start-Sleep -s 240
Write-Host "Still has not rebooted"
throw ("Tried rebooting two times, failed")
}
- ps: |
. .\scripts\build_helper.ps1
- ps: |
if ($env:CONFIGURATION -eq "FsTest") {
Exec-External {& net user dokan_ifstest D0kan_1fstest /ADD }
}
- ps: |
if ($env:CONFIGURATION -eq "FsTest") {
Exec-External {& powershell .\scripts\install_wlk_ifstest.ps1 }
}
- ps: |
if ($env:CONFIGURATION -eq "Documentation") {
# choco doxygen.portable has ftp download issue for now
# Exec-External {& choco install "--cache-location=${env:CHOCO_CACHE}" doxygen.portable}
$env:PATH = "$env:DOXYGEN_INST_DIR;$env:PATH"
if (Test-Path $env:DOXYGEN_INST_DIR) {
Write-Host "Doxygen in cache, skipping."
return
}
New-Item -Force -Type Directory $env:DOXYGEN_INST_DIR | Out-Null
cd $env:DOXYGEN_INST_DIR
$doxygen_zip = "$env:TEMP\doxygen.zip"
# Version has to be < 1.8.12 because doxyboot theme is incompatible with later versions
# https://github.com/Velron/doxygen-bootstrapped/issues/20
# https://github.com/Velron/doxygen-bootstrapped/issues/27
Write-Host "Downloading Doxygen..."
Invoke-WebRequest https://netcologne.dl.sourceforge.net/project/doxygen/rel-1.8.11/doxygen-1.8.11.windows.x64.bin.zip -OutFile $doxygen_zip -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox
if ($(Get-FileHash -Algorithm SHA256 $doxygen_zip).Hash -ne "6CE7C259975FB3DC449313913DE71B89665D15C49CF674DB6952F304BB3DFAAA") {
throw "Hash mismatch while downloading Doxygen"
}
Exec-External {& 7z x -y "$doxygen_zip"}
cd $env:APPVEYOR_BUILD_FOLDER
}
- git submodule update --init --recursive
- ps: |
if ($env:CONFIGURATION -eq "All") {
function downloadIfOlderThanDays($url, $path, $days) {
if ( !(Test-Path $path -NewerThan (Get-Date).AddDays(-$days)) ) {
Write-Host "$path does not exist or is older than $days days, downloading from $url"
Invoke-WebRequest $url -OutFile $path
}
}
downloadIfOlderThanDays "https://cygwin.com/setup-x86_64.exe" "${env:DOKAN_CI_CACHE}\setup-x86_64.exe" 7
function updateCygwin($cygwinexe, $installFolder, $cacheFolder) {
Write-Host "Update Cygwin: $cygwinexe"
Exec-External {& cmd /c $cygwinexe -gqnNdO -R $installFolder -s http://mirrors.kernel.org/sourceware/cygwin/ -l $cacheFolder -P cmake -P make -P gcc-core -P gcc-g++ -P pkg-config}
Write-Host "Update Cygwin: $cygwinexe " -NoNewLine
Write-Host "[ OK ]" -ForegroundColor Green
}
updateCygwin "${env:DOKAN_CI_CACHE}\setup-x86_64.exe" C:/cygwin64 $env:CYG_CACHE
}
- ps: |
if ($env:CONFIGURATION -eq "All") {
function bash($bash_command) {
Write-Host "MSYS2-Bash: $bash_command"
Exec-External {& C:\msys64\usr\bin\bash.exe --login -c $bash_command }
Write-Host "MSYS2-Bash $bash_command " -NoNewLine
Write-Host "[ OK ]" -ForegroundColor Green
}
New-Item -Force -Type Directory $env:MSYS2_CACHE
$unix_msys2_cache = (Exec-External {& C:\msys64\usr\bin\bash.exe --login -c "cygpath '${env:MSYS2_CACHE}'"})
# Update keyring to fix possible package signatures we faced in the past.
bash "pacman -Sy --noconfirm --cache `"$unix_msys2_cache`" msys2-keyring"
# We run the upgrade three times, because MSYS2 cannot upgrade itself without restarting
# TODO: detect if restart is necessary and only run as many times as needed.
# Maybe two times is enough in all cases, but better be safe than sorry and run it three times.
# See https://github.com/msys2/msys2/wiki/MSYS2-installation#iii-updating-packages
# For the `--ask 20` option, see
# <https://github.com/Alexpux/MSYS2-packages/issues/1141>.
#
# Otherwise the message
#
# :: msys2-runtime and catgets are in conflict. Remove catgets? [y/N]
#
# is displayed when trying to update followed by an exit rather
# than selecting yes.
for ($i = 0; $i -lt 3; $i++) {
bash "pacman -Syuu --ask 20 --noconfirm --cache `"$unix_msys2_cache`""
}
# install MinGW toolchain
bash "pacman --sync --needed --noconfirm --cache `"$unix_msys2_cache`" mingw-w64-{x86_64,i686}-toolchain mingw-w64-{x86_64,i686}-cmake make"
}
build_script:
- ps: |
Write-Host Start building...
$buildCmd = $(cmd /c where msbuild)
- ps: |
if ($env:CONFIGURATION -eq "SonarQube" -and "$env:APPVEYOR_REPO_BRANCH" -eq "master") {
if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {
Add-AppveyorMessage -Message "Not running SonarQube on pull request." -Category Information
return;
}
Add-Type -assembly system.io.compression.filesystem
New-Item -Path "sonar-scanner" -ItemType "directory"
cd sonar-scanner
Invoke-WebRequest https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip -OutFile .\build-wrapper-win-x86.zip
Exec-External { & 7z e .\build-wrapper-win-x86.zip }
Invoke-WebRequest https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/5.13.0.66756/sonar-scanner-msbuild-5.13.0.66756-net46.zip -OutFile .\sonar-scanner-msbuild.zip
Exec-External { & 7z x .\sonar-scanner-msbuild.zip }
$env:Path = "$((Get-Location).Path);" + $env:Path
$env:JAVA_HOME = "C:\Program Files\Java\jdk15"
cd ..
.\scripts\sonar-build.ps1 dokany $env:SonarQubeToken dokan-dev https://sonarcloud.io $env:APPVEYOR_BUILD_VERSION
}
- ps: |
# Available in all configurations
$xmlversion = [xml](Get-Content "${env:APPVEYOR_BUILD_FOLDER}\dokan_wix\version.xml")
$current_build_version = $xmlversion.Include.define | Where { $_.StartsWith("BuildVersion=") }
$mm_version = $current_build_version.Split("=")[1] -replace '"','';
$mm_version = $mm_version.Substring(0, $mm_version.Length - $env:APPVEYOR_BUILD_NUMBER.Length - 1);
$mm_version += $env:APPVEYOR_BUILD_NUMBER;
(Get-Content "${env:APPVEYOR_BUILD_FOLDER}\CHANGELOG.md") -replace '[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,4}', ($env:APPVEYOR_BUILD_VERSION.Split("-")[0] + '.' + $mm_version) | out-file "${env:APPVEYOR_BUILD_FOLDER}\CHANGELOG.md"
$installer_version = $env:APPVEYOR_BUILD_VERSION.Split("-")[0] + '.' + $mm_version;
- ps: |
if ($env:CONFIGURATION -eq "All") {
$env:Path += ";C:\Program Files (x86)\WiX Toolset v3.11;C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\"
$env:CERTISSUER="DokanCA"
$env:ADDITIONALCERT="$pwd\cert\DokanCA.cer"
$env:SIGNTOOL="C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\signtool.exe"
cd dokan_wix
$Platform = "Any CPU"
$buildArgs = @(
"SetAssemblyVersion.sln",
"/m",
"/l:C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll",
"/p:Configuration=Release",
"/p:Platform=${Platform}")
Exec-External { & $buildCmd $buildArgs }
& .\SetAssemblyVersion\bin\Release\SetAssemblyVersion ..\CHANGELOG.md version.xml ..\
# Flip the config to Debug for a Debug build and installer
$BuildConfig="Release"
cd ${env:APPVEYOR_BUILD_FOLDER}
Exec-External {& .\scripts\build.ps1 -Configurations $BuildConfig }
.\cert\dokan-sign.ps1
cd dokan_wix
(gc version.xml) -replace 'BuildCygwin="false"', 'BuildCygwin="true"' | sc version.xml
(gc version.xml) -replace 'Compressed="no"', 'Compressed="yes"' | sc version.xml
$Platform = "Mixed Platforms"
$buildArgs = @(
"Dokan_WiX.sln",
"/m",
"/l:C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll",
"/p:Configuration=${BuildConfig}",
"/p:Platform=${Platform}")
Exec-External {& $buildCmd $buildArgs}
Write-Host Build archive ...
Exec-External { 7z a -tzip dokan.zip ..\Win32 ..\x64 ..\ARM ..\ARM64 }
Write-Host Build archive done !
Write-Host Upload Artifact...
Push-AppveyorArtifact "${env:APPVEYOR_BUILD_FOLDER}\dokan_wix\Bootstrapper\bin\${BuildConfig}\DokanSetup.exe" -FileName ("DokanSetup-" + $installer_version + ".exe")
Push-AppveyorArtifact "${env:APPVEYOR_BUILD_FOLDER}\dokan_wix\dokan.zip" -FileName ("dokan-" + $installer_version + ".zip")
Write-Host Artifact uploaded!
}
- ps: |
if ($env:CONFIGURATION -eq "FsTest") {
Write-Host "Getting main build job id via API..."
$api_build_info_url = "${env:APPVEYOR_URL}/api/projects/${env:APPVEYOR_ACCOUNT_NAME}/${env:APPVEYOR_PROJECT_SLUG}/build/${env:APPVEYOR_BUILD_VERSION}"
$headers = @{
"Content-Type" = "application/json"
}
$build_info = Invoke-RestMethod -Method Get -Uri $api_build_info_url -Headers $headers -UserAgent "Dokany CI-Script ${env:APPVEYOR_JOB_ID}"
$main_build_job_id = ($build_info.Build.jobs | Where-Object {$_.name -eq $env:DOKAN_MAIN_BUILD_JOB_NAME}).jobId
$installer_url = "${env:APPVEYOR_URL}/api/buildjobs/${main_build_job_id}/artifacts/DokanSetup-${installer_version}.exe"
Write-Host "Downloading installer artifact from main build job ${main_build_job_id}..."
Invoke-WebRequest $installer_url -OutFile DokanSetup.exe
Write-Host "Installing Dokan..."
$install_process = Start-Process -PassThru -Wait -FilePath .\DokanSetup.exe -ArgumentList @("/quiet", "/norestart", "/log", "dokan_install.log")
if ($install_process.ExitCode -ne 0) {
Write-Error "Dokan-Installation failed. Log below this line:"
Get-Content dokan_install*.log # wildcard for getting both MSI and bundle log
throw "Dokan-Installation failed. Log above this line"
}
}
- ps: |
Write-Host Build finished!
test_script:
- ps: |
if ($env:CONFIGURATION -eq "FsTest") {
Write-Host Running tests...
$env:DokanLibrary2 = [System.Environment]::GetEnvironmentVariable("DokanLibrary2", "Machine")
$memfs = @("${env:DokanLibrary2}\sample\memfs\memfs.exe", "${env:DokanLibrary2}\x86\sample\memfs\memfs.exe")
$mirrors = @("${env:DokanLibrary2}\sample\mirror\mirror.exe", "${env:DokanLibrary2}\x86\sample\mirror\mirror.exe")
cd .\samples
.\memfs_test.ps1 -Memfs $memfs
.\mirror_test.ps1 -Mirrors $mirrors
}
- ps: |
if ($env:CONFIGURATION -eq "FsTest") {
Write-Host Test finished!
}
after_test:
- ps: |
# This function has already been defined above, but in case of a reboot caused by a BSOD, we cannot
# rely on it being defined!
function Exec-External {
param(
[Parameter(Position=0,Mandatory=1)][scriptblock] $command
)
& $command
if ($LASTEXITCODE -ne 0) {
throw ("Command returned non-zero error-code ${LASTEXITCODE}: $command")
}
}
- ps: |
if ($env:CONFIGURATION -eq "FsTest") {
Exec-External {& verifier /query}
}
- ps: |
# checking for BSOD
$bugchecks = (Get-EventLog -LogName system | Where-Object {$_.eventID -eq '1001' -and $_.Source -eq 'BugCheck'} | Select-Object -Property *)
if ($bugchecks) {
Write-Host "It seems like we rebooted due to a bugcheck (BSOD)."
Format-List -InputObject $bugchecks | Out-String | Out-Host
# events are sorted descendingly by time, so $bugchecks[0] is the latest BSOD
$memory_dmp = $bugchecks[0].ReplacementStrings[1]
Write-Host Calling KD to get more information...
# somehow the env-var-changes by the installer are sometimes lost after the BSOD. Hardcode the path!
$driver_and_pdb_path = Resolve-Path 'C:\Program Files\Dokan\Dokan Library-*\driver\'
& "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\kd.exe" -lines -z $memory_dmp -y "SRV*;${driver_and_pdb_path};http://msdl.microsoft.com/download/symbols" -c "!analyze -v; kp; dv /t /i /V; q"
$memdumpArchive = "memory_dmp_$(& git rev-parse --short HEAD)_${env:APPVEYOR_BUILD_VERSION}.7z"
Write-Host "Compressing $memory_dmp"
Exec-External { &7z a -t7z $memdumpArchive $memory_dmp }
Push-AppveyorArtifact $memdumpArchive
Write-Host "MEMORY.DMP uploaded as build artifact $memdumpArchive"
Add-AppveyorMessage `
-Category Error `
-Message "BSOD encountered during $env:CONFIGURATION. Link to MEMORY.DMP in the description" `
-Details ("MEMORY.DMP is available here: " + `
"https://ci.appveyor.com/api/buildjobs/$([System.Web.HttpUtility]::UrlEncode($env:APPVEYOR_JOB_ID))/artifacts/$([System.Web.HttpUtility]::UrlEncode($memdumpArchive))")
throw "Build failed due to BSOD during $env:CONFIGURATION"
}
on_success:
- ps: |
# AppVeyor does not provide us with the SHA1 before the push
# Thus we have no baseline for pushes and can only run this for PRs
if ($env:CONFIGURATION -eq "All" -and $env:APPVEYOR_PULL_REQUEST_NUMBER) {
$parents = (Exec-External {& git rev-list --parents -n1 HEAD}).Split()
$head = $parents[0]
$mergeBranchHead = $parents[1]
$prBranchHead = $parents[2]
# Python 3 is needed by git clang-format
$env:PATH ="C:\Python38;$env:PATH"
$diffFile = "clang_format_$(& git rev-parse --short $prBranchHead)_into_$(& git rev-parse --short $mergeBranchHead).diff"
Exec-External {& git clang-format --quiet --style=file --diff $mergeBranchHead} |
Select-String -NotMatch "^no modified files to format$" > $diffFile
if ((Get-Item $diffFile).length -gt 0) {
Write-Host "Ran git clang-format on PR, found changes, uploading as artifact"
Add-AppveyorMessage `
-Category Warning `
-Message "Please check your indentation." `
-Details ("You may want to run ``git clang-format --style file`` on each of your commits.`n" + `
"A diff of the suggested changes is available here:`n" + `
"https://ci.appveyor.com/api/buildjobs/$([System.Web.HttpUtility]::UrlEncode($env:APPVEYOR_JOB_ID))/artifacts/$([System.Web.HttpUtility]::UrlEncode($diffFile))")
Push-AppveyorArtifact $diffFile
}
else {
Write-Host "Ran git clang-format on PR, no changes necessary"
Add-AppveyorMessage `
-Category Information `
-Message "Your indentation is fine. clang-format did not suggest any changes."
}
}
- ps: |
if ($env:CONFIGURATION -eq "Documentation") {
if (!$env:AccessTokenDokanDoc -or "$env:APPVEYOR_PULL_REQUEST_TITLE" -or "$env:APPVEYOR_REPO_BRANCH" -ne "master") {
return;
}
cd $env:APPVEYOR_BUILD_FOLDER\documentations
Exec-External {& git config --global user.email "[email protected]"}
Exec-External {& git config --global user.name "appveyor"}
Exec-External {& git clone -b gh-pages --single-branch https://$($env:AccessTokenDokanDoc)@github.com/dokan-dev/dokany-doc.git doc}
Exec-External {& doxygen Doxyfile}
cd doc
if ($(git status --porcelain)) {
Write-Host "Update documentation..." -ForegroundColor Green
Exec-External {& git add -A}
Exec-External {& git commit -m "Latest documentation on successful appveyor build $env:APPVEYOR_BUILD_VERSION auto-pushed to gh-pages"}
Exec-External {& git push -fq origin gh-pages}
Write-Host "Documentation updated!" -ForegroundColor Green
} else {
Write-Host "No documentation changes detected." -ForegroundColor Green
}
}