ci: add a Windows job to the Azure Pipelines definition
[git] / azure-pipelines.yml
1 resources:
2 - repo: self
3   fetchDepth: 1
4
5 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
97 - job: linux_clang
98   displayName: linux-clang
99   condition: succeeded()
100   pool: Hosted Ubuntu 1604
101   steps:
102   - bash: |
103        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
104
105        sudo apt-get update &&
106        sudo apt-get -y install git gcc make libssl-dev libcurl4-openssl-dev libexpat-dev tcl tk gettext git-email zlib1g-dev apache2-bin &&
107
108        export CC=clang || exit 1
109
110        ci/install-dependencies.sh || exit 1
111        ci/run-build-and-tests.sh || {
112            ci/print-test-failures.sh
113            exit 1
114        }
115
116        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1
117     displayName: 'ci/run-build-and-tests.sh'
118     env:
119       GITFILESHAREPWD: $(gitfileshare.pwd)
120   - task: PublishTestResults@2
121     displayName: 'Publish Test Results **/TEST-*.xml'
122     inputs:
123       mergeTestResults: true
124       testRunTitle: 'linux-clang'
125       platform: Linux
126       publishRunAttachments: false
127     condition: succeededOrFailed()
128   - task: PublishBuildArtifacts@1
129     displayName: 'Publish trash directories of failed tests'
130     condition: failed()
131     inputs:
132       PathtoPublish: t/failed-test-artifacts
133       ArtifactName: failed-test-artifacts
134
135 - job: linux_gcc
136   displayName: linux-gcc
137   condition: succeeded()
138   pool: Hosted Ubuntu 1604
139   steps:
140   - bash: |
141        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
142
143        sudo add-apt-repository ppa:ubuntu-toolchain-r/test &&
144        sudo apt-get update &&
145        sudo apt-get -y install git gcc make libssl-dev libcurl4-openssl-dev libexpat-dev tcl tk gettext git-email zlib1g-dev apache2 language-pack-is git-svn gcc-8 || exit 1
146
147        ci/install-dependencies.sh || exit 1
148        ci/run-build-and-tests.sh || {
149            ci/print-test-failures.sh
150            exit 1
151        }
152
153        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1
154     displayName: 'ci/run-build-and-tests.sh'
155     env:
156       GITFILESHAREPWD: $(gitfileshare.pwd)
157   - task: PublishTestResults@2
158     displayName: 'Publish Test Results **/TEST-*.xml'
159     inputs:
160       mergeTestResults: true
161       testRunTitle: 'linux-gcc'
162       platform: Linux
163       publishRunAttachments: false
164     condition: succeededOrFailed()
165   - task: PublishBuildArtifacts@1
166     displayName: 'Publish trash directories of failed tests'
167     condition: failed()
168     inputs:
169       PathtoPublish: t/failed-test-artifacts
170       ArtifactName: failed-test-artifacts
171
172 - job: osx_clang
173   displayName: osx-clang
174   condition: succeeded()
175   pool: Hosted macOS
176   steps:
177   - bash: |
178        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
179
180        export CC=clang
181
182        ci/install-dependencies.sh || exit 1
183        ci/run-build-and-tests.sh || {
184            ci/print-test-failures.sh
185            exit 1
186        }
187
188        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || umount "$HOME/test-cache" || exit 1
189     displayName: 'ci/run-build-and-tests.sh'
190     env:
191       GITFILESHAREPWD: $(gitfileshare.pwd)
192   - task: PublishTestResults@2
193     displayName: 'Publish Test Results **/TEST-*.xml'
194     inputs:
195       mergeTestResults: true
196       testRunTitle: 'osx-clang'
197       platform: macOS
198       publishRunAttachments: false
199     condition: succeededOrFailed()
200   - task: PublishBuildArtifacts@1
201     displayName: 'Publish trash directories of failed tests'
202     condition: failed()
203     inputs:
204       PathtoPublish: t/failed-test-artifacts
205       ArtifactName: failed-test-artifacts
206
207 - job: osx_gcc
208   displayName: osx-gcc
209   condition: succeeded()
210   pool: Hosted macOS
211   steps:
212   - bash: |
213        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
214
215        ci/install-dependencies.sh || exit 1
216        ci/run-build-and-tests.sh || {
217            ci/print-test-failures.sh
218            exit 1
219        }
220
221        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || umount "$HOME/test-cache" || exit 1
222     displayName: 'ci/run-build-and-tests.sh'
223     env:
224       GITFILESHAREPWD: $(gitfileshare.pwd)
225   - task: PublishTestResults@2
226     displayName: 'Publish Test Results **/TEST-*.xml'
227     inputs:
228       mergeTestResults: true
229       testRunTitle: 'osx-gcc'
230       platform: macOS
231       publishRunAttachments: false
232     condition: succeededOrFailed()
233   - task: PublishBuildArtifacts@1
234     displayName: 'Publish trash directories of failed tests'
235     condition: failed()
236     inputs:
237       PathtoPublish: t/failed-test-artifacts
238       ArtifactName: failed-test-artifacts
239
240 - job: gettext_poison
241   displayName: GETTEXT_POISON
242   condition: succeeded()
243   pool: Hosted Ubuntu 1604
244   steps:
245   - bash: |
246        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
247
248        sudo apt-get update &&
249        sudo apt-get -y install git gcc make libssl-dev libcurl4-openssl-dev libexpat-dev tcl tk gettext git-email zlib1g-dev &&
250
251        export jobname=GETTEXT_POISON || exit 1
252
253        ci/run-build-and-tests.sh || {
254            ci/print-test-failures.sh
255            exit 1
256        }
257
258        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1
259     displayName: 'ci/run-build-and-tests.sh'
260     env:
261       GITFILESHAREPWD: $(gitfileshare.pwd)
262   - task: PublishTestResults@2
263     displayName: 'Publish Test Results **/TEST-*.xml'
264     inputs:
265       mergeTestResults: true
266       testRunTitle: 'gettext-poison'
267       platform: Linux
268       publishRunAttachments: false
269     condition: succeededOrFailed()
270   - task: PublishBuildArtifacts@1
271     displayName: 'Publish trash directories of failed tests'
272     condition: failed()
273     inputs:
274       PathtoPublish: t/failed-test-artifacts
275       ArtifactName: failed-test-artifacts
276
277 - job: linux32
278   displayName: Linux32
279   condition: succeeded()
280   pool: Hosted Ubuntu 1604
281   steps:
282   - bash: |
283        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
284
285        res=0
286        sudo AGENT_OS="$AGENT_OS" BUILD_BUILDNUMBER="$BUILD_BUILDNUMBER" BUILD_REPOSITORY_URI="$BUILD_REPOSITORY_URI" BUILD_SOURCEBRANCH="$BUILD_SOURCEBRANCH" BUILD_SOURCEVERSION="$BUILD_SOURCEVERSION" SYSTEM_PHASENAME="$SYSTEM_PHASENAME" SYSTEM_TASKDEFINITIONSURI="$SYSTEM_TASKDEFINITIONSURI" SYSTEM_TEAMPROJECT="$SYSTEM_TEAMPROJECT" CC=$CC MAKEFLAGS="$MAKEFLAGS" bash -lxc ci/run-linux32-docker.sh || res=1
287
288        sudo chmod a+r t/out/TEST-*.xml
289        test ! -d t/failed-test-artifacts || sudo chmod a+r t/failed-test-artifacts
290
291        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || res=1
292        exit $res
293     displayName: 'ci/run-linux32-docker.sh'
294     env:
295       GITFILESHAREPWD: $(gitfileshare.pwd)
296   - task: PublishTestResults@2
297     displayName: 'Publish Test Results **/TEST-*.xml'
298     inputs:
299       mergeTestResults: true
300       testRunTitle: 'linux32'
301       platform: Linux
302       publishRunAttachments: false
303     condition: succeededOrFailed()
304   - task: PublishBuildArtifacts@1
305     displayName: 'Publish trash directories of failed tests'
306     condition: failed()
307     inputs:
308       PathtoPublish: t/failed-test-artifacts
309       ArtifactName: failed-test-artifacts
310
311 - job: static_analysis
312   displayName: StaticAnalysis
313   condition: succeeded()
314   pool: Hosted Ubuntu 1604
315   steps:
316   - bash: |
317        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
318
319        sudo apt-get update &&
320        sudo apt-get install -y coccinelle &&
321
322        export jobname=StaticAnalysis &&
323
324        ci/run-static-analysis.sh || exit 1
325
326        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1
327     displayName: 'ci/run-static-analysis.sh'
328     env:
329       GITFILESHAREPWD: $(gitfileshare.pwd)
330
331 - job: documentation
332   displayName: Documentation
333   condition: succeeded()
334   pool: Hosted Ubuntu 1604
335   steps:
336   - bash: |
337        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
338
339        sudo apt-get update &&
340        sudo apt-get install -y asciidoc xmlto asciidoctor &&
341
342        export ALREADY_HAVE_ASCIIDOCTOR=yes. &&
343        export jobname=Documentation &&
344
345        ci/test-documentation.sh || exit 1
346
347        test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || exit 1
348     displayName: 'ci/test-documentation.sh'
349     env:
350       GITFILESHAREPWD: $(gitfileshare.pwd)