]> git.ipfire.org Git - thirdparty/git.git/blame - .github/workflows/main.yml
ci: expose distro name in dockerized GitHub jobs
[thirdparty/git.git] / .github / workflows / main.yml
CommitLineData
df7375d7 1name: CI
889cacb6
ĐTCD
2
3on: [push, pull_request]
4
5env:
6 DEVELOPER: 1
7
99fe06cb
JS
8# If more than one workflow run is triggered for the very same commit hash
9# (which happens when multiple branches pointing to the same commit), only
10# the first one is allowed to run, the second will be kept in the "queued"
11# state. This allows a successful completion of the first run to be reused
12# in the second run via the `skip-if-redundant` logic in the `config` job.
13#
14# The only caveat is that if a workflow run is triggered for the same commit
15# hash that another run is already being held, that latter run will be
16# canceled. For more details about the `concurrency` attribute, see:
17# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
18concurrency:
19 group: ${{ github.sha }}
20
889cacb6 21jobs:
e76eec35 22 ci-config:
df7375d7 23 name: config
21c82dcd 24 if: vars.CI_BRANCHES == '' || contains(vars.CI_BRANCHES, github.ref_name)
055747cd
AM
25 runs-on: ubuntu-latest
26 outputs:
7d78d5fc 27 enabled: ${{ steps.check-ref.outputs.enabled }}${{ steps.skip-if-redundant.outputs.enabled }}
eb5b03a9 28 skip_concurrent: ${{ steps.check-ref.outputs.skip_concurrent }}
055747cd
AM
29 steps:
30 - name: try to clone ci-config branch
055747cd
AM
31 run: |
32 git -c protocol.version=2 clone \
33 --no-tags \
34 --single-branch \
35 -b ci-config \
36 --depth 1 \
37 --no-checkout \
38 --filter=blob:none \
39 https://github.com/${{ github.repository }} \
40 config-repo &&
b01aff8c 41 cd config-repo &&
2fcf7a8c 42 git checkout HEAD -- ci/config || : ignore
055747cd
AM
43 - id: check-ref
44 name: check whether CI is enabled for ref
45 run: |
46 enabled=yes
edf80d23 47 if test -x config-repo/ci/config/allow-ref
055747cd 48 then
edf80d23
JK
49 echo "::warning::ci/config/allow-ref is deprecated; use CI_BRANCHES instead"
50 if ! config-repo/ci/config/allow-ref '${{ github.ref }}'
51 then
52 enabled=no
53 fi
055747cd 54 fi
eb5b03a9
TB
55
56 skip_concurrent=yes
57 if test -x config-repo/ci/config/skip-concurrent &&
58 ! config-repo/ci/config/skip-concurrent '${{ github.ref }}'
59 then
60 skip_concurrent=no
61 fi
f115c96e 62 echo "enabled=$enabled" >>$GITHUB_OUTPUT
763f20fb 63 echo "skip_concurrent=$skip_concurrent" >>$GITHUB_OUTPUT
7d78d5fc
JS
64 - name: skip if the commit or tree was already tested
65 id: skip-if-redundant
c4ddbe04 66 uses: actions/github-script@v7
7d78d5fc
JS
67 if: steps.check-ref.outputs.enabled == 'yes'
68 with:
69 github-token: ${{secrets.GITHUB_TOKEN}}
70 script: |
d6d66837
JS
71 try {
72 // Figure out workflow ID, commit and tree
63357b79 73 const { data: run } = await github.rest.actions.getWorkflowRun({
d6d66837
JS
74 owner: context.repo.owner,
75 repo: context.repo.repo,
76 run_id: context.runId,
77 });
78 const workflow_id = run.workflow_id;
79 const head_sha = run.head_sha;
80 const tree_id = run.head_commit.tree_id;
7d78d5fc 81
d6d66837 82 // See whether there is a successful run for that commit or tree
63357b79 83 const { data: runs } = await github.rest.actions.listWorkflowRuns({
d6d66837
JS
84 owner: context.repo.owner,
85 repo: context.repo.repo,
86 per_page: 500,
87 status: 'success',
88 workflow_id,
89 });
90 for (const run of runs.workflow_runs) {
91 if (head_sha === run.head_sha) {
92 core.warning(`Successful run for the commit ${head_sha}: ${run.html_url}`);
93 core.setOutput('enabled', ' but skip');
94 break;
95 }
96 if (run.head_commit && tree_id === run.head_commit.tree_id) {
97 core.warning(`Successful run for the tree ${tree_id}: ${run.html_url}`);
98 core.setOutput('enabled', ' but skip');
99 break;
100 }
7d78d5fc 101 }
d6d66837
JS
102 } catch (e) {
103 core.warning(e);
7d78d5fc 104 }
e76eec35 105
889cacb6 106 windows-build:
df7375d7 107 name: win build
e76eec35
JK
108 needs: ci-config
109 if: needs.ci-config.outputs.enabled == 'yes'
889cacb6 110 runs-on: windows-latest
eb5b03a9
TB
111 concurrency:
112 group: windows-build-${{ github.ref }}
113 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
889cacb6 114 steps:
e94dec0c 115 - uses: actions/checkout@v4
0eb6c189 116 - uses: git-for-windows/setup-git-for-windows-sdk@v1
889cacb6 117 - name: build
0eb6c189 118 shell: bash
889cacb6
ĐTCD
119 env:
120 HOME: ${{runner.workspace}}
889cacb6 121 NO_PERL: 1
7491ef61 122 run: . /etc/profile && ci/make-test-artifacts.sh artifacts
d681d0dc
JS
123 - name: zip up tracked files
124 run: git archive -o artifacts/tracked.tar.gz HEAD
125 - name: upload tracked files and build artifacts
820a3400 126 uses: actions/upload-artifact@v4
889cacb6
ĐTCD
127 with:
128 name: windows-artifacts
129 path: artifacts
130 windows-test:
df7375d7 131 name: win test
889cacb6 132 runs-on: windows-latest
eb5b03a9 133 needs: [ci-config, windows-build]
889cacb6 134 strategy:
2b0e14f6 135 fail-fast: false
889cacb6
ĐTCD
136 matrix:
137 nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
eb5b03a9
TB
138 concurrency:
139 group: windows-test-${{ matrix.nr }}-${{ github.ref }}
140 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
889cacb6 141 steps:
d681d0dc 142 - name: download tracked files and build artifacts
820a3400 143 uses: actions/download-artifact@v4
889cacb6
ĐTCD
144 with:
145 name: windows-artifacts
146 path: ${{github.workspace}}
d681d0dc 147 - name: extract tracked files and build artifacts
889cacb6 148 shell: bash
d681d0dc 149 run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz
0eb6c189 150 - uses: git-for-windows/setup-git-for-windows-sdk@v1
889cacb6 151 - name: test
0eb6c189 152 shell: bash
7491ef61 153 run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
5aeb1457
JS
154 - name: print test failures
155 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
156 shell: bash
157 run: ci/print-test-failures.sh
f72f328b
JS
158 - name: Upload failed tests' directories
159 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
820a3400 160 uses: actions/upload-artifact@v4
f72f328b 161 with:
e1aaf309 162 name: failed-tests-windows-${{ matrix.nr }}
f72f328b 163 path: ${{env.FAILED_TEST_ARTIFACTS}}
889cacb6 164 vs-build:
df7375d7 165 name: win+VS build
e76eec35 166 needs: ci-config
a0da6dee 167 if: github.event.repository.owner.login == 'git-for-windows' && needs.ci-config.outputs.enabled == 'yes'
889cacb6 168 env:
889cacb6
ĐTCD
169 NO_PERL: 1
170 GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@git'"
171 runs-on: windows-latest
eb5b03a9
TB
172 concurrency:
173 group: vs-build-${{ github.ref }}
174 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
889cacb6 175 steps:
e94dec0c 176 - uses: actions/checkout@v4
0eb6c189 177 - uses: git-for-windows/setup-git-for-windows-sdk@v1
958a5f5d 178 - name: initialize vcpkg
e94dec0c 179 uses: actions/checkout@v4
958a5f5d
DA
180 with:
181 repository: 'microsoft/vcpkg'
182 path: 'compat/vcbuild/vcpkg'
889cacb6
ĐTCD
183 - name: download vcpkg artifacts
184 shell: powershell
185 run: |
186 $urlbase = "https://dev.azure.com/git/git/_apis/build/builds"
187 $id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=9&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id
188 $downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[0].resource.downloadUrl
189 (New-Object Net.WebClient).DownloadFile($downloadUrl, "compat.zip")
190 Expand-Archive compat.zip -DestinationPath . -Force
191 Remove-Item compat.zip
192 - name: add msbuild to PATH
17c13069 193 uses: microsoft/setup-msbuild@v1
4c2c38e8 194 - name: copy dlls to root
abb2b389
JS
195 shell: cmd
196 run: compat\vcbuild\vcpkg_copy_dlls.bat release
4c2c38e8
SS
197 - name: generate Visual Studio solution
198 shell: bash
199 run: |
200 cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows \
9ab0b661 201 -DNO_GETTEXT=YesPlease -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
889cacb6
ĐTCD
202 - name: MSBuild
203 run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
204 - name: bundle artifact tar
0eb6c189 205 shell: bash
889cacb6
ĐTCD
206 env:
207 MSVC: 1
208 VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
209 run: |
0eb6c189 210 mkdir -p artifacts &&
9ab0b661 211 eval "$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts NO_GETTEXT=YesPlease 2>&1 | grep ^tar)"
d681d0dc
JS
212 - name: zip up tracked files
213 run: git archive -o artifacts/tracked.tar.gz HEAD
214 - name: upload tracked files and build artifacts
820a3400 215 uses: actions/upload-artifact@v4
889cacb6
ĐTCD
216 with:
217 name: vs-artifacts
218 path: artifacts
219 vs-test:
df7375d7 220 name: win+VS test
889cacb6 221 runs-on: windows-latest
eb5b03a9 222 needs: [ci-config, vs-build]
889cacb6 223 strategy:
2b0e14f6 224 fail-fast: false
889cacb6
ĐTCD
225 matrix:
226 nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
eb5b03a9
TB
227 concurrency:
228 group: vs-test-${{ matrix.nr }}-${{ github.ref }}
229 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
889cacb6 230 steps:
0eb6c189 231 - uses: git-for-windows/setup-git-for-windows-sdk@v1
d681d0dc 232 - name: download tracked files and build artifacts
820a3400 233 uses: actions/download-artifact@v4
889cacb6
ĐTCD
234 with:
235 name: vs-artifacts
236 path: ${{github.workspace}}
d681d0dc 237 - name: extract tracked files and build artifacts
889cacb6 238 shell: bash
d681d0dc 239 run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz
4c2c38e8 240 - name: test
0eb6c189 241 shell: bash
889cacb6 242 env:
889cacb6 243 NO_SVN_TESTS: 1
7491ef61 244 run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
5aeb1457
JS
245 - name: print test failures
246 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
247 shell: bash
248 run: ci/print-test-failures.sh
4c2c38e8
SS
249 - name: Upload failed tests' directories
250 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
820a3400 251 uses: actions/upload-artifact@v4
4c2c38e8 252 with:
e1aaf309 253 name: failed-tests-windows-vs-${{ matrix.nr }}
4c2c38e8 254 path: ${{env.FAILED_TEST_ARTIFACTS}}
889cacb6 255 regular:
df7375d7 256 name: ${{matrix.vector.jobname}} (${{matrix.vector.pool}})
e76eec35
JK
257 needs: ci-config
258 if: needs.ci-config.outputs.enabled == 'yes'
eb5b03a9
TB
259 concurrency:
260 group: ${{ matrix.vector.jobname }}-${{ matrix.vector.pool }}-${{ github.ref }}
261 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
889cacb6 262 strategy:
2b0e14f6 263 fail-fast: false
889cacb6
ĐTCD
264 matrix:
265 vector:
25715419
ÆAB
266 - jobname: linux-sha256
267 cc: clang
25715419 268 pool: ubuntu-latest
c0350cb9
PS
269 - jobname: linux-reftable
270 cc: clang
271 pool: ubuntu-latest
889cacb6
ĐTCD
272 - jobname: linux-gcc
273 cc: gcc
707d2f2f 274 cc_package: gcc-8
0178420b 275 pool: ubuntu-20.04
25715419
ÆAB
276 - jobname: linux-TEST-vars
277 cc: gcc
25715419 278 cc_package: gcc-8
0178420b 279 pool: ubuntu-20.04
889cacb6
ĐTCD
280 - jobname: osx-clang
281 cc: clang
682a868f 282 pool: macos-13
c0350cb9
PS
283 - jobname: osx-reftable
284 cc: clang
285 pool: macos-13
889cacb6
ĐTCD
286 - jobname: osx-gcc
287 cc: gcc
682a868f
JS
288 cc_package: gcc-13
289 pool: macos-13
6c280b41 290 - jobname: linux-gcc-default
889cacb6
ĐTCD
291 cc: gcc
292 pool: ubuntu-latest
956d2e46
ÆAB
293 - jobname: linux-leaks
294 cc: gcc
295 pool: ubuntu-latest
c0350cb9
PS
296 - jobname: linux-reftable-leaks
297 cc: gcc
298 pool: ubuntu-latest
ec691526 299 - jobname: linux-asan-ubsan
85a62951 300 cc: clang
1c0962c0 301 pool: ubuntu-latest
889cacb6
ĐTCD
302 env:
303 CC: ${{matrix.vector.cc}}
707d2f2f 304 CC_PACKAGE: ${{matrix.vector.cc_package}}
889cacb6 305 jobname: ${{matrix.vector.jobname}}
2d65e5b6 306 distro: ${{matrix.vector.pool}}
889cacb6
ĐTCD
307 runs-on: ${{matrix.vector.pool}}
308 steps:
e94dec0c 309 - uses: actions/checkout@v4
889cacb6
ĐTCD
310 - run: ci/install-dependencies.sh
311 - run: ci/run-build-and-tests.sh
7b341645 312 - name: print test failures
5aeb1457 313 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
7b341645 314 run: ci/print-test-failures.sh
f72f328b
JS
315 - name: Upload failed tests' directories
316 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
820a3400 317 uses: actions/upload-artifact@v4
f72f328b
JS
318 with:
319 name: failed-tests-${{matrix.vector.jobname}}
320 path: ${{env.FAILED_TEST_ARTIFACTS}}
c4a9cf1d
JS
321 fuzz-smoke-test:
322 name: fuzz smoke test
323 needs: ci-config
324 if: needs.ci-config.outputs.enabled == 'yes'
325 env:
326 CC: clang
327 runs-on: ubuntu-latest
328 steps:
dcce2bda 329 - uses: actions/checkout@v4
c4a9cf1d
JS
330 - run: ci/install-dependencies.sh
331 - run: ci/run-build-and-minimal-fuzzers.sh
889cacb6 332 dockerized:
df7375d7 333 name: ${{matrix.vector.jobname}} (${{matrix.vector.image}})
e76eec35
JK
334 needs: ci-config
335 if: needs.ci-config.outputs.enabled == 'yes'
eb5b03a9
TB
336 concurrency:
337 group: dockerized-${{ matrix.vector.jobname }}-${{ matrix.vector.image }}-${{ github.ref }}
338 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
889cacb6 339 strategy:
2b0e14f6 340 fail-fast: false
889cacb6
ĐTCD
341 matrix:
342 vector:
343 - jobname: linux-musl
344 image: alpine
ab2b3aad 345 distro: alpine-latest
c08bb260 346 - jobname: linux32
889cacb6 347 image: daald/ubuntu32:xenial
ab2b3aad 348 distro: ubuntu32-16.04
cebead1e
CMAB
349 - jobname: pedantic
350 image: fedora
ab2b3aad 351 distro: fedora-latest
889cacb6
ĐTCD
352 env:
353 jobname: ${{matrix.vector.jobname}}
ab2b3aad 354 distro: ${{matrix.vector.distro}}
889cacb6
ĐTCD
355 runs-on: ubuntu-latest
356 container: ${{matrix.vector.image}}
357 steps:
e94dec0c 358 - uses: actions/checkout@v4
6cf4d908 359 if: matrix.vector.jobname != 'linux32'
20e0ff88 360 - uses: actions/checkout@v1 # cannot be upgraded because Node.js Actions aren't supported in this container
6cf4d908 361 if: matrix.vector.jobname == 'linux32'
889cacb6
ĐTCD
362 - run: ci/install-docker-dependencies.sh
363 - run: ci/run-build-and-tests.sh
7b341645 364 - name: print test failures
5aeb1457 365 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
7b341645 366 run: ci/print-test-failures.sh
f72f328b 367 - name: Upload failed tests' directories
1f398446 368 if: failure() && env.FAILED_TEST_ARTIFACTS != '' && matrix.vector.jobname != 'linux32'
820a3400 369 uses: actions/upload-artifact@v4
1f398446
JS
370 with:
371 name: failed-tests-${{matrix.vector.jobname}}
372 path: ${{env.FAILED_TEST_ARTIFACTS}}
373 - name: Upload failed tests' directories
374 if: failure() && env.FAILED_TEST_ARTIFACTS != '' && matrix.vector.jobname == 'linux32'
20e0ff88 375 uses: actions/upload-artifact@v1 # cannot be upgraded because Node.js Actions aren't supported in this container
f72f328b
JS
376 with:
377 name: failed-tests-${{matrix.vector.jobname}}
378 path: ${{env.FAILED_TEST_ARTIFACTS}}
889cacb6 379 static-analysis:
e76eec35
JK
380 needs: ci-config
381 if: needs.ci-config.outputs.enabled == 'yes'
889cacb6
ĐTCD
382 env:
383 jobname: StaticAnalysis
ef465848 384 runs-on: ubuntu-22.04
eb5b03a9
TB
385 concurrency:
386 group: static-analysis-${{ github.ref }}
387 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
889cacb6 388 steps:
e94dec0c 389 - uses: actions/checkout@v4
889cacb6
ĐTCD
390 - run: ci/install-dependencies.sh
391 - run: ci/run-static-analysis.sh
0e7696c6 392 - run: ci/check-directional-formatting.bash
e6105966
JS
393 sparse:
394 needs: ci-config
395 if: needs.ci-config.outputs.enabled == 'yes'
396 env:
397 jobname: sparse
398 runs-on: ubuntu-20.04
eb5b03a9
TB
399 concurrency:
400 group: sparse-${{ github.ref }}
401 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
e6105966
JS
402 steps:
403 - name: Download a current `sparse` package
404 # Ubuntu's `sparse` version is too old for us
405 uses: git-for-windows/get-azure-pipelines-artifact@v0
406 with:
407 repository: git/git
408 definitionId: 10
409 artifact: sparse-20.04
410 - name: Install the current `sparse` package
411 run: sudo dpkg -i sparse-20.04/sparse_*.deb
e94dec0c 412 - uses: actions/checkout@v4
27f45ccf
JK
413 - name: Install other dependencies
414 run: ci/install-dependencies.sh
e6105966 415 - run: make sparse
889cacb6 416 documentation:
df7375d7 417 name: documentation
e76eec35
JK
418 needs: ci-config
419 if: needs.ci-config.outputs.enabled == 'yes'
eb5b03a9
TB
420 concurrency:
421 group: documentation-${{ github.ref }}
422 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
889cacb6
ĐTCD
423 env:
424 jobname: Documentation
425 runs-on: ubuntu-latest
426 steps:
e94dec0c 427 - uses: actions/checkout@v4
889cacb6
ĐTCD
428 - run: ci/install-dependencies.sh
429 - run: ci/test-documentation.sh