coverity: support building on Windows
By adding the repository variable `ENABLE_COVERITY_SCAN_ON_OS` with a value, say, `["windows-latest"]`, this GitHub workflow now runs on Windows, allowing to analyze Windows-specific issues. This allows, say, the Git for Windows fork to submit Windows builds to Coverity Scan instead of Linux builds. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Sep 25, 2023 at 11:51 UTC
d3c3ffa6249adce1f007ac43374cb540524fe767
1 file changed
+51
-6
.github/workflows/coverity.yml
+51
-6
@@ -12,31 +12,62 @@ name: Coverity
12
# email to which the Coverity reports should be sent and the latter can be
13
# obtained from the Project Settings tab of the Coverity project).
14
#
15
+# The workflow runs on `ubuntu-latest` by default. This can be overridden by setting
16
+# the repository variable `ENABLE_COVERITY_SCAN_ON_OS` to a JSON string array specifying
17
+# the operating systems, e.g. `["ubuntu-latest", "windows-latest"]`.
18
+#
19
# By default, the builds are submitted to the Coverity project `git`. To override this,
20
# set the repository variable `COVERITY_PROJECT`.
21
22
on:
23
push:
24
25
+defaults:
26
+ run:
27
+ shell: bash
28
+
29
jobs:
30
coverity:
31
if: contains(fromJSON(vars.ENABLE_COVERITY_SCAN_FOR_BRANCHES || '[""]'), github.ref_name)
24
- runs-on: ubuntu-latest
32
+ strategy:
33
+ matrix:
34
+ os: ${{ fromJSON(vars.ENABLE_COVERITY_SCAN_ON_OS || '["ubuntu-latest"]') }}
35
+ runs-on: ${{ matrix.os }}
36
env:
37
COVERITY_PROJECT: ${{ vars.COVERITY_PROJECT || 'git' }}
38
COVERITY_LANGUAGE: cxx
28
- COVERITY_PLATFORM: linux64
39
+ COVERITY_PLATFORM: overridden-below
40
steps:
41
- uses: actions/checkout@v3
42
+ - name: install minimal Git for Windows SDK
43
+ if: contains(matrix.os, 'windows')
44
+ uses: git-for-windows/setup-git-for-windows-sdk@v1
45
- run: ci/install-dependencies.sh
46
+ if: contains(matrix.os, 'ubuntu')
47
env:
33
- runs_on_pool: ubuntu-latest
48
+ runs_on_pool: ${{ matrix.os }}
49
50
# The Coverity site says the tool is usually updated twice yearly, so the
51
# MD5 of download can be used to determine whether there's been an update.
52
- name: get the Coverity Build Tool hash
53
id: lookup
54
run: |
55
+ case "${{ matrix.os }}" in
56
+ *windows*)
57
+ COVERITY_PLATFORM=win64
58
+ COVERITY_TOOL_FILENAME=cov-analysis.zip
59
+ ;;
60
+ *ubuntu*)
61
+ COVERITY_PLATFORM=linux64
62
+ COVERITY_TOOL_FILENAME=cov-analysis.tgz
63
+ ;;
64
+ *)
65
+ echo '::error::unhandled OS ${{ matrix.os }}' >&2
66
+ exit 1
67
+ ;;
68
+ esac
69
+ echo "COVERITY_PLATFORM=$COVERITY_PLATFORM" >>$GITHUB_ENV
70
+ echo "COVERITY_TOOL_FILENAME=$COVERITY_TOOL_FILENAME" >>$GITHUB_ENV
71
MD5=$(curl https://scan.coverity.com/download/$COVERITY_LANGUAGE/$COVERITY_PLATFORM \
72
--fail \
73
--form token='${{ secrets.COVERITY_SCAN_TOKEN }}' \
@@ -57,14 +88,28 @@ jobs:
88
run: |
89
curl https://scan.coverity.com/download/$COVERITY_LANGUAGE/$COVERITY_PLATFORM \
90
--fail --no-progress-meter \
60
- --output $RUNNER_TEMP/cov-analysis.tgz \
91
+ --output $RUNNER_TEMP/$COVERITY_TOOL_FILENAME \
92
--form token='${{ secrets.COVERITY_SCAN_TOKEN }}' \
93
--form project="$COVERITY_PROJECT"
94
- name: extract the Coverity Build Tool
95
if: steps.cache.outputs.cache-hit != 'true'
96
run: |
66
- mkdir $RUNNER_TEMP/cov-analysis &&
67
- tar -xzf $RUNNER_TEMP/cov-analysis.tgz --strip 1 -C $RUNNER_TEMP/cov-analysis
97
+ case "$COVERITY_TOOL_FILENAME" in
98
+ *.tgz)
99
+ mkdir $RUNNER_TEMP/cov-analysis &&
100
+ tar -xzf $RUNNER_TEMP/$COVERITY_TOOL_FILENAME --strip 1 -C $RUNNER_TEMP/cov-analysis
101
+ ;;
102
+ *.zip)
103
+ cd $RUNNER_TEMP &&
104
+ mkdir cov-analysis-tmp &&
105
+ unzip -d cov-analysis-tmp $COVERITY_TOOL_FILENAME &&
106
+ mv cov-analysis-tmp/* cov-analysis
107
+ ;;
108
+ *)
109
+ echo "::error::unhandled archive type: $COVERITY_TOOL_FILENAME" >&2
110
+ exit 1
111
+ ;;
112
+ esac
113
- name: cache the Coverity Build Tool
114
if: steps.cache.outputs.cache-hit != 'true'
115
uses: actions/cache/save@v3