Skip to content

Commit 117eaf6

Browse files
committed
ci: add a Windows job to the Azure Pipelines definition
Previously, we did not have robust support for Windows in our CI definition, simply because Travis cannot accommodate our needs (even after Travis added experimental Windows support very recently, it takes longer than Travis' 50 minute timeout to build Git and run the test suite on Windows). Instead, we used a hack that started a dedicated Azure Pipeline from Travis and waited for the output, often timing out (which is quite fragile, as we found out). With this commit, we finally have first-class support for Windows in our CI definition (in the Azure Pipelines one, that is). Due to our reliance on Unix shell scripting in the test suite, combined with the challenges on executing such scripts on Windows, the Windows job currently takes a whopping ~1h20m to complete. Which is *far* longer than the next-longest job takes (linux-gcc, ~35m). Now, Azure Pipelines's free tier for open source projects (such as Git) offers up to 10 concurrent jobs for free, meaning that the overall run time will be dominated by the slowest job(s). Therefore, it makes sense to start the Windows job first, to minimize the time the entire build takes from start to end (which is now pretty safely the run time of the Windows job). Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1795fb3 commit 117eaf6

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

azure-pipelines.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,97 @@ resources:
33
fetchDepth: 1
44

55
jobs:
6+
- job: windows
7+
displayName: Windows
8+
condition: succeeded()
9+
pool: Hosted
10+
timeoutInMinutes: 240
11+
steps:
12+
- powershell: |
13+
if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
14+
net use s: \\gitfileshare.file.core.windows.net\test-cache "$GITFILESHAREPWD" /user:AZURE\gitfileshare /persistent:no
15+
cmd /c mklink /d "$(Build.SourcesDirectory)\test-cache" S:\
16+
}
17+
displayName: 'Mount test-cache'
18+
env:
19+
GITFILESHAREPWD: $(gitfileshare.pwd)
20+
- powershell: |
21+
# Helper to check the error level of the latest command (exit with error when appropriate)
22+
function c() { if (!$?) { exit(1) } }
23+
24+
# Add build agent's MinGit to PATH
25+
$env:PATH = $env:AGENT_HOMEDIRECTORY +"\externals\\git\cmd;" +$env:PATH
26+
27+
# Helper to initialize (or update) a Git worktree
28+
function init ($path, $url, $set_origin) {
29+
if (Test-Path $path) {
30+
cd $path; c
31+
if (Test-Path .git) {
32+
& git init; c
33+
} else {
34+
& git status
35+
}
36+
} else {
37+
& git init $path; c
38+
cd $path; c
39+
}
40+
& git config core.autocrlf false; c
41+
& git config core.untrackedCache true; c
42+
if (($set_origin -ne 0) -and !(git config remote.origin.url)) {
43+
& git remote add origin $url; c
44+
}
45+
& git fetch --depth=1 $url master; c
46+
& git reset --hard FETCH_HEAD; c
47+
& git clean -df; c
48+
}
49+
50+
# Initialize Git for Windows' SDK
51+
$sdk_path = "$(Build.SourcesDirectory)\git-sdk-64"
52+
init "$sdk_path" "https://dev.azure.com/git-for-windows/git-sdk-64/_git/git-sdk-64" 0
53+
54+
# Let Git ignore the SDK and the test-cache
55+
"/git-sdk-64/`n/test-cache/`n" | Out-File -NoNewLine -Encoding ascii -Append "$(Build.SourcesDirectory)\.git\info\exclude"
56+
displayName: 'Initialize the Git for Windows SDK'
57+
- powershell: |
58+
& "git-sdk-64\git-cmd.exe" --command=usr\\bin\\bash.exe -lc @"
59+
export DEVELOPER=1
60+
export NO_PERL=1
61+
export NO_SVN_TESTS=1
62+
export GIT_TEST_SKIP_REBASE_P=1
63+
64+
ci/run-build-and-tests.sh || {
65+
ci/print-test-failures.sh
66+
exit 1
67+
}
68+
"@
69+
if (!$?) { exit(1) }
70+
displayName: 'Build & Test'
71+
env:
72+
HOME: $(Build.SourcesDirectory)
73+
MSYSTEM: MINGW64
74+
- powershell: |
75+
if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") {
76+
cmd /c rmdir "$(Build.SourcesDirectory)\test-cache"
77+
}
78+
displayName: 'Unmount test-cache'
79+
condition: true
80+
env:
81+
GITFILESHAREPWD: $(gitfileshare.pwd)
82+
- task: PublishTestResults@2
83+
displayName: 'Publish Test Results **/TEST-*.xml'
84+
inputs:
85+
mergeTestResults: true
86+
testRunTitle: 'windows'
87+
platform: Windows
88+
publishRunAttachments: false
89+
condition: succeededOrFailed()
90+
- task: PublishBuildArtifacts@1
91+
displayName: 'Publish trash directories of failed tests'
92+
condition: failed()
93+
inputs:
94+
PathtoPublish: t/failed-test-artifacts
95+
ArtifactName: failed-test-artifacts
96+
697
- job: linux_clang
798
displayName: linux-clang
899
condition: succeeded()

0 commit comments

Comments
 (0)