ci: also build and test with MS Visual Studio on Azure Pipelines

... because we can, now. Technically, we actually build using `MSBuild`, which is however pretty close to building interactively in Visual Studio. As there is no convenient way to run Git's test suite in Visual Studio, we unpack a Portable Git to run it, using the just-added test helper to allow running test scripts in parallel. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Oct 4, 2019 at 08:09 UTC 46689317ac009ef4ae91235354b6df7bf6d11d17
2 files changed +163
Makefile
+4
@@ -3025,6 +3025,10 @@ rpm::
3025 @false
3026 .PHONY: rpm
3027
3028 +ifneq ($(INCLUDE_DLLS_IN_ARTIFACTS),)
3029 +OTHER_PROGRAMS += $(shell echo *.dll t/helper/*.dll)
3030 +endif
3031 +
3032 artifacts-tar:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) \
3033 GIT-BUILD-OPTIONS $(TEST_PROGRAMS) $(test_bindir_programs) \
3034 $(MOFILES)
azure-pipelines.yml
+159
@@ -130,6 +130,165 @@ jobs:
130 PathtoPublish: t/failed-test-artifacts
131 ArtifactName: failed-test-artifacts
132
133 +- job: vs_build
134 + displayName: Visual Studio Build
135 + condition: succeeded()
136 + pool: Hosted VS2017
137 + timeoutInMinutes: 240
138 + steps:
139 + - powershell: |
140 + if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
141 + net use s: \\gitfileshare.file.core.windows.net\test-cache "$GITFILESHAREPWD" /user:AZURE\gitfileshare /persistent:no
142 + cmd /c mklink /d "$(Build.SourcesDirectory)\test-cache" S:\
143 + }
144 + displayName: 'Mount test-cache'
145 + env:
146 + GITFILESHAREPWD: $(gitfileshare.pwd)
147 + - powershell: |
148 + $urlbase = "https://dev.azure.com/git-for-windows/git/_apis/build/builds"
149 + $id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=22&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id
150 + $downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[1].resource.downloadUrl
151 + (New-Object Net.WebClient).DownloadFile($downloadUrl,"git-sdk-64-minimal.zip")
152 + Expand-Archive git-sdk-64-minimal.zip -DestinationPath . -Force
153 + Remove-Item git-sdk-64-minimal.zip
154 +
155 + # Let Git ignore the SDK and the test-cache
156 + "/git-sdk-64-minimal/`n/test-cache/`n" | Out-File -NoNewLine -Encoding ascii -Append "$(Build.SourcesDirectory)\.git\info\exclude"
157 + displayName: 'Download git-sdk-64-minimal'
158 + - powershell: |
159 + & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
160 + make vcxproj
161 + "@
162 + if (!$?) { exit(1) }
163 + displayName: Generate Visual Studio Solution
164 + env:
165 + HOME: $(Build.SourcesDirectory)
166 + MSYSTEM: MINGW64
167 + DEVELOPER: 1
168 + NO_PERL: 1
169 + GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@git'"
170 + - powershell: |
171 + $urlbase = "https://dev.azure.com/git/git/_apis/build/builds"
172 + $id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=9&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id
173 + $downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[0].resource.downloadUrl
174 + (New-Object Net.WebClient).DownloadFile($downloadUrl, "compat.zip")
175 + Expand-Archive compat.zip -DestinationPath . -Force
176 + Remove-Item compat.zip
177 + displayName: 'Download vcpkg artifacts'
178 + - task: MSBuild@1
179 + inputs:
180 + solution: git.sln
181 + platform: x64
182 + configuration: Release
183 + maximumCpuCount: 4
184 + - powershell: |
185 + & compat\vcbuild\vcpkg_copy_dlls.bat release
186 + if (!$?) { exit(1) }
187 + & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
188 + mkdir -p artifacts &&
189 + eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts | grep ^tar)\"
190 + "@
191 + if (!$?) { exit(1) }
192 + displayName: Bundle artifact tar
193 + env:
194 + HOME: $(Build.SourcesDirectory)
195 + MSYSTEM: MINGW64
196 + DEVELOPER: 1
197 + NO_PERL: 1
198 + MSVC: 1
199 + VCPKG_ROOT: $(Build.SourcesDirectory)\compat\vcbuild\vcpkg
200 + - powershell: |
201 + $tag = (Invoke-WebRequest -UseBasicParsing "https://gitforwindows.org/latest-tag.txt").content
202 + $version = (Invoke-WebRequest -UseBasicParsing "https://gitforwindows.org/latest-version.txt").content
203 + $url = "https://github.com/git-for-windows/git/releases/download/${tag}/PortableGit-${version}-64-bit.7z.exe"
204 + (New-Object Net.WebClient).DownloadFile($url,"PortableGit.exe")
205 + & .\PortableGit.exe -y -oartifacts\PortableGit
206 + # Wait until it is unpacked
207 + while (-not @(Remove-Item -ErrorAction SilentlyContinue PortableGit.exe; $?)) { sleep 1 }
208 + displayName: Download & extract portable Git
209 + - task: PublishPipelineArtifact@0
210 + displayName: 'Publish Pipeline Artifact: MSVC test artifacts'
211 + inputs:
212 + artifactName: 'vs-artifacts'
213 + targetPath: '$(Build.SourcesDirectory)\artifacts'
214 + - powershell: |
215 + if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
216 + cmd /c rmdir "$(Build.SourcesDirectory)\test-cache"
217 + }
218 + displayName: 'Unmount test-cache'
219 + condition: true
220 + env:
221 + GITFILESHAREPWD: $(gitfileshare.pwd)
222 +
223 +- job: vs_test
224 + displayName: Visual Studio Test
225 + dependsOn: vs_build
226 + condition: succeeded()
227 + pool: Hosted
228 + timeoutInMinutes: 240
229 + strategy:
230 + parallel: 10
231 + steps:
232 + - powershell: |
233 + if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
234 + net use s: \\gitfileshare.file.core.windows.net\test-cache "$GITFILESHAREPWD" /user:AZURE\gitfileshare /persistent:no
235 + cmd /c mklink /d "$(Build.SourcesDirectory)\test-cache" S:\
236 + }
237 + displayName: 'Mount test-cache'
238 + env:
239 + GITFILESHAREPWD: $(gitfileshare.pwd)
240 + - task: DownloadPipelineArtifact@0
241 + displayName: 'Download Pipeline Artifact: VS test artifacts'
242 + inputs:
243 + artifactName: 'vs-artifacts'
244 + targetPath: '$(Build.SourcesDirectory)'
245 + - powershell: |
246 + & PortableGit\git-cmd.exe --command=usr\bin\bash.exe -lc @"
247 + test -f artifacts.tar.gz || {
248 + echo No test artifacts found\; skipping >&2
249 + exit 0
250 + }
251 + tar xf artifacts.tar.gz || exit 1
252 +
253 + # Let Git ignore the SDK and the test-cache
254 + printf '%s\n' /PortableGit/ /test-cache/ >>.git/info/exclude
255 +
256 + cd t &&
257 + PATH=\"`$PWD/helper:`$PATH\" &&
258 + test-tool.exe run-command testsuite -V -x --write-junit-xml \
259 + `$(test-tool.exe path-utils slice-tests \
260 + `$SYSTEM_JOBPOSITIONINPHASE `$SYSTEM_TOTALJOBSINPHASE t[0-9]*.sh)
261 + "@
262 + if (!$?) { exit(1) }
263 + displayName: 'Test (parallel)'
264 + env:
265 + HOME: $(Build.SourcesDirectory)
266 + MSYSTEM: MINGW64
267 + NO_SVN_TESTS: 1
268 + GIT_TEST_SKIP_REBASE_P: 1
269 + - powershell: |
270 + if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
271 + cmd /c rmdir "$(Build.SourcesDirectory)\test-cache"
272 + }
273 + displayName: 'Unmount test-cache'
274 + condition: true
275 + env:
276 + GITFILESHAREPWD: $(gitfileshare.pwd)
277 + - task: PublishTestResults@2
278 + displayName: 'Publish Test Results **/TEST-*.xml'
279 + inputs:
280 + mergeTestResults: true
281 + testRunTitle: 'vs'
282 + platform: Windows
283 + publishRunAttachments: false
284 + condition: succeededOrFailed()
285 + - task: PublishBuildArtifacts@1
286 + displayName: 'Publish trash directories of failed tests'
287 + condition: failed()
288 + inputs:
289 + PathtoPublish: t/failed-test-artifacts
290 + ArtifactName: failed-vs-test-artifacts
291 +
292 - job: linux_clang
293 displayName: linux-clang
294 condition: succeeded()