@@ -12,31 +12,62 @@ name: Coverity
12
12
# email to which the Coverity reports should be sent and the latter can be
13
13
# obtained from the Project Settings tab of the Coverity project).
14
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
+ #
15
19
# By default, the builds are submitted to the Coverity project `git`. To override this,
16
20
# set the repository variable `COVERITY_PROJECT`.
17
21
18
22
on :
19
23
push :
20
24
25
+ defaults :
26
+ run :
27
+ shell : bash
28
+
21
29
jobs :
22
30
coverity :
23
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 }}
25
36
env :
26
37
COVERITY_PROJECT : ${{ vars.COVERITY_PROJECT || 'git' }}
27
38
COVERITY_LANGUAGE : cxx
28
- COVERITY_PLATFORM : linux64
39
+ COVERITY_PLATFORM : overridden-below
29
40
steps :
30
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
31
45
- run : ci/install-dependencies.sh
46
+ if : contains(matrix.os, 'ubuntu')
32
47
env :
33
- runs_on_pool : ubuntu-latest
48
+ runs_on_pool : ${{ matrix.os }}
34
49
35
50
# The Coverity site says the tool is usually updated twice yearly, so the
36
51
# MD5 of download can be used to determine whether there's been an update.
37
52
- name : get the Coverity Build Tool hash
38
53
id : lookup
39
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
40
71
MD5=$(curl https://scan.coverity.com/download/$COVERITY_LANGUAGE/$COVERITY_PLATFORM \
41
72
--fail \
42
73
--form token='${{ secrets.COVERITY_SCAN_TOKEN }}' \
@@ -57,14 +88,28 @@ jobs:
57
88
run : |
58
89
curl https://scan.coverity.com/download/$COVERITY_LANGUAGE/$COVERITY_PLATFORM \
59
90
--fail --no-progress-meter \
60
- --output $RUNNER_TEMP/cov-analysis.tgz \
91
+ --output $RUNNER_TEMP/$COVERITY_TOOL_FILENAME \
61
92
--form token='${{ secrets.COVERITY_SCAN_TOKEN }}' \
62
93
--form project="$COVERITY_PROJECT"
63
94
- name : extract the Coverity Build Tool
64
95
if : steps.cache.outputs.cache-hit != 'true'
65
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
68
113
- name : cache the Coverity Build Tool
69
114
if : steps.cache.outputs.cache-hit != 'true'
70
115
uses : actions/cache/save@v3
0 commit comments