]> git.ipfire.org Git - thirdparty/git.git/blob - .github/workflows/main.yml
Merge branch 'jc/diff-exit-code-with-w-fixes'
[thirdparty/git.git] / .github / workflows / main.yml
1 name: CI
2
3 on: [push, pull_request]
4
5 env:
6 DEVELOPER: 1
7
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
18 concurrency:
19 group: ${{ github.sha }}
20
21 jobs:
22 ci-config:
23 name: config
24 runs-on: ubuntu-latest
25 outputs:
26 enabled: ${{ steps.check-ref.outputs.enabled }}${{ steps.skip-if-redundant.outputs.enabled }}
27 skip_concurrent: ${{ steps.check-ref.outputs.skip_concurrent }}
28 steps:
29 - name: try to clone ci-config branch
30 run: |
31 git -c protocol.version=2 clone \
32 --no-tags \
33 --single-branch \
34 -b ci-config \
35 --depth 1 \
36 --no-checkout \
37 --filter=blob:none \
38 https://github.com/${{ github.repository }} \
39 config-repo &&
40 cd config-repo &&
41 git checkout HEAD -- ci/config || : ignore
42 - id: check-ref
43 name: check whether CI is enabled for ref
44 run: |
45 enabled=yes
46 if test -x config-repo/ci/config/allow-ref &&
47 ! config-repo/ci/config/allow-ref '${{ github.ref }}'
48 then
49 enabled=no
50 fi
51
52 skip_concurrent=yes
53 if test -x config-repo/ci/config/skip-concurrent &&
54 ! config-repo/ci/config/skip-concurrent '${{ github.ref }}'
55 then
56 skip_concurrent=no
57 fi
58 echo "enabled=$enabled" >>$GITHUB_OUTPUT
59 echo "skip_concurrent=$skip_concurrent" >>$GITHUB_OUTPUT
60 - name: skip if the commit or tree was already tested
61 id: skip-if-redundant
62 uses: actions/github-script@v6
63 if: steps.check-ref.outputs.enabled == 'yes'
64 with:
65 github-token: ${{secrets.GITHUB_TOKEN}}
66 script: |
67 try {
68 // Figure out workflow ID, commit and tree
69 const { data: run } = await github.rest.actions.getWorkflowRun({
70 owner: context.repo.owner,
71 repo: context.repo.repo,
72 run_id: context.runId,
73 });
74 const workflow_id = run.workflow_id;
75 const head_sha = run.head_sha;
76 const tree_id = run.head_commit.tree_id;
77
78 // See whether there is a successful run for that commit or tree
79 const { data: runs } = await github.rest.actions.listWorkflowRuns({
80 owner: context.repo.owner,
81 repo: context.repo.repo,
82 per_page: 500,
83 status: 'success',
84 workflow_id,
85 });
86 for (const run of runs.workflow_runs) {
87 if (head_sha === run.head_sha) {
88 core.warning(`Successful run for the commit ${head_sha}: ${run.html_url}`);
89 core.setOutput('enabled', ' but skip');
90 break;
91 }
92 if (run.head_commit && tree_id === run.head_commit.tree_id) {
93 core.warning(`Successful run for the tree ${tree_id}: ${run.html_url}`);
94 core.setOutput('enabled', ' but skip');
95 break;
96 }
97 }
98 } catch (e) {
99 core.warning(e);
100 }
101
102 windows-build:
103 name: win build
104 needs: ci-config
105 if: needs.ci-config.outputs.enabled == 'yes'
106 runs-on: windows-latest
107 concurrency:
108 group: windows-build-${{ github.ref }}
109 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
110 steps:
111 - uses: actions/checkout@v3
112 - uses: git-for-windows/setup-git-for-windows-sdk@v1
113 - name: build
114 shell: bash
115 env:
116 HOME: ${{runner.workspace}}
117 NO_PERL: 1
118 run: . /etc/profile && ci/make-test-artifacts.sh artifacts
119 - name: zip up tracked files
120 run: git archive -o artifacts/tracked.tar.gz HEAD
121 - name: upload tracked files and build artifacts
122 uses: actions/upload-artifact@v3
123 with:
124 name: windows-artifacts
125 path: artifacts
126 windows-test:
127 name: win test
128 runs-on: windows-latest
129 needs: [ci-config, windows-build]
130 strategy:
131 fail-fast: false
132 matrix:
133 nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
134 concurrency:
135 group: windows-test-${{ matrix.nr }}-${{ github.ref }}
136 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
137 steps:
138 - name: download tracked files and build artifacts
139 uses: actions/download-artifact@v3
140 with:
141 name: windows-artifacts
142 path: ${{github.workspace}}
143 - name: extract tracked files and build artifacts
144 shell: bash
145 run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz
146 - uses: git-for-windows/setup-git-for-windows-sdk@v1
147 - name: test
148 shell: bash
149 run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
150 - name: print test failures
151 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
152 shell: bash
153 run: ci/print-test-failures.sh
154 - name: Upload failed tests' directories
155 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
156 uses: actions/upload-artifact@v3
157 with:
158 name: failed-tests-windows
159 path: ${{env.FAILED_TEST_ARTIFACTS}}
160 vs-build:
161 name: win+VS build
162 needs: ci-config
163 if: github.event.repository.owner.login == 'git-for-windows' && needs.ci-config.outputs.enabled == 'yes'
164 env:
165 NO_PERL: 1
166 GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@git'"
167 runs-on: windows-latest
168 concurrency:
169 group: vs-build-${{ github.ref }}
170 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
171 steps:
172 - uses: actions/checkout@v3
173 - uses: git-for-windows/setup-git-for-windows-sdk@v1
174 - name: initialize vcpkg
175 uses: actions/checkout@v3
176 with:
177 repository: 'microsoft/vcpkg'
178 path: 'compat/vcbuild/vcpkg'
179 - name: download vcpkg artifacts
180 shell: powershell
181 run: |
182 $urlbase = "https://dev.azure.com/git/git/_apis/build/builds"
183 $id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=9&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id
184 $downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[0].resource.downloadUrl
185 (New-Object Net.WebClient).DownloadFile($downloadUrl, "compat.zip")
186 Expand-Archive compat.zip -DestinationPath . -Force
187 Remove-Item compat.zip
188 - name: add msbuild to PATH
189 uses: microsoft/setup-msbuild@v1
190 - name: copy dlls to root
191 shell: cmd
192 run: compat\vcbuild\vcpkg_copy_dlls.bat release
193 - name: generate Visual Studio solution
194 shell: bash
195 run: |
196 cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows \
197 -DNO_GETTEXT=YesPlease -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
198 - name: MSBuild
199 run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
200 - name: bundle artifact tar
201 shell: bash
202 env:
203 MSVC: 1
204 VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
205 run: |
206 mkdir -p artifacts &&
207 eval "$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts NO_GETTEXT=YesPlease 2>&1 | grep ^tar)"
208 - name: zip up tracked files
209 run: git archive -o artifacts/tracked.tar.gz HEAD
210 - name: upload tracked files and build artifacts
211 uses: actions/upload-artifact@v3
212 with:
213 name: vs-artifacts
214 path: artifacts
215 vs-test:
216 name: win+VS test
217 runs-on: windows-latest
218 needs: [ci-config, vs-build]
219 strategy:
220 fail-fast: false
221 matrix:
222 nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
223 concurrency:
224 group: vs-test-${{ matrix.nr }}-${{ github.ref }}
225 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
226 steps:
227 - uses: git-for-windows/setup-git-for-windows-sdk@v1
228 - name: download tracked files and build artifacts
229 uses: actions/download-artifact@v3
230 with:
231 name: vs-artifacts
232 path: ${{github.workspace}}
233 - name: extract tracked files and build artifacts
234 shell: bash
235 run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz
236 - name: test
237 shell: bash
238 env:
239 NO_SVN_TESTS: 1
240 run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
241 - name: print test failures
242 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
243 shell: bash
244 run: ci/print-test-failures.sh
245 - name: Upload failed tests' directories
246 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
247 uses: actions/upload-artifact@v3
248 with:
249 name: failed-tests-windows
250 path: ${{env.FAILED_TEST_ARTIFACTS}}
251 regular:
252 name: ${{matrix.vector.jobname}} (${{matrix.vector.pool}})
253 needs: ci-config
254 if: needs.ci-config.outputs.enabled == 'yes'
255 concurrency:
256 group: ${{ matrix.vector.jobname }}-${{ matrix.vector.pool }}-${{ github.ref }}
257 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
258 strategy:
259 fail-fast: false
260 matrix:
261 vector:
262 - jobname: linux-sha256
263 cc: clang
264 pool: ubuntu-latest
265 - jobname: linux-gcc
266 cc: gcc
267 cc_package: gcc-8
268 pool: ubuntu-20.04
269 - jobname: linux-TEST-vars
270 cc: gcc
271 cc_package: gcc-8
272 pool: ubuntu-20.04
273 - jobname: osx-clang
274 cc: clang
275 pool: macos-12
276 - jobname: osx-gcc
277 cc: gcc
278 cc_package: gcc-9
279 pool: macos-12
280 - jobname: linux-gcc-default
281 cc: gcc
282 pool: ubuntu-latest
283 - jobname: linux-leaks
284 cc: gcc
285 pool: ubuntu-latest
286 - jobname: linux-asan-ubsan
287 cc: clang
288 pool: ubuntu-latest
289 env:
290 CC: ${{matrix.vector.cc}}
291 CC_PACKAGE: ${{matrix.vector.cc_package}}
292 jobname: ${{matrix.vector.jobname}}
293 runs_on_pool: ${{matrix.vector.pool}}
294 runs-on: ${{matrix.vector.pool}}
295 steps:
296 - uses: actions/checkout@v3
297 - run: ci/install-dependencies.sh
298 - run: ci/run-build-and-tests.sh
299 - name: print test failures
300 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
301 run: ci/print-test-failures.sh
302 - name: Upload failed tests' directories
303 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
304 uses: actions/upload-artifact@v3
305 with:
306 name: failed-tests-${{matrix.vector.jobname}}
307 path: ${{env.FAILED_TEST_ARTIFACTS}}
308 dockerized:
309 name: ${{matrix.vector.jobname}} (${{matrix.vector.image}})
310 needs: ci-config
311 if: needs.ci-config.outputs.enabled == 'yes'
312 concurrency:
313 group: dockerized-${{ matrix.vector.jobname }}-${{ matrix.vector.image }}-${{ github.ref }}
314 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
315 strategy:
316 fail-fast: false
317 matrix:
318 vector:
319 - jobname: linux-musl
320 image: alpine
321 - jobname: linux32
322 image: daald/ubuntu32:xenial
323 - jobname: pedantic
324 image: fedora
325 env:
326 jobname: ${{matrix.vector.jobname}}
327 runs-on: ubuntu-latest
328 container: ${{matrix.vector.image}}
329 steps:
330 - uses: actions/checkout@v3
331 if: matrix.vector.jobname != 'linux32'
332 - uses: actions/checkout@v1
333 if: matrix.vector.jobname == 'linux32'
334 - run: ci/install-docker-dependencies.sh
335 - run: ci/run-build-and-tests.sh
336 - name: print test failures
337 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
338 run: ci/print-test-failures.sh
339 - name: Upload failed tests' directories
340 if: failure() && env.FAILED_TEST_ARTIFACTS != '' && matrix.vector.jobname != 'linux32'
341 uses: actions/upload-artifact@v3
342 with:
343 name: failed-tests-${{matrix.vector.jobname}}
344 path: ${{env.FAILED_TEST_ARTIFACTS}}
345 - name: Upload failed tests' directories
346 if: failure() && env.FAILED_TEST_ARTIFACTS != '' && matrix.vector.jobname == 'linux32'
347 uses: actions/upload-artifact@v1
348 with:
349 name: failed-tests-${{matrix.vector.jobname}}
350 path: ${{env.FAILED_TEST_ARTIFACTS}}
351 static-analysis:
352 needs: ci-config
353 if: needs.ci-config.outputs.enabled == 'yes'
354 env:
355 jobname: StaticAnalysis
356 runs-on: ubuntu-22.04
357 concurrency:
358 group: static-analysis-${{ github.ref }}
359 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
360 steps:
361 - uses: actions/checkout@v3
362 - run: ci/install-dependencies.sh
363 - run: ci/run-static-analysis.sh
364 - run: ci/check-directional-formatting.bash
365 sparse:
366 needs: ci-config
367 if: needs.ci-config.outputs.enabled == 'yes'
368 env:
369 jobname: sparse
370 runs-on: ubuntu-20.04
371 concurrency:
372 group: sparse-${{ github.ref }}
373 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
374 steps:
375 - name: Download a current `sparse` package
376 # Ubuntu's `sparse` version is too old for us
377 uses: git-for-windows/get-azure-pipelines-artifact@v0
378 with:
379 repository: git/git
380 definitionId: 10
381 artifact: sparse-20.04
382 - name: Install the current `sparse` package
383 run: sudo dpkg -i sparse-20.04/sparse_*.deb
384 - uses: actions/checkout@v3
385 - name: Install other dependencies
386 run: ci/install-dependencies.sh
387 - run: make sparse
388 documentation:
389 name: documentation
390 needs: ci-config
391 if: needs.ci-config.outputs.enabled == 'yes'
392 concurrency:
393 group: documentation-${{ github.ref }}
394 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
395 env:
396 jobname: Documentation
397 runs-on: ubuntu-latest
398 steps:
399 - uses: actions/checkout@v3
400 - run: ci/install-dependencies.sh
401 - run: ci/test-documentation.sh