Merge branch 'pb/doc-external-diff-env'
[git] / .github / workflows / main.yml
1 name: CI/PR
2
3 on: [push, pull_request]
4
5 env:
6   DEVELOPER: 1
7
8 jobs:
9   ci-config:
10     runs-on: ubuntu-latest
11     outputs:
12       enabled: ${{ steps.check-ref.outputs.enabled }}
13     steps:
14       - name: try to clone ci-config branch
15         continue-on-error: true
16         run: |
17           git -c protocol.version=2 clone \
18             --no-tags \
19             --single-branch \
20             -b ci-config \
21             --depth 1 \
22             --no-checkout \
23             --filter=blob:none \
24             https://github.com/${{ github.repository }} \
25             config-repo &&
26             cd config-repo &&
27             git checkout HEAD -- ci/config
28       - id: check-ref
29         name: check whether CI is enabled for ref
30         run: |
31           enabled=yes
32           if test -x config-repo/ci/config/allow-ref &&
33              ! config-repo/ci/config/allow-ref '${{ github.ref }}'
34           then
35             enabled=no
36           fi
37           echo "::set-output name=enabled::$enabled"
38
39   windows-build:
40     needs: ci-config
41     if: needs.ci-config.outputs.enabled == 'yes'
42     runs-on: windows-latest
43     steps:
44     - uses: actions/checkout@v1
45     - name: download git-sdk-64-minimal
46       shell: bash
47       run: |
48         ## Get artifact
49         urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
50         id=$(curl "$urlbase?definitions=22&statusFilter=completed&resultFilter=succeeded&\$top=1" |
51           jq -r ".value[] | .id")
52         download_url="$(curl "$urlbase/$id/artifacts" |
53           jq -r '.value[] | select(.name == "git-sdk-64-minimal").resource.downloadUrl')"
54         curl --connect-timeout 10 --retry 5 --retry-delay 0 --retry-max-time 240 \
55           -o artifacts.zip "$download_url"
56
57         ## Unzip and remove the artifact
58         unzip artifacts.zip
59         rm artifacts.zip
60     - name: build
61       shell: powershell
62       env:
63         HOME: ${{runner.workspace}}
64         MSYSTEM: MINGW64
65         NO_PERL: 1
66       run: |
67         & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
68         printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
69
70           ci/make-test-artifacts.sh artifacts
71         "@
72     - name: upload build artifacts
73       uses: actions/upload-artifact@v1
74       with:
75         name: windows-artifacts
76         path: artifacts
77     - name: upload git-sdk-64-minimal
78       uses: actions/upload-artifact@v1
79       with:
80         name: git-sdk-64-minimal
81         path: git-sdk-64-minimal
82   windows-test:
83     runs-on: windows-latest
84     needs: [windows-build]
85     strategy:
86       matrix:
87         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
88     steps:
89     - uses: actions/checkout@v1
90     - name: download build artifacts
91       uses: actions/download-artifact@v1
92       with:
93         name: windows-artifacts
94         path: ${{github.workspace}}
95     - name: extract build artifacts
96       shell: bash
97       run: tar xf artifacts.tar.gz
98     - name: download git-sdk-64-minimal
99       uses: actions/download-artifact@v1
100       with:
101         name: git-sdk-64-minimal
102         path: ${{github.workspace}}/git-sdk-64-minimal/
103     - name: test
104       shell: powershell
105       run: |
106         & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
107           # Let Git ignore the SDK
108           printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
109
110           ci/run-test-slice.sh ${{matrix.nr}} 10
111         "@
112     - name: ci/print-test-failures.sh
113       if: failure()
114       shell: powershell
115       run: |
116         & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
117     - name: Upload failed tests' directories
118       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
119       uses: actions/upload-artifact@v1
120       with:
121         name: failed-tests-windows
122         path: ${{env.FAILED_TEST_ARTIFACTS}}
123   vs-build:
124     needs: ci-config
125     if: needs.ci-config.outputs.enabled == 'yes'
126     env:
127       MSYSTEM: MINGW64
128       NO_PERL: 1
129       GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@git'"
130     runs-on: windows-latest
131     steps:
132     - uses: actions/checkout@v1
133     - name: download git-sdk-64-minimal
134       shell: bash
135       run: |
136         ## Get artifact
137         urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
138         id=$(curl "$urlbase?definitions=22&statusFilter=completed&resultFilter=succeeded&\$top=1" |
139           jq -r ".value[] | .id")
140         download_url="$(curl "$urlbase/$id/artifacts" |
141           jq -r '.value[] | select(.name == "git-sdk-64-minimal").resource.downloadUrl')"
142         curl --connect-timeout 10 --retry 5 --retry-delay 0 --retry-max-time 240 \
143           -o artifacts.zip "$download_url"
144
145         ## Unzip and remove the artifact
146         unzip artifacts.zip
147         rm artifacts.zip
148     - name: download vcpkg artifacts
149       shell: powershell
150       run: |
151         $urlbase = "https://dev.azure.com/git/git/_apis/build/builds"
152         $id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=9&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id
153         $downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[0].resource.downloadUrl
154         (New-Object Net.WebClient).DownloadFile($downloadUrl, "compat.zip")
155         Expand-Archive compat.zip -DestinationPath . -Force
156         Remove-Item compat.zip
157     - name: add msbuild to PATH
158       uses: microsoft/setup-msbuild@v1.0.0
159     - name: copy dlls to root
160       shell: powershell
161       run: |
162         & compat\vcbuild\vcpkg_copy_dlls.bat release
163         if (!$?) { exit(1) }
164     - name: generate Visual Studio solution
165       shell: bash
166       run: |
167         cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows \
168         -DIconv_LIBRARY=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows/lib/libiconv.lib -DIconv_INCLUDE_DIR=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows/include \
169         -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
170     - name: MSBuild
171       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
172     - name: bundle artifact tar
173       shell: powershell
174       env:
175         MSVC: 1
176         VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
177       run: |
178         & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
179           mkdir -p artifacts &&
180           eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
181         "@
182     - name: upload build artifacts
183       uses: actions/upload-artifact@v1
184       with:
185         name: vs-artifacts
186         path: artifacts
187   vs-test:
188     runs-on: windows-latest
189     needs: [vs-build, windows-build]
190     strategy:
191       matrix:
192         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
193     steps:
194     - uses: actions/checkout@v1
195     - name: download git-sdk-64-minimal
196       uses: actions/download-artifact@v1
197       with:
198         name: git-sdk-64-minimal
199         path: ${{github.workspace}}/git-sdk-64-minimal/
200     - name: download build artifacts
201       uses: actions/download-artifact@v1
202       with:
203         name: vs-artifacts
204         path: ${{github.workspace}}
205     - name: extract build artifacts
206       shell: bash
207       run: tar xf artifacts.tar.gz
208     - name: test
209       shell: powershell
210       env:
211         MSYSTEM: MINGW64
212         NO_SVN_TESTS: 1
213         GIT_TEST_SKIP_REBASE_P: 1
214       run: |
215         & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
216           # Let Git ignore the SDK and the test-cache
217           printf '%s\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude
218
219           ci/run-test-slice.sh ${{matrix.nr}} 10
220         "@
221     - name: ci/print-test-failures.sh
222       if: failure()
223       shell: powershell
224       run: |
225         & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
226     - name: Upload failed tests' directories
227       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
228       uses: actions/upload-artifact@v1
229       with:
230         name: failed-tests-windows
231         path: ${{env.FAILED_TEST_ARTIFACTS}}
232   regular:
233     needs: ci-config
234     if: needs.ci-config.outputs.enabled == 'yes'
235     strategy:
236       matrix:
237         vector:
238           - jobname: linux-clang
239             cc: clang
240             pool: ubuntu-latest
241           - jobname: linux-gcc
242             cc: gcc
243             pool: ubuntu-latest
244           - jobname: osx-clang
245             cc: clang
246             pool: macos-latest
247           - jobname: osx-gcc
248             cc: gcc
249             pool: macos-latest
250           - jobname: GETTEXT_POISON
251             cc: gcc
252             pool: ubuntu-latest
253     env:
254       CC: ${{matrix.vector.cc}}
255       jobname: ${{matrix.vector.jobname}}
256     runs-on: ${{matrix.vector.pool}}
257     steps:
258     - uses: actions/checkout@v1
259     - run: ci/install-dependencies.sh
260     - run: ci/run-build-and-tests.sh
261     - run: ci/print-test-failures.sh
262       if: failure()
263     - name: Upload failed tests' directories
264       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
265       uses: actions/upload-artifact@v1
266       with:
267         name: failed-tests-${{matrix.vector.jobname}}
268         path: ${{env.FAILED_TEST_ARTIFACTS}}
269   dockerized:
270     needs: ci-config
271     if: needs.ci-config.outputs.enabled == 'yes'
272     strategy:
273       matrix:
274         vector:
275         - jobname: linux-musl
276           image: alpine
277         - jobname: Linux32
278           image: daald/ubuntu32:xenial
279     env:
280       jobname: ${{matrix.vector.jobname}}
281     runs-on: ubuntu-latest
282     container: ${{matrix.vector.image}}
283     steps:
284     - uses: actions/checkout@v1
285     - run: ci/install-docker-dependencies.sh
286     - run: ci/run-build-and-tests.sh
287     - run: ci/print-test-failures.sh
288       if: failure()
289     - name: Upload failed tests' directories
290       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
291       uses: actions/upload-artifact@v1
292       with:
293         name: failed-tests-${{matrix.vector.jobname}}
294         path: ${{env.FAILED_TEST_ARTIFACTS}}
295   static-analysis:
296     needs: ci-config
297     if: needs.ci-config.outputs.enabled == 'yes'
298     env:
299       jobname: StaticAnalysis
300     runs-on: ubuntu-latest
301     steps:
302     - uses: actions/checkout@v1
303     - run: ci/install-dependencies.sh
304     - run: ci/run-static-analysis.sh
305   documentation:
306     needs: ci-config
307     if: needs.ci-config.outputs.enabled == 'yes'
308     env:
309       jobname: Documentation
310     runs-on: ubuntu-latest
311     steps:
312     - uses: actions/checkout@v1
313     - run: ci/install-dependencies.sh
314     - run: ci/test-documentation.sh