Fix coverity scan (#8388)
* Fix coverity scan * Add path filter to pull_request: condition * Add missing dependency
James Mills committed
Mar 13, 2020 at 07:24 UTC
a18ec2d2d81bfa178be09f3fa427ea4ddbc1bf40
2 files changed
+41
-33
.github/workflows/coverity.yml
+13
-3
@@ -4,6 +4,10 @@ name: Coverity Scan
4
on:
5
schedule:
6
- cron: '0 1 * * *'
7
+ pull_request:
8
+ paths:
9
+ - .github/workflows/coverity.yml
10
+ - coverity-scan.sh
11
jobs:
12
coverity:
13
if: github.repository == 'netdata/netdata'
@@ -12,12 +16,18 @@ jobs:
16
- name: Checkout
17
uses: actions/checkout@v2
18
- name: Prepare environment
19
+ env:
20
+ DEBIAN_FRONTEND: 'noninteractive'
21
run: |
16
- ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata
17
- sudo apt-get install -y libjson-c-dev libipmimonitoring-dev libcups2-dev libsnappy-dev \
18
- libprotobuf-dev libprotoc-dev libssl-dev protobuf-compiler
22
+ ./packaging/installer/install-required-packages.sh \
23
+ --dont-wait --non-interactive netdata
24
+ sudo apt-get install -y libjson-c-dev libipmimonitoring-dev \
25
+ libcups2-dev libsnappy-dev libprotobuf-dev \
26
+ libprotoc-dev libssl-dev protobuf-compiler \
27
+ libnetfilter-acct-dev
28
- name: Run coverity-scan
29
env:
30
+ REPOSITORY: 'netdata/netdata'
31
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
32
COVERITY_SCAN_SUBMIT_MAIL: ${{ secrets.COVERITY_SCAN_SUBMIT_MAIL }}
33
run: |
coverity-scan.sh
+28
-30
@@ -48,37 +48,35 @@ source packaging/installer/functions.sh || echo "Failed to fully load the functi
48
cpus=$(find_processors)
49
[ -z "${cpus}" ] && cpus=1
50
51
-if [ -f ".coverity-scan.conf" ]
52
-then
53
- source ".coverity-scan.conf"
51
+if [ -f ".coverity-scan.conf" ]; then
52
+ source ".coverity-scan.conf"
53
fi
54
55
repo="${REPOSITORY}"
56
if [ -z "${repo}" ]; then
58
- fatal "export variable REPOSITORY or set it in .coverity-scan.conf"
57
+ fatal "export variable REPOSITORY or set it in .coverity-scan.conf"
58
fi
59
repo="${repo//\//%2F}"
60
61
email="${COVERITY_SCAN_SUBMIT_MAIL}"
62
if [ -z "${email}" ]; then
64
- fatal "export variable COVERITY_SCAN_SUBMIT_MAIL or set it in .coverity-scan.conf"
63
+ fatal "export variable COVERITY_SCAN_SUBMIT_MAIL or set it in .coverity-scan.conf"
64
fi
65
66
token="${COVERITY_SCAN_TOKEN}"
67
if [ -z "${token}" ]; then
69
- fatal "export variable COVERITY_SCAN_TOKEN or set it in .coverity-scan.conf"
68
+ fatal "export variable COVERITY_SCAN_TOKEN or set it in .coverity-scan.conf"
69
fi
70
72
-if ! command -v curl >/dev/null 2>&1; then
73
- fatal "CURL is required for coverity scan to work"
71
+if ! command -v curl > /dev/null 2>&1; then
72
+ fatal "CURL is required for coverity scan to work"
73
fi
74
75
# only print the output of a command
76
# when debugging is enabled
77
# used to hide the token when debugging is not enabled
78
debugrun() {
80
- if [ "${COVERITY_SUBMIT_DEBUG}" = "1" ]
81
- then
79
+ if [ "${COVERITY_SUBMIT_DEBUG}" = "1" ]; then
80
run "${@}"
81
return $?
82
else
@@ -91,7 +89,7 @@ scanit() {
89
progress "Scanning using coverity"
90
export PATH="${PATH}:${INSTALL_DIR}/${COVERITY_BUILD_VERSION}/bin/"
91
covbuild="${COVERITY_BUILD_PATH}"
94
- [ -z "${covbuild}" ] && covbuild="$(which cov-build 2>/dev/null || command -v cov-build 2>/dev/null)"
92
+ [ -z "${covbuild}" ] && covbuild="$(which cov-build 2> /dev/null || command -v cov-build 2> /dev/null)"
93
94
if [ -z "${covbuild}" ]; then
95
fatal "Cannot find 'cov-build' binary in \$PATH. Export variable COVERITY_BUILD_PATH or set it in .coverity-scan.conf"
@@ -146,7 +144,7 @@ installit() {
144
progress "Installing coverity..."
145
cd "${INSTALL_DIR}"
146
149
- run sudo tar -z -x -f "${TMP_DIR}/${COVERITY_BUILD_VERSION}.tar.gz" || exit 1
147
+ run sudo tar -z -x -f "${TMP_DIR}/${COVERITY_BUILD_VERSION}.tar.gz" || exit 1
148
rm "${TMP_DIR}/${COVERITY_BUILD_VERSION}.tar.gz"
149
export PATH=${PATH}:${INSTALL_DIR}/${COVERITY_BUILD_VERSION}/bin/
150
else
@@ -154,7 +152,7 @@ installit() {
152
fi
153
154
# Validate the installation
157
- covbuild="$(which cov-build 2>/dev/null || command -v cov-build 2>/dev/null)"
155
+ covbuild="$(which cov-build 2> /dev/null || command -v cov-build 2> /dev/null)"
156
if [ -z "$covbuild" ]; then
157
fatal "Failed to install coverity."
158
fi
@@ -183,23 +181,23 @@ OTHER_OPTIONS+=" --enable-backend-prometheus-remote-write"
181
182
FOUND_OPTS="NO"
183
while [ -n "${1}" ]; do
186
- if [ "${1}" = "--with-install" ]; then
187
- progress "Running coverity install"
188
- installit
189
- shift 1
190
- elif [ -n "${1}" ]; then
191
- # Clear the default arguments, once you bump into the first argument
192
- if [ "${FOUND_OPTS}" = "NO" ]; then
193
- OTHER_OPTIONS="${1}"
194
- FOUND_OPTS="YES"
195
- else
196
- OTHER_OPTIONS+=" ${1}"
197
- fi
198
-
199
- shift 1
200
- else
201
- break
202
- fi
184
+ if [ "${1}" = "--with-install" ]; then
185
+ progress "Running coverity install"
186
+ installit
187
+ shift 1
188
+ elif [ -n "${1}" ]; then
189
+ # Clear the default arguments, once you bump into the first argument
190
+ if [ "${FOUND_OPTS}" = "NO" ]; then
191
+ OTHER_OPTIONS="${1}"
192
+ FOUND_OPTS="YES"
193
+ else
194
+ OTHER_OPTIONS+=" ${1}"
195
+ fi
196
+
197
+ shift 1
198
+ else
199
+ break
200
+ fi
201
done
202
203
echo "Running coverity scan with extra options ${OTHER_OPTIONS}"