]> git.ipfire.org Git - thirdparty/git.git/blob - .github/workflows/main.yml
diffcore-rename: avoid doing basename comparisons for irrelevant sources
[thirdparty/git.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 }}${{ steps.skip-if-redundant.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 - name: skip if the commit or tree was already tested
38 id: skip-if-redundant
39 uses: actions/github-script@v3
40 if: steps.check-ref.outputs.enabled == 'yes'
41 with:
42 github-token: ${{secrets.GITHUB_TOKEN}}
43 script: |
44 try {
45 // Figure out workflow ID, commit and tree
46 const { data: run } = await github.actions.getWorkflowRun({
47 owner: context.repo.owner,
48 repo: context.repo.repo,
49 run_id: context.runId,
50 });
51 const workflow_id = run.workflow_id;
52 const head_sha = run.head_sha;
53 const tree_id = run.head_commit.tree_id;
54
55 // See whether there is a successful run for that commit or tree
56 const { data: runs } = await github.actions.listWorkflowRuns({
57 owner: context.repo.owner,
58 repo: context.repo.repo,
59 per_page: 500,
60 status: 'success',
61 workflow_id,
62 });
63 for (const run of runs.workflow_runs) {
64 if (head_sha === run.head_sha) {
65 core.warning(`Successful run for the commit ${head_sha}: ${run.html_url}`);
66 core.setOutput('enabled', ' but skip');
67 break;
68 }
69 if (run.head_commit && tree_id === run.head_commit.tree_id) {
70 core.warning(`Successful run for the tree ${tree_id}: ${run.html_url}`);
71 core.setOutput('enabled', ' but skip');
72 break;
73 }
74 }
75 } catch (e) {
76 core.warning(e);
77 }
78
79 windows-build:
80 needs: ci-config
81 if: needs.ci-config.outputs.enabled == 'yes'
82 runs-on: windows-latest
83 steps:
84 - uses: actions/checkout@v1
85 - name: download git-sdk-64-minimal
86 shell: bash
87 run: |
88 ## Get artifact
89 urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
90 id=$(curl "$urlbase?definitions=22&statusFilter=completed&resultFilter=succeeded&\$top=1" |
91 jq -r ".value[] | .id")
92 download_url="$(curl "$urlbase/$id/artifacts" |
93 jq -r '.value[] | select(.name == "git-sdk-64-minimal").resource.downloadUrl')"
94 curl --connect-timeout 10 --retry 5 --retry-delay 0 --retry-max-time 240 \
95 -o artifacts.zip "$download_url"
96
97 ## Unzip and remove the artifact
98 unzip artifacts.zip
99 rm artifacts.zip
100 - name: build
101 shell: powershell
102 env:
103 HOME: ${{runner.workspace}}
104 MSYSTEM: MINGW64
105 NO_PERL: 1
106 run: |
107 & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
108 printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
109
110 ci/make-test-artifacts.sh artifacts
111 "@
112 - name: upload build artifacts
113 uses: actions/upload-artifact@v1
114 with:
115 name: windows-artifacts
116 path: artifacts
117 - name: upload git-sdk-64-minimal
118 uses: actions/upload-artifact@v1
119 with:
120 name: git-sdk-64-minimal
121 path: git-sdk-64-minimal
122 windows-test:
123 runs-on: windows-latest
124 needs: [windows-build]
125 strategy:
126 fail-fast: false
127 matrix:
128 nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
129 steps:
130 - uses: actions/checkout@v1
131 - name: download build artifacts
132 uses: actions/download-artifact@v1
133 with:
134 name: windows-artifacts
135 path: ${{github.workspace}}
136 - name: extract build artifacts
137 shell: bash
138 run: tar xf artifacts.tar.gz
139 - name: download git-sdk-64-minimal
140 uses: actions/download-artifact@v1
141 with:
142 name: git-sdk-64-minimal
143 path: ${{github.workspace}}/git-sdk-64-minimal/
144 - name: test
145 shell: powershell
146 run: |
147 & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
148 # Let Git ignore the SDK
149 printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
150
151 ci/run-test-slice.sh ${{matrix.nr}} 10
152 "@
153 - name: ci/print-test-failures.sh
154 if: failure()
155 shell: powershell
156 run: |
157 & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
158 - name: Upload failed tests' directories
159 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
160 uses: actions/upload-artifact@v1
161 with:
162 name: failed-tests-windows
163 path: ${{env.FAILED_TEST_ARTIFACTS}}
164 vs-build:
165 needs: ci-config
166 if: needs.ci-config.outputs.enabled == 'yes'
167 env:
168 MSYSTEM: MINGW64
169 NO_PERL: 1
170 GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@git'"
171 runs-on: windows-latest
172 steps:
173 - uses: actions/checkout@v1
174 - name: download git-sdk-64-minimal
175 shell: bash
176 run: |
177 ## Get artifact
178 urlbase=https://dev.azure.com/git-for-windows/git/_apis/build/builds
179 id=$(curl "$urlbase?definitions=22&statusFilter=completed&resultFilter=succeeded&\$top=1" |
180 jq -r ".value[] | .id")
181 download_url="$(curl "$urlbase/$id/artifacts" |
182 jq -r '.value[] | select(.name == "git-sdk-64-minimal").resource.downloadUrl')"
183 curl --connect-timeout 10 --retry 5 --retry-delay 0 --retry-max-time 240 \
184 -o artifacts.zip "$download_url"
185
186 ## Unzip and remove the artifact
187 unzip artifacts.zip
188 rm artifacts.zip
189 - name: download vcpkg artifacts
190 shell: powershell
191 run: |
192 $urlbase = "https://dev.azure.com/git/git/_apis/build/builds"
193 $id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=9&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id
194 $downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[0].resource.downloadUrl
195 (New-Object Net.WebClient).DownloadFile($downloadUrl, "compat.zip")
196 Expand-Archive compat.zip -DestinationPath . -Force
197 Remove-Item compat.zip
198 - name: add msbuild to PATH
199 uses: microsoft/setup-msbuild@v1
200 - name: copy dlls to root
201 shell: powershell
202 run: |
203 & compat\vcbuild\vcpkg_copy_dlls.bat release
204 if (!$?) { exit(1) }
205 - name: generate Visual Studio solution
206 shell: bash
207 run: |
208 cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows \
209 -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
210 - name: MSBuild
211 run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
212 - name: bundle artifact tar
213 shell: powershell
214 env:
215 MSVC: 1
216 VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
217 run: |
218 & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
219 mkdir -p artifacts &&
220 eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
221 "@
222 - name: upload build artifacts
223 uses: actions/upload-artifact@v1
224 with:
225 name: vs-artifacts
226 path: artifacts
227 vs-test:
228 runs-on: windows-latest
229 needs: [vs-build, windows-build]
230 strategy:
231 fail-fast: false
232 matrix:
233 nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
234 steps:
235 - uses: actions/checkout@v1
236 - name: download git-sdk-64-minimal
237 uses: actions/download-artifact@v1
238 with:
239 name: git-sdk-64-minimal
240 path: ${{github.workspace}}/git-sdk-64-minimal/
241 - name: download build artifacts
242 uses: actions/download-artifact@v1
243 with:
244 name: vs-artifacts
245 path: ${{github.workspace}}
246 - name: extract build artifacts
247 shell: bash
248 run: tar xf artifacts.tar.gz
249 - name: test
250 shell: powershell
251 env:
252 MSYSTEM: MINGW64
253 NO_SVN_TESTS: 1
254 GIT_TEST_SKIP_REBASE_P: 1
255 run: |
256 & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
257 # Let Git ignore the SDK and the test-cache
258 printf '%s\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude
259
260 ci/run-test-slice.sh ${{matrix.nr}} 10
261 "@
262 - name: ci/print-test-failures.sh
263 if: failure()
264 shell: powershell
265 run: |
266 & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
267 - name: Upload failed tests' directories
268 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
269 uses: actions/upload-artifact@v1
270 with:
271 name: failed-tests-windows
272 path: ${{env.FAILED_TEST_ARTIFACTS}}
273 regular:
274 needs: ci-config
275 if: needs.ci-config.outputs.enabled == 'yes'
276 strategy:
277 fail-fast: false
278 matrix:
279 vector:
280 - jobname: linux-clang
281 cc: clang
282 pool: ubuntu-latest
283 - jobname: linux-gcc
284 cc: gcc
285 pool: ubuntu-latest
286 - jobname: osx-clang
287 cc: clang
288 pool: macos-latest
289 - jobname: osx-gcc
290 cc: gcc
291 pool: macos-latest
292 - jobname: linux-gcc-default
293 cc: gcc
294 pool: ubuntu-latest
295 env:
296 CC: ${{matrix.vector.cc}}
297 jobname: ${{matrix.vector.jobname}}
298 runs-on: ${{matrix.vector.pool}}
299 steps:
300 - uses: actions/checkout@v1
301 - run: ci/install-dependencies.sh
302 - run: ci/run-build-and-tests.sh
303 - run: ci/print-test-failures.sh
304 if: failure()
305 - name: Upload failed tests' directories
306 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
307 uses: actions/upload-artifact@v1
308 with:
309 name: failed-tests-${{matrix.vector.jobname}}
310 path: ${{env.FAILED_TEST_ARTIFACTS}}
311 dockerized:
312 needs: ci-config
313 if: needs.ci-config.outputs.enabled == 'yes'
314 strategy:
315 fail-fast: false
316 matrix:
317 vector:
318 - jobname: linux-musl
319 image: alpine
320 - jobname: Linux32
321 image: daald/ubuntu32:xenial
322 env:
323 jobname: ${{matrix.vector.jobname}}
324 runs-on: ubuntu-latest
325 container: ${{matrix.vector.image}}
326 steps:
327 - uses: actions/checkout@v1
328 - run: ci/install-docker-dependencies.sh
329 - run: ci/run-build-and-tests.sh
330 - run: ci/print-test-failures.sh
331 if: failure()
332 - name: Upload failed tests' directories
333 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
334 uses: actions/upload-artifact@v1
335 with:
336 name: failed-tests-${{matrix.vector.jobname}}
337 path: ${{env.FAILED_TEST_ARTIFACTS}}
338 static-analysis:
339 needs: ci-config
340 if: needs.ci-config.outputs.enabled == 'yes'
341 env:
342 jobname: StaticAnalysis
343 runs-on: ubuntu-18.04
344 steps:
345 - uses: actions/checkout@v1
346 - run: ci/install-dependencies.sh
347 - run: ci/run-static-analysis.sh
348 documentation:
349 needs: ci-config
350 if: needs.ci-config.outputs.enabled == 'yes'
351 env:
352 jobname: Documentation
353 runs-on: ubuntu-latest
354 steps:
355 - uses: actions/checkout@v1
356 - run: ci/install-dependencies.sh
357 - run: ci/test-documentation.sh