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