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