git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 13/13] ci: also build and test with MS Visual Studio on Azure Pipelines

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 4, 2019, 15:09 UTC
Message-ID
<b1ff8eff4d209d2ab44c76da6146bb7ad49d9650.1570201763.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.288.v3.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

... 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>
---
 Makefile            |   4 ++
 azure-pipelines.yml | 159 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 163 insertions(+)
diff --git a/Makefile b/Makefile
index 3716dadc08..3f6dcec54b 100644
--- a/Makefile
+++ b/Makefile
@@ -3025,6 +3025,10 @@ rpm::
 	@false
 .PHONY: rpm
 
+ifneq ($(INCLUDE_DLLS_IN_ARTIFACTS),)
+OTHER_PROGRAMS += $(shell echo *.dll t/helper/*.dll)
+endif
+
 artifacts-tar:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) \
 		GIT-BUILD-OPTIONS $(TEST_PROGRAMS) $(test_bindir_programs) \
 		$(MOFILES)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 55ee23ad0f..875e63cac1 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -130,6 +130,165 @@ jobs:
       PathtoPublish: t/failed-test-artifacts
       ArtifactName: failed-test-artifacts
 
+- job: vs_build
+  displayName: Visual Studio Build
+  condition: succeeded()
+  pool: Hosted VS2017
+  timeoutInMinutes: 240
+  steps:
+  - powershell: |
+      if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
+        net use s: \\gitfileshare.file.core.windows.net\test-cache "$GITFILESHAREPWD" /user:AZURE\gitfileshare /persistent:no
+        cmd /c mklink /d "$(Build.SourcesDirectory)\test-cache" S:\
+      }
+    displayName: 'Mount test-cache'
+    env:
+      GITFILESHAREPWD: $(gitfileshare.pwd)
+  - powershell: |
+      $urlbase = "https://dev.azure.com/git-for-windows/git/_apis/build/builds"
+      $id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=22&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id
+      $downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[1].resource.downloadUrl
+      (New-Object Net.WebClient).DownloadFile($downloadUrl,"git-sdk-64-minimal.zip")
+      Expand-Archive git-sdk-64-minimal.zip -DestinationPath . -Force
+      Remove-Item git-sdk-64-minimal.zip
+
+      # Let Git ignore the SDK and the test-cache
+      "/git-sdk-64-minimal/`n/test-cache/`n" | Out-File -NoNewLine -Encoding ascii -Append "$(Build.SourcesDirectory)\.git\info\exclude"
+    displayName: 'Download git-sdk-64-minimal'
+  - powershell: |
+      & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+        make vcxproj
+      "@
+      if (!$?) { exit(1) }
+    displayName: Generate Visual Studio Solution
+    env:
+      HOME: $(Build.SourcesDirectory)
+      MSYSTEM: MINGW64
+      DEVELOPER: 1
+      NO_PERL: 1
+      GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@git'"
+  - powershell: |
+      $urlbase = "https://dev.azure.com/git/git/_apis/build/builds"
+      $id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=9&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id
+      $downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[0].resource.downloadUrl
+      (New-Object Net.WebClient).DownloadFile($downloadUrl, "compat.zip")
+      Expand-Archive compat.zip -DestinationPath . -Force
+      Remove-Item compat.zip
+    displayName: 'Download vcpkg artifacts'
+  - task: MSBuild@1
+    inputs:
+      solution: git.sln
+      platform: x64
+      configuration: Release
+      maximumCpuCount: 4
+  - powershell: |
+      & compat\vcbuild\vcpkg_copy_dlls.bat release
+      if (!$?) { exit(1) }
+      & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+        mkdir -p artifacts &&
+        eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts | grep ^tar)\"
+      "@
+      if (!$?) { exit(1) }
+    displayName: Bundle artifact tar
+    env:
+      HOME: $(Build.SourcesDirectory)
+      MSYSTEM: MINGW64
+      DEVELOPER: 1
+      NO_PERL: 1
+      MSVC: 1
+      VCPKG_ROOT: $(Build.SourcesDirectory)\compat\vcbuild\vcpkg
+  - powershell: |
+      $tag = (Invoke-WebRequest -UseBasicParsing "https://gitforwindows.org/latest-tag.txt").content
+      $version = (Invoke-WebRequest -UseBasicParsing "https://gitforwindows.org/latest-version.txt").content
+      $url = "https://github.com/git-for-windows/git/releases/download/${tag}/PortableGit-${version}-64-bit.7z.exe"
+      (New-Object Net.WebClient).DownloadFile($url,"PortableGit.exe")
+      & .\PortableGit.exe -y -oartifacts\PortableGit
+      # Wait until it is unpacked
+      while (-not @(Remove-Item -ErrorAction SilentlyContinue PortableGit.exe; $?)) { sleep 1 }
+    displayName: Download & extract portable Git
+  - task: PublishPipelineArtifact@0
+    displayName: 'Publish Pipeline Artifact: MSVC test artifacts'
+    inputs:
+      artifactName: 'vs-artifacts'
+      targetPath: '$(Build.SourcesDirectory)\artifacts'
+  - powershell: |
+      if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
+        cmd /c rmdir "$(Build.SourcesDirectory)\test-cache"
+      }
+    displayName: 'Unmount test-cache'
+    condition: true
+    env:
+      GITFILESHAREPWD: $(gitfileshare.pwd)
+
+- job: vs_test
+  displayName: Visual Studio Test
+  dependsOn: vs_build
+  condition: succeeded()
+  pool: Hosted
+  timeoutInMinutes: 240
+  strategy:
+    parallel: 10
+  steps:
+  - powershell: |
+      if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
+        net use s: \\gitfileshare.file.core.windows.net\test-cache "$GITFILESHAREPWD" /user:AZURE\gitfileshare /persistent:no
+        cmd /c mklink /d "$(Build.SourcesDirectory)\test-cache" S:\
+      }
+    displayName: 'Mount test-cache'
+    env:
+      GITFILESHAREPWD: $(gitfileshare.pwd)
+  - task: DownloadPipelineArtifact@0
+    displayName: 'Download Pipeline Artifact: VS test artifacts'
+    inputs:
+      artifactName: 'vs-artifacts'
+      targetPath: '$(Build.SourcesDirectory)'
+  - powershell: |
+      & PortableGit\git-cmd.exe --command=usr\bin\bash.exe -lc @"
+        test -f artifacts.tar.gz || {
+          echo No test artifacts found\; skipping >&2
+          exit 0
+        }
+        tar xf artifacts.tar.gz || exit 1
+
+        # Let Git ignore the SDK and the test-cache
+        printf '%s\n' /PortableGit/ /test-cache/ >>.git/info/exclude
+
+        cd t &&
+        PATH=\"`$PWD/helper:`$PATH\" &&
+        test-tool.exe run-command testsuite -V -x --write-junit-xml \
+                `$(test-tool.exe path-utils slice-tests \
+                        `$SYSTEM_JOBPOSITIONINPHASE `$SYSTEM_TOTALJOBSINPHASE t[0-9]*.sh)
+      "@
+      if (!$?) { exit(1) }
+    displayName: 'Test (parallel)'
+    env:
+      HOME: $(Build.SourcesDirectory)
+      MSYSTEM: MINGW64
+      NO_SVN_TESTS: 1
+      GIT_TEST_SKIP_REBASE_P: 1
+  - powershell: |
+      if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
+        cmd /c rmdir "$(Build.SourcesDirectory)\test-cache"
+      }
+    displayName: 'Unmount test-cache'
+    condition: true
+    env:
+      GITFILESHAREPWD: $(gitfileshare.pwd)
+  - task: PublishTestResults@2
+    displayName: 'Publish Test Results **/TEST-*.xml'
+    inputs:
+      mergeTestResults: true
+      testRunTitle: 'vs'
+      platform: Windows
+      publishRunAttachments: false
+    condition: succeededOrFailed()
+  - task: PublishBuildArtifacts@1
+    displayName: 'Publish trash directories of failed tests'
+    condition: failed()
+    inputs:
+      PathtoPublish: t/failed-test-artifacts
+      ArtifactName: failed-vs-test-artifacts
+
 - job: linux_clang
   displayName: linux-clang
   condition: succeeded()
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Junio C Hamano
Message 59 of 72 in “ci: include a Visual Studio build & test in our Azure Pipeline”
  1. 00/13 ci: include a Visual Studio build & test in our Azure PipelineJohannes Schindelin via GitGitGadget, Sep 26, 2019
  2. 01/13 push: do not pretend to return `int` from `die_push_simple()`Johannes Schindelin via GitGitGadget, Sep 26, 2019
  3. 02/13 msvc: avoid using minus operator on unsigned typesJohannes Schindelin via GitGitGadget, Sep 26, 2019
  4. Denton LiuSep 26, 2019
  5. Johannes SchindelinSep 26, 2019
  6. Denton LiuSep 26, 2019
  7. Johannes SchindelinSep 30, 2019
  8. 03/13 winansi: use FLEX_ARRAY to avoid compiler warningJohannes Schindelin via GitGitGadget, Sep 26, 2019
  9. 04/13 compat/win32/path-utils.h: add #include guardsJohannes Schindelin via GitGitGadget, Sep 26, 2019
  10. 05/13 msvc: ignore some libraries when linkingJohannes Schindelin via GitGitGadget, Sep 26, 2019
  11. 06/13 msvc: handle DEVELOPER=1Johannes Schindelin via GitGitGadget, Sep 26, 2019
  12. 07/13 msvc: work around a bug in GetEnvironmentVariable()Johannes Schindelin via GitGitGadget, Sep 26, 2019
  13. 08/13 vcxproj: only copy `git-remote-http.exe` once it was builtJohannes Schindelin via GitGitGadget, Sep 26, 2019
  14. 10/13 test-tool run-command: learn to run (parts of) the testsuiteJohannes Schindelin via GitGitGadget, Sep 26, 2019
  15. 09/13 vcxproj: include more generated filesJohannes Schindelin via GitGitGadget, Sep 26, 2019
  16. 11/13 tests: let --immediate and --write-junit-xml play well togetherJohannes Schindelin via GitGitGadget, Sep 26, 2019
  17. Junio C HamanoSep 28, 2019
  18. Johannes SchindelinSep 30, 2019
  19. 12/13 ci: really use shallow clones on Azure PipelinesJohannes Schindelin via GitGitGadget, Sep 26, 2019
  20. 13/13 ci: also build and test with MS Visual Studio on Azure PipelinesJohannes Schindelin via GitGitGadget, Sep 26, 2019
  21. 00/13 ci: include a Visual Studio build & test in our Azure PipelineJohannes Schindelin via GitGitGadget, Sep 30, 2019
  22. 01/13 push: do not pretend to return `int` from `die_push_simple()`Johannes Schindelin via GitGitGadget, Sep 30, 2019
  23. Junio C HamanoOct 3, 2019
  24. Johannes SchindelinOct 4, 2019
  25. 03/13 winansi: use FLEX_ARRAY to avoid compiler warningJohannes Schindelin via GitGitGadget, Sep 30, 2019
  26. 02/13 msvc: avoid using minus operator on unsigned typesJohannes Schindelin via GitGitGadget, Sep 30, 2019
  27. Junio C HamanoOct 3, 2019
  28. Johannes SchindelinOct 4, 2019
  29. Johannes SixtOct 4, 2019
  30. Johannes SchindelinOct 4, 2019
  31. Junio C HamanoOct 6, 2019
  32. Johannes SixtOct 6, 2019
  33. Johannes SchindelinOct 8, 2019
  34. Johannes SixtOct 8, 2019
  35. 05/13 msvc: ignore some libraries when linkingJohannes Schindelin via GitGitGadget, Sep 30, 2019
  36. 06/13 msvc: handle DEVELOPER=1Johannes Schindelin via GitGitGadget, Sep 30, 2019
  37. 04/13 compat/win32/path-utils.h: add #include guardsJohannes Schindelin via GitGitGadget, Sep 30, 2019
  38. 07/13 msvc: work around a bug in GetEnvironmentVariable()Johannes Schindelin via GitGitGadget, Sep 30, 2019
  39. 11/13 tests: let --immediate and --write-junit-xml play well togetherJohannes Schindelin via GitGitGadget, Sep 30, 2019
  40. 13/13 ci: also build and test with MS Visual Studio on Azure PipelinesJohannes Schindelin via GitGitGadget, Sep 30, 2019
  41. 10/13 test-tool run-command: learn to run (parts of) the testsuiteJohannes Schindelin via GitGitGadget, Sep 30, 2019
  42. 08/13 vcxproj: only copy `git-remote-http.exe` once it was builtJohannes Schindelin via GitGitGadget, Sep 30, 2019
  43. 09/13 vcxproj: include more generated filesJohannes Schindelin via GitGitGadget, Sep 30, 2019
  44. 12/13 ci: really use shallow clones on Azure PipelinesJohannes Schindelin via GitGitGadget, Sep 30, 2019
  45. 00/13 ci: include a Visual Studio build & test in our Azure PipelineJohannes Schindelin via GitGitGadget, Oct 4, 2019
  46. 01/13 push: do not pretend to return `int` from `die_push_simple()`Johannes Schindelin via GitGitGadget, Oct 4, 2019
  47. 03/13 winansi: use FLEX_ARRAY to avoid compiler warningJohannes Schindelin via GitGitGadget, Oct 4, 2019
  48. Alban GruinOct 7, 2019
  49. 05/13 msvc: ignore some libraries when linkingJohannes Schindelin via GitGitGadget, Oct 4, 2019
  50. 02/13 msvc: avoid using minus operator on unsigned typesJohannes Schindelin via GitGitGadget, Oct 4, 2019
  51. 08/13 vcxproj: only copy `git-remote-http.exe` once it was builtJohannes Schindelin via GitGitGadget, Oct 4, 2019
  52. 07/13 msvc: work around a bug in GetEnvironmentVariable()Johannes Schindelin via GitGitGadget, Oct 4, 2019
  53. 09/13 vcxproj: include more generated filesJohannes Schindelin via GitGitGadget, Oct 4, 2019
  54. 04/13 compat/win32/path-utils.h: add #include guardsJohannes Schindelin via GitGitGadget, Oct 4, 2019
  55. 12/13 ci: really use shallow clones on Azure PipelinesJohannes Schindelin via GitGitGadget, Oct 4, 2019
  56. 06/13 msvc: handle DEVELOPER=1Johannes Schindelin via GitGitGadget, Oct 4, 2019
  57. 11/13 tests: let --immediate and --write-junit-xml play well togetherJohannes Schindelin via GitGitGadget, Oct 4, 2019
  58. 10/13 test-tool run-command: learn to run (parts of) the testsuiteJohannes Schindelin via GitGitGadget, Oct 4, 2019
  59. 13/13 ci: also build and test with MS Visual Studio on Azure PipelinesJohannes Schindelin via GitGitGadget, Oct 4, 2019
  60. Junio C HamanoOct 6, 2019
  61. Johannes SchindelinOct 6, 2019
  62. Johannes SchindelinOct 6, 2019
  63. Junio C HamanoOct 7, 2019
  64. Johannes SchindelinOct 7, 2019
  65. Junio C HamanoOct 8, 2019
  66. Johannes SchindelinOct 8, 2019
  67. Philip OakleyOct 9, 2019
  68. Johannes SchindelinOct 10, 2019
  69. Philip OakleyOct 10, 2019
  70. Junio C HamanoOct 7, 2019
  71. Thomas GummererOct 7, 2019
  72. Johannes SchindelinOct 11, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.