]> git.ipfire.org Git - thirdparty/git.git/blame - .github/workflows/main.yml
Merge branch 'pw/ci-print-failure-name-fix'
[thirdparty/git.git] / .github / workflows / main.yml
CommitLineData
df7375d7 1name: CI
889cacb6
ĐTCD
2
3on: [push, pull_request]
4
5env:
6 DEVELOPER: 1
7
8jobs:
e76eec35 9 ci-config:
df7375d7 10 name: config
055747cd
AM
11 runs-on: ubuntu-latest
12 outputs:
7d78d5fc 13 enabled: ${{ steps.check-ref.outputs.enabled }}${{ steps.skip-if-redundant.outputs.enabled }}
055747cd
AM
14 steps:
15 - name: try to clone ci-config branch
055747cd
AM
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 &&
b01aff8c 26 cd config-repo &&
2fcf7a8c 27 git checkout HEAD -- ci/config || : ignore
055747cd
AM
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
f115c96e 37 echo "enabled=$enabled" >>$GITHUB_OUTPUT
7d78d5fc
JS
38 - name: skip if the commit or tree was already tested
39 id: skip-if-redundant
63357b79 40 uses: actions/github-script@v6
7d78d5fc
JS
41 if: steps.check-ref.outputs.enabled == 'yes'
42 with:
43 github-token: ${{secrets.GITHUB_TOKEN}}
44 script: |
d6d66837
JS
45 try {
46 // Figure out workflow ID, commit and tree
63357b79 47 const { data: run } = await github.rest.actions.getWorkflowRun({
d6d66837
JS
48 owner: context.repo.owner,
49 repo: context.repo.repo,
50 run_id: context.runId,
51 });
52 const workflow_id = run.workflow_id;
53 const head_sha = run.head_sha;
54 const tree_id = run.head_commit.tree_id;
7d78d5fc 55
d6d66837 56 // See whether there is a successful run for that commit or tree
63357b79 57 const { data: runs } = await github.rest.actions.listWorkflowRuns({
d6d66837
JS
58 owner: context.repo.owner,
59 repo: context.repo.repo,
60 per_page: 500,
61 status: 'success',
62 workflow_id,
63 });
64 for (const run of runs.workflow_runs) {
65 if (head_sha === run.head_sha) {
66 core.warning(`Successful run for the commit ${head_sha}: ${run.html_url}`);
67 core.setOutput('enabled', ' but skip');
68 break;
69 }
70 if (run.head_commit && tree_id === run.head_commit.tree_id) {
71 core.warning(`Successful run for the tree ${tree_id}: ${run.html_url}`);
72 core.setOutput('enabled', ' but skip');
73 break;
74 }
7d78d5fc 75 }
d6d66837
JS
76 } catch (e) {
77 core.warning(e);
7d78d5fc 78 }
e76eec35 79
889cacb6 80 windows-build:
df7375d7 81 name: win build
e76eec35
JK
82 needs: ci-config
83 if: needs.ci-config.outputs.enabled == 'yes'
889cacb6
ĐTCD
84 runs-on: windows-latest
85 steps:
6cf4d908 86 - uses: actions/checkout@v3
0eb6c189 87 - uses: git-for-windows/setup-git-for-windows-sdk@v1
889cacb6 88 - name: build
0eb6c189 89 shell: bash
889cacb6
ĐTCD
90 env:
91 HOME: ${{runner.workspace}}
889cacb6 92 NO_PERL: 1
7491ef61 93 run: . /etc/profile && ci/make-test-artifacts.sh artifacts
d681d0dc
JS
94 - name: zip up tracked files
95 run: git archive -o artifacts/tracked.tar.gz HEAD
96 - name: upload tracked files and build artifacts
1f398446 97 uses: actions/upload-artifact@v3
889cacb6
ĐTCD
98 with:
99 name: windows-artifacts
100 path: artifacts
101 windows-test:
df7375d7 102 name: win test
889cacb6
ĐTCD
103 runs-on: windows-latest
104 needs: [windows-build]
105 strategy:
2b0e14f6 106 fail-fast: false
889cacb6
ĐTCD
107 matrix:
108 nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
109 steps:
d681d0dc 110 - name: download tracked files and build artifacts
1f398446 111 uses: actions/download-artifact@v3
889cacb6
ĐTCD
112 with:
113 name: windows-artifacts
114 path: ${{github.workspace}}
d681d0dc 115 - name: extract tracked files and build artifacts
889cacb6 116 shell: bash
d681d0dc 117 run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz
0eb6c189 118 - uses: git-for-windows/setup-git-for-windows-sdk@v1
889cacb6 119 - name: test
0eb6c189 120 shell: bash
7491ef61 121 run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
5aeb1457
JS
122 - name: print test failures
123 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
124 shell: bash
125 run: ci/print-test-failures.sh
f72f328b
JS
126 - name: Upload failed tests' directories
127 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
1f398446 128 uses: actions/upload-artifact@v3
f72f328b
JS
129 with:
130 name: failed-tests-windows
131 path: ${{env.FAILED_TEST_ARTIFACTS}}
889cacb6 132 vs-build:
df7375d7 133 name: win+VS build
e76eec35 134 needs: ci-config
a0da6dee 135 if: github.event.repository.owner.login == 'git-for-windows' && needs.ci-config.outputs.enabled == 'yes'
889cacb6 136 env:
889cacb6
ĐTCD
137 NO_PERL: 1
138 GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@git'"
139 runs-on: windows-latest
140 steps:
6cf4d908 141 - uses: actions/checkout@v3
0eb6c189 142 - uses: git-for-windows/setup-git-for-windows-sdk@v1
958a5f5d 143 - name: initialize vcpkg
6cf4d908 144 uses: actions/checkout@v3
958a5f5d
DA
145 with:
146 repository: 'microsoft/vcpkg'
147 path: 'compat/vcbuild/vcpkg'
889cacb6
ĐTCD
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
17c13069 158 uses: microsoft/setup-msbuild@v1
4c2c38e8 159 - name: copy dlls to root
abb2b389
JS
160 shell: cmd
161 run: compat\vcbuild\vcpkg_copy_dlls.bat release
4c2c38e8
SS
162 - name: generate Visual Studio solution
163 shell: bash
164 run: |
165 cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows \
9ab0b661 166 -DNO_GETTEXT=YesPlease -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
889cacb6
ĐTCD
167 - name: MSBuild
168 run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
169 - name: bundle artifact tar
0eb6c189 170 shell: bash
889cacb6
ĐTCD
171 env:
172 MSVC: 1
173 VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
174 run: |
0eb6c189 175 mkdir -p artifacts &&
9ab0b661 176 eval "$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts NO_GETTEXT=YesPlease 2>&1 | grep ^tar)"
d681d0dc
JS
177 - name: zip up tracked files
178 run: git archive -o artifacts/tracked.tar.gz HEAD
179 - name: upload tracked files and build artifacts
1f398446 180 uses: actions/upload-artifact@v3
889cacb6
ĐTCD
181 with:
182 name: vs-artifacts
183 path: artifacts
184 vs-test:
df7375d7 185 name: win+VS test
889cacb6 186 runs-on: windows-latest
0eb6c189 187 needs: vs-build
889cacb6 188 strategy:
2b0e14f6 189 fail-fast: false
889cacb6
ĐTCD
190 matrix:
191 nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
192 steps:
0eb6c189 193 - uses: git-for-windows/setup-git-for-windows-sdk@v1
d681d0dc 194 - name: download tracked files and build artifacts
1f398446 195 uses: actions/download-artifact@v3
889cacb6
ĐTCD
196 with:
197 name: vs-artifacts
198 path: ${{github.workspace}}
d681d0dc 199 - name: extract tracked files and build artifacts
889cacb6 200 shell: bash
d681d0dc 201 run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz
4c2c38e8 202 - name: test
0eb6c189 203 shell: bash
889cacb6 204 env:
889cacb6 205 NO_SVN_TESTS: 1
7491ef61 206 run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
5aeb1457
JS
207 - name: print test failures
208 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
209 shell: bash
210 run: ci/print-test-failures.sh
4c2c38e8
SS
211 - name: Upload failed tests' directories
212 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
1f398446 213 uses: actions/upload-artifact@v3
4c2c38e8
SS
214 with:
215 name: failed-tests-windows
216 path: ${{env.FAILED_TEST_ARTIFACTS}}
889cacb6 217 regular:
df7375d7 218 name: ${{matrix.vector.jobname}} (${{matrix.vector.pool}})
e76eec35
JK
219 needs: ci-config
220 if: needs.ci-config.outputs.enabled == 'yes'
889cacb6 221 strategy:
2b0e14f6 222 fail-fast: false
889cacb6
ĐTCD
223 matrix:
224 vector:
225 - jobname: linux-clang
226 cc: clang
227 pool: ubuntu-latest
25715419
ÆAB
228 - jobname: linux-sha256
229 cc: clang
25715419 230 pool: ubuntu-latest
889cacb6
ĐTCD
231 - jobname: linux-gcc
232 cc: gcc
707d2f2f 233 cc_package: gcc-8
0178420b 234 pool: ubuntu-20.04
25715419
ÆAB
235 - jobname: linux-TEST-vars
236 cc: gcc
25715419 237 cc_package: gcc-8
0178420b 238 pool: ubuntu-20.04
889cacb6
ĐTCD
239 - jobname: osx-clang
240 cc: clang
d1119225 241 pool: macos-12
889cacb6
ĐTCD
242 - jobname: osx-gcc
243 cc: gcc
707d2f2f 244 cc_package: gcc-9
d1119225 245 pool: macos-12
6c280b41 246 - jobname: linux-gcc-default
889cacb6
ĐTCD
247 cc: gcc
248 pool: ubuntu-latest
956d2e46
ÆAB
249 - jobname: linux-leaks
250 cc: gcc
251 pool: ubuntu-latest
1c0962c0
JH
252 - jobname: linux-asan
253 cc: gcc
254 pool: ubuntu-latest
255 - jobname: linux-ubsan
256 cc: gcc
257 pool: ubuntu-latest
889cacb6
ĐTCD
258 env:
259 CC: ${{matrix.vector.cc}}
707d2f2f 260 CC_PACKAGE: ${{matrix.vector.cc_package}}
889cacb6 261 jobname: ${{matrix.vector.jobname}}
707d2f2f 262 runs_on_pool: ${{matrix.vector.pool}}
889cacb6
ĐTCD
263 runs-on: ${{matrix.vector.pool}}
264 steps:
6cf4d908 265 - uses: actions/checkout@v3
889cacb6
ĐTCD
266 - run: ci/install-dependencies.sh
267 - run: ci/run-build-and-tests.sh
7b341645 268 - name: print test failures
5aeb1457 269 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
7b341645 270 run: ci/print-test-failures.sh
f72f328b
JS
271 - name: Upload failed tests' directories
272 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
1f398446 273 uses: actions/upload-artifact@v3
f72f328b
JS
274 with:
275 name: failed-tests-${{matrix.vector.jobname}}
276 path: ${{env.FAILED_TEST_ARTIFACTS}}
889cacb6 277 dockerized:
df7375d7 278 name: ${{matrix.vector.jobname}} (${{matrix.vector.image}})
e76eec35
JK
279 needs: ci-config
280 if: needs.ci-config.outputs.enabled == 'yes'
889cacb6 281 strategy:
2b0e14f6 282 fail-fast: false
889cacb6
ĐTCD
283 matrix:
284 vector:
285 - jobname: linux-musl
286 image: alpine
c08bb260 287 - jobname: linux32
889cacb6 288 image: daald/ubuntu32:xenial
cebead1e
CMAB
289 - jobname: pedantic
290 image: fedora
889cacb6
ĐTCD
291 env:
292 jobname: ${{matrix.vector.jobname}}
293 runs-on: ubuntu-latest
294 container: ${{matrix.vector.image}}
295 steps:
6cf4d908
OD
296 - uses: actions/checkout@v3
297 if: matrix.vector.jobname != 'linux32'
889cacb6 298 - uses: actions/checkout@v1
6cf4d908 299 if: matrix.vector.jobname == 'linux32'
889cacb6
ĐTCD
300 - run: ci/install-docker-dependencies.sh
301 - run: ci/run-build-and-tests.sh
7b341645 302 - name: print test failures
5aeb1457 303 if: failure() && env.FAILED_TEST_ARTIFACTS != ''
7b341645 304 run: ci/print-test-failures.sh
f72f328b 305 - name: Upload failed tests' directories
1f398446
JS
306 if: failure() && env.FAILED_TEST_ARTIFACTS != '' && matrix.vector.jobname != 'linux32'
307 uses: actions/upload-artifact@v3
308 with:
309 name: failed-tests-${{matrix.vector.jobname}}
310 path: ${{env.FAILED_TEST_ARTIFACTS}}
311 - name: Upload failed tests' directories
312 if: failure() && env.FAILED_TEST_ARTIFACTS != '' && matrix.vector.jobname == 'linux32'
3cf9bb36 313 uses: actions/upload-artifact@v1
f72f328b
JS
314 with:
315 name: failed-tests-${{matrix.vector.jobname}}
316 path: ${{env.FAILED_TEST_ARTIFACTS}}
889cacb6 317 static-analysis:
e76eec35
JK
318 needs: ci-config
319 if: needs.ci-config.outputs.enabled == 'yes'
889cacb6
ĐTCD
320 env:
321 jobname: StaticAnalysis
ef465848 322 runs-on: ubuntu-22.04
889cacb6 323 steps:
6cf4d908 324 - uses: actions/checkout@v3
889cacb6
ĐTCD
325 - run: ci/install-dependencies.sh
326 - run: ci/run-static-analysis.sh
0e7696c6 327 - run: ci/check-directional-formatting.bash
e6105966
JS
328 sparse:
329 needs: ci-config
330 if: needs.ci-config.outputs.enabled == 'yes'
331 env:
332 jobname: sparse
333 runs-on: ubuntu-20.04
334 steps:
335 - name: Download a current `sparse` package
336 # Ubuntu's `sparse` version is too old for us
337 uses: git-for-windows/get-azure-pipelines-artifact@v0
338 with:
339 repository: git/git
340 definitionId: 10
341 artifact: sparse-20.04
342 - name: Install the current `sparse` package
343 run: sudo dpkg -i sparse-20.04/sparse_*.deb
6cf4d908 344 - uses: actions/checkout@v3
27f45ccf
JK
345 - name: Install other dependencies
346 run: ci/install-dependencies.sh
e6105966 347 - run: make sparse
889cacb6 348 documentation:
df7375d7 349 name: documentation
e76eec35
JK
350 needs: ci-config
351 if: needs.ci-config.outputs.enabled == 'yes'
889cacb6
ĐTCD
352 env:
353 jobname: Documentation
354 runs-on: ubuntu-latest
355 steps:
6cf4d908 356 - uses: actions/checkout@v3
889cacb6
ĐTCD
357 - run: ci/install-dependencies.sh
358 - run: ci/test-documentation.sh