CI: don't explicitly pick "bash" shell outside of Windows, fix regression
[git/debian.git] / .github / workflows / main.yml
blob2ac20b47b74cba96be050928c2cbd808b21382a2
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     steps:
15       - name: try to clone ci-config branch
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 &&
26           cd config-repo &&
27           git checkout HEAD -- ci/config || : ignore
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
37           echo "::set-output name=enabled::$enabled"
38       - name: skip if the commit or tree was already tested
39         id: skip-if-redundant
40         uses: actions/github-script@v3
41         if: steps.check-ref.outputs.enabled == 'yes'
42         with:
43           github-token: ${{secrets.GITHUB_TOKEN}}
44           script: |
45             try {
46               // Figure out workflow ID, commit and tree
47               const { data: run } = await github.actions.getWorkflowRun({
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;
56               // See whether there is a successful run for that commit or tree
57               const { data: runs } = await github.actions.listWorkflowRuns({
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                 }
75               }
76             } catch (e) {
77               core.warning(e);
78             }
80   windows-build:
81     name: win build
82     needs: ci-config
83     if: needs.ci-config.outputs.enabled == 'yes'
84     runs-on: windows-latest
85     steps:
86     - uses: actions/checkout@v2
87     - uses: git-for-windows/setup-git-for-windows-sdk@v1
88     - name: build
89       shell: bash
90       env:
91         HOME: ${{runner.workspace}}
92         NO_PERL: 1
93       run: . /etc/profile && ci/make-test-artifacts.sh artifacts
94     - name: zip up tracked files
95       run: git archive -o artifacts/tracked.tar.gz HEAD
96     - name: upload tracked files and build artifacts
97       uses: actions/upload-artifact@v2
98       with:
99         name: windows-artifacts
100         path: artifacts
101   windows-test:
102     name: win test
103     runs-on: windows-latest
104     needs: [windows-build]
105     strategy:
106       fail-fast: false
107       matrix:
108         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
109     steps:
110     - name: download tracked files and build artifacts
111       uses: actions/download-artifact@v2
112       with:
113         name: windows-artifacts
114         path: ${{github.workspace}}
115     - name: extract tracked files and build artifacts
116       shell: bash
117       run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz
118     - uses: git-for-windows/setup-git-for-windows-sdk@v1
119     - name: test
120       shell: bash
121       run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
122     - name: print test failures
123       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
124       shell: bash
125       run: ci/print-test-failures.sh
126     - name: Upload failed tests' directories
127       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
128       uses: actions/upload-artifact@v2
129       with:
130         name: failed-tests-windows
131         path: ${{env.FAILED_TEST_ARTIFACTS}}
132   vs-build:
133     name: win+VS build
134     needs: ci-config
135     if: needs.ci-config.outputs.enabled == 'yes'
136     env:
137       NO_PERL: 1
138       GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@git'"
139     runs-on: windows-latest
140     steps:
141     - uses: actions/checkout@v2
142     - uses: git-for-windows/setup-git-for-windows-sdk@v1
143     - name: initialize vcpkg
144       uses: actions/checkout@v2
145       with:
146         repository: 'microsoft/vcpkg'
147         path: 'compat/vcbuild/vcpkg'
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
158       uses: microsoft/setup-msbuild@v1
159     - name: copy dlls to root
160       shell: cmd
161       run: compat\vcbuild\vcpkg_copy_dlls.bat release
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 \
166         -DNO_GETTEXT=YesPlease -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
167     - name: MSBuild
168       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
169     - name: bundle artifact tar
170       shell: bash
171       env:
172         MSVC: 1
173         VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
174       run: |
175         mkdir -p artifacts &&
176         eval "$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts NO_GETTEXT=YesPlease 2>&1 | grep ^tar)"
177     - name: zip up tracked files
178       run: git archive -o artifacts/tracked.tar.gz HEAD
179     - name: upload tracked files and build artifacts
180       uses: actions/upload-artifact@v2
181       with:
182         name: vs-artifacts
183         path: artifacts
184   vs-test:
185     name: win+VS test
186     runs-on: windows-latest
187     needs: vs-build
188     strategy:
189       fail-fast: false
190       matrix:
191         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
192     steps:
193     - uses: git-for-windows/setup-git-for-windows-sdk@v1
194     - name: download tracked files and build artifacts
195       uses: actions/download-artifact@v2
196       with:
197         name: vs-artifacts
198         path: ${{github.workspace}}
199     - name: extract tracked files and build artifacts
200       shell: bash
201       run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz
202     - name: test
203       shell: bash
204       env:
205         NO_SVN_TESTS: 1
206       run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10
207     - name: print test failures
208       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
209       shell: bash
210       run: ci/print-test-failures.sh
211     - name: Upload failed tests' directories
212       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
213       uses: actions/upload-artifact@v2
214       with:
215         name: failed-tests-windows
216         path: ${{env.FAILED_TEST_ARTIFACTS}}
217   regular:
218     name: ${{matrix.vector.jobname}} (${{matrix.vector.pool}})
219     needs: ci-config
220     if: needs.ci-config.outputs.enabled == 'yes'
221     strategy:
222       fail-fast: false
223       matrix:
224         vector:
225           - jobname: linux-clang
226             cc: clang
227             pool: ubuntu-latest
228           - jobname: linux-sha256
229             cc: clang
230             os: ubuntu
231             pool: ubuntu-latest
232           - jobname: linux-gcc
233             cc: gcc
234             cc_package: gcc-8
235             pool: ubuntu-latest
236           - jobname: linux-TEST-vars
237             cc: gcc
238             os: ubuntu
239             cc_package: gcc-8
240             pool: ubuntu-latest
241           - jobname: osx-clang
242             cc: clang
243             pool: macos-latest
244           - jobname: osx-gcc
245             cc: gcc
246             cc_package: gcc-9
247             pool: macos-latest
248           - jobname: linux-gcc-default
249             cc: gcc
250             pool: ubuntu-latest
251           - jobname: linux-leaks
252             cc: gcc
253             pool: ubuntu-latest
254     env:
255       CC: ${{matrix.vector.cc}}
256       CC_PACKAGE: ${{matrix.vector.cc_package}}
257       jobname: ${{matrix.vector.jobname}}
258       runs_on_pool: ${{matrix.vector.pool}}
259     runs-on: ${{matrix.vector.pool}}
260     steps:
261     - uses: actions/checkout@v2
262     - run: ci/install-dependencies.sh
263     - run: ci/run-build-and-tests.sh
264     - run: ci/print-test-failures.sh
265       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
266     - name: Upload failed tests' directories
267       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
268       uses: actions/upload-artifact@v2
269       with:
270         name: failed-tests-${{matrix.vector.jobname}}
271         path: ${{env.FAILED_TEST_ARTIFACTS}}
272   dockerized:
273     name: ${{matrix.vector.jobname}} (${{matrix.vector.image}})
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-musl
281           image: alpine
282         - jobname: linux32
283           os: ubuntu32
284           image: daald/ubuntu32:xenial
285         - jobname: pedantic
286           image: fedora
287     env:
288       jobname: ${{matrix.vector.jobname}}
289     runs-on: ubuntu-latest
290     container: ${{matrix.vector.image}}
291     steps:
292     - uses: actions/checkout@v1
293     - run: ci/install-docker-dependencies.sh
294     - run: ci/run-build-and-tests.sh
295     - run: ci/print-test-failures.sh
296       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
297     - name: Upload failed tests' directories
298       if: failure() && env.FAILED_TEST_ARTIFACTS != ''
299       uses: actions/upload-artifact@v1
300       with:
301         name: failed-tests-${{matrix.vector.jobname}}
302         path: ${{env.FAILED_TEST_ARTIFACTS}}
303   static-analysis:
304     needs: ci-config
305     if: needs.ci-config.outputs.enabled == 'yes'
306     env:
307       jobname: StaticAnalysis
308     runs-on: ubuntu-22.04
309     steps:
310     - uses: actions/checkout@v2
311     - run: ci/install-dependencies.sh
312     - run: ci/run-static-analysis.sh
313     - run: ci/check-directional-formatting.bash
314   sparse:
315     needs: ci-config
316     if: needs.ci-config.outputs.enabled == 'yes'
317     env:
318       jobname: sparse
319     runs-on: ubuntu-20.04
320     steps:
321     - name: Download a current `sparse` package
322       # Ubuntu's `sparse` version is too old for us
323       uses: git-for-windows/get-azure-pipelines-artifact@v0
324       with:
325         repository: git/git
326         definitionId: 10
327         artifact: sparse-20.04
328     - name: Install the current `sparse` package
329       run: sudo dpkg -i sparse-20.04/sparse_*.deb
330     - uses: actions/checkout@v2
331     - name: Install other dependencies
332       run: ci/install-dependencies.sh
333     - run: make sparse
334   documentation:
335     name: documentation
336     needs: ci-config
337     if: needs.ci-config.outputs.enabled == 'yes'
338     env:
339       jobname: Documentation
340     runs-on: ubuntu-latest
341     steps:
342     - uses: actions/checkout@v2
343     - run: ci/install-dependencies.sh
344     - run: ci/test-documentation.sh