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