forked from dokan-dev/dokany
-
Notifications
You must be signed in to change notification settings - Fork 3
/
appveyor.yml
365 lines (331 loc) · 16.6 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
-
environment:
CoverityProjectToken:
secure: 1mtSEr5uFQI5rdwItPXrR1y4fV+SUWt55lUSQB5o3x8=
CoverityNotificationEmail:
secure: 0SPcT7MZEWl9NsqpKSOoLBCfqx/KVDAte5+xvbRremg=
AccessTokenDokanDoc:
secure: 1JpCwgUIFUddCeF/nvSRQxb309YpVnHvN/Sd5DLRQCQPTSv/YZVv7CspelmBGSua
global:
DOKAN_CI_CACHE: C:\dokan_ci_cache
CYG_CACHE: '%DOKAN_CI_CACHE%\cygwin'
MSYS2_CACHE: '%DOKAN_CI_CACHE%\msys2'
CHOCO_CACHE: '%DOKAN_CI_CACHE%\choco'
WLK_INST_CACHE: '%DOKAN_CI_CACHE%\wlk_inst'
DOKAN_MAIN_BUILD_JOB_NAME: "Image: Visual Studio 2015; Configuration: All"
version: 1.0.3-{build}
configuration:
- All
- Coverity
- FsTest
image:
- Visual Studio 2015
- Visual Studio 2017
# If you suspect some changes on the AppVeyor-side breaking things,
# uncomment below. https://www.appveyor.com/updates/
# - Previous Visual Studio 2015
# - Previous Visual Studio 2017
matrix:
exclude:
- configuration: All
image: Visual Studio 2017
- configuration: Coverity
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: |
if ($env:CONFIGURATION -eq "FsTest" -or $env:CONFIGURATION -eq "All") {
.\cert\dokan-import.ps1
}
- ps: |
if ($env:CONFIGURATION -eq "FsTest") {
& verifier /standard /driver dokan1.sys
Write-Host "Before reboot"
Start-Sleep -s 2
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: |
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 {& 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 "All") {
Exec-External {& choco install "--cache-location=${env:CHOCO_CACHE}" doxygen.portable}
}
- 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.exe" "${env:DOKAN_CI_CACHE}\setup-x86.exe" 7
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.exe" C:/cygwin $env:CYG_CACHE
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}'"})
# 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 ($i = 0; $i -lt 3; $i++) {
bash "pacman -Syuu --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"
}
before_build:
# Remove VS build warning http://help.appveyor.com/discussions/problems/4569-the-target-_convertpdbfiles-listed-in-a-beforetargets-attribute-at-c-does-not-exist-in-the-project-and-will-be-ignored
- del "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets"
build_script:
- ps: |
Write-Host Start building...
$buildCmd = "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"
- ps: |
if ($env:CONFIGURATION -eq "Coverity") {
if (!"$env:CoverityProjectToken") {
Add-AppveyorMessage -Message "Not running Coverity due to missing credential. Is this a fork or a pull request?" -Category Information
return;
}
$buildArgs = @(
"/m",
"/l:C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll",
"/p:Configuration=Win10 Debug",
"/p:Platform=x64")
Exec-External {& "cov-build.exe" `
--dir cov-int `
--encoding=UTF-8 `
$buildCmd $buildArgs}
Exec-External {nuget install -ExcludeVersion PublishCoverity}
Write-Host "Compressing Coverity results..."
Exec-External {& PublishCoverity\tools\PublishCoverity.exe compress `
--nologo `
-i "$env:APPVEYOR_BUILD_FOLDER\cov-int" `
-o "$env:APPVEYOR_BUILD_FOLDER\coverity.zip" `
--overwrite}
Write-Host "Uploading Coverity results..."
Exec-External {& PublishCoverity\tools\PublishCoverity.exe publish `
--nologo `
-t "$env:CoverityProjectToken" `
-e "$env:CoverityNotificationEmail" `
-r "dokan-dev/dokany" `
-z "coverity.zip" `
-d "Appveyor build." `
--codeVersion "$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 = $env:Path + ";C:\Program Files (x86)\WiX Toolset v3.10;C:\Program Files (x86)\Windows Kits\8.1\bin\x64\"
$env:CERTISSUER="DokanCA"
$env:ADDITIONALCERT="$pwd\cert\DokanCA.cer"
$env:SIGNTOOL="C:\Program Files (x86)\Windows Kits\8.1\bin\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}")
& $buildCmd $buildArgs
& .\SetAssemblyVersion\bin\Release\SetAssemblyVersion ..\CHANGELOG.md version.xml ..\
cd ${env:APPVEYOR_BUILD_FOLDER}
Exec-External {& .\build.bat}
.\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=Release",
"/p:Platform=${Platform}")
Exec-External {& $buildCmd $buildArgs}
Write-Host Upload Artifact...
Push-AppveyorArtifact "${env:APPVEYOR_BUILD_FOLDER}\dokan_wix\Bootstrapper\bin\Release\DokanSetup.exe" -FileName ("DokanSetup-" + $installer_version + ".exe")
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:DokanLibrary1 = [System.Environment]::GetEnvironmentVariable("DokanLibrary1", "Machine")
$mirrors = @("${env:DokanLibrary1}\sample\mirror\mirror.exe", "${env:DokanLibrary1}\x86\sample\mirror\mirror.exe")
cd .\samples
.\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]
$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 "All") {
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
}
}