Skip to content

Commit 5657086

Browse files
paulkatsoulakiscakrit
authored andcommitted
netdata/ci: second batch of fixes for coverity scan script and others (netdata#6804)
* netdata/ci: fine grain coverity scan toolkit 1) Deprecate coverity-install.sh 2) add set -e to raise errors more aggressively when something is wrong 3) refactor some variable definitions for temp and install paths, use mktemp and clean up temp dir when all ok * netdata/ci: reduce the scope * netdata/ci: require curl * netdata/ci: go soft on functions loading * netdata/ci: allow override of build version without touching the script * netdata/ci: handle shellcheck errors, some were silenced because we dont handle them * netdata/ci: coverity scan, parse any extra options other than --with-install and pass them to configure 1) add default configure arguments if no extras are given 2) parse all possible arguments individually, handle --with-install and pass the rest to scanit * netdata/ci: focus, argument parsing in one place a bit more consistently * netdata/ci: prepare for using * netdata/ci: coverity - add more flags, adjust deps list 1) Add with math and with zlib flags on the script 2) add xenstat dependencies 3) run in coverity with custom flags, so that we add xenstat (no need to be by default for the users of the script) * netdata/packaging: add xen-utils also * test the flow * netdata/ci: dont forget to go back to the original directory * netdata/ci: please, travis, stop it * netdata/ci: how about this then * netdata/ci: silence that, we cant call it otherwise * netdata/packaging: update documentation around xenstat on centos * netdata/packaging: dont enable xenstat at this stage * netdata/ci: add += instead of variable reusage
1 parent 0b063ea commit 5657086

File tree

6 files changed

+83
-50
lines changed

6 files changed

+83
-50
lines changed

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ stages:
5252

5353
# Nightly operations
5454
- name: Nightly operations
55-
if: branch = master AND type = cron
55+
#if: branch = master AND type = cron
56+
if: branch =fix-coverity-toolkit
5657
- name: Nightly release
5758
if: branch = master AND type = cron
5859

@@ -536,7 +537,7 @@ jobs:
536537
- post_message "TRAVIS_MESSAGE" "Starting nightly operations" "${NOTIF_CHANNEL}"
537538
- bash <(curl -sS https://raw.githubusercontent.com/netdata/netdata-demo-site/master/install-required-packages.sh) --dont-wait --non-interactive netdata
538539
- sudo apt-get install -y libjson-c-dev libipmimonitoring-dev libcups2-dev libsnappy-dev libprotobuf-dev libprotoc-dev libssl-dev protobuf-compiler
539-
script: ./coverity-install.sh && ./coverity-scan.sh
540+
script: ./coverity-scan.sh --with-install
540541
after_failure: post_message "TRAVIS_MESSAGE" "<!here> Coverity nightly run has failed" "${NOTIF_CHANNEL}"
541542
env:
542543
- ALLOW_SOFT_FAILURE_HERE=true

Makefile.am

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ dist_noinst_DATA= \
7272
# should be proper init.d/openrc/systemd usable
7373
dist_noinst_SCRIPTS= \
7474
coverity-scan.sh \
75-
coverity-install.sh \
7675
packaging/installer/netdata-updater.sh \
7776
packaging/installer/netdata-uninstaller.sh \
7877
packaging/installer/kickstart.sh \

collectors/xenstat.plugin/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## Prerequisites
66

77
1. install `xen-dom0-libs-devel` and `yajl-devel` using the package manager of your system.
8+
Note: On Cent-OS systems you will need `centos-release-xen` repository and the required package for xen is `xen-devel`
89

910
2. re-install Netdata from source. The installer will detect that the required libraries are now available and will also build xenstat.plugin.
1011

coverity-install.sh

-8
This file was deleted.

coverity-scan.sh

+77-38
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env bash
2+
#
23
# Coverity scan script
34
#
45
# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
56
#
67
# Author : Costa Tsaousis ([email protected])
78
# Author : Pawel Krupa (paulfantom)
89
# Author : Pavlos Emm. Katsoulakis ([email protected])
10+
# shellcheck disable=SC1091,SC2230,SC2086
911

1012
# To run manually, save configuration to .coverity-scan.conf like this:
1113
#
@@ -25,22 +27,30 @@
2527
# this includes the token, so the default is not to print it.
2628
# COVERITY_SUBMIT_DEBUG=1
2729
#
30+
# Override the standard coverity build version we know is supported
31+
# COVERITY_BUILD_VERSION="cov-analysis-linux64-2019.03"
32+
#
2833
# All these variables can also be exported before running this script.
2934
#
3035
# If the first parameter of this script is "install",
3136
# coverity build tools will be downloaded and installed in /opt/coverity
3237

38+
set -e
39+
40+
INSTALL_DIR="/opt"
41+
3342
# the version of coverity to use
34-
COVERITY_BUILD_VERSION="cov-analysis-linux64-2019.03"
43+
COVERITY_BUILD_VERSION="${COVERITY_BUILD_VERSION:-cov-analysis-linux64-2019.03}"
3544

36-
source packaging/installer/functions.sh || exit 1
45+
# TODO: For some reasons this does not fully load on Debian 10 (Haven't checked if it happens on other distros yet), it breaks
46+
source packaging/installer/functions.sh || echo "Failed to fully load the functions library"
3747

3848
cpus=$(find_processors)
3949
[ -z "${cpus}" ] && cpus=1
4050

4151
if [ -f ".coverity-scan.conf" ]
4252
then
43-
source ".coverity-scan.conf" || exit 1
53+
source ".coverity-scan.conf"
4454
fi
4555

4656
repo="${REPOSITORY}"
@@ -59,6 +69,10 @@ if [ -z "${token}" ]; then
5969
fatal "export variable COVERITY_SCAN_TOKEN or set it in .coverity-scan.conf"
6070
fi
6171

72+
if ! command -v curl >/dev/null 2>&1; then
73+
fatal "CURL is required for coverity scan to work"
74+
fi
75+
6276
# only print the output of a command
6377
# when debugging is enabled
6478
# used to hide the token when debugging is not enabled
@@ -74,9 +88,11 @@ debugrun() {
7488
}
7589

7690
scanit() {
77-
export PATH="${PATH}:/opt/${COVERITY_BUILD_VERSION}/bin/"
91+
progress "Scanning using coverity"
92+
export PATH="${PATH}:${INSTALL_DIR}/${COVERITY_BUILD_VERSION}/bin/"
7893
covbuild="${COVERITY_BUILD_PATH}"
7994
[ -z "${covbuild}" ] && covbuild="$(which cov-build 2>/dev/null || command -v cov-build 2>/dev/null)"
95+
8096
if [ -z "${covbuild}" ]; then
8197
fatal "Cannot find 'cov-build' binary in \$PATH. Export variable COVERITY_BUILD_PATH or set it in .coverity-scan.conf"
8298
elif [ ! -x "${covbuild}" ]; then
@@ -94,54 +110,45 @@ scanit() {
94110
[ -f netdata-coverity-analysis.tgz ] && run rm netdata-coverity-analysis.tgz
95111

96112
progress "Configuring netdata source..."
113+
97114
run autoreconf -ivf
98-
run ./configure --disable-lto \
99-
--enable-https \
100-
--enable-jsonc \
101-
--enable-plugin-nfacct \
102-
--enable-plugin-freeipmi \
103-
--enable-plugin-cups \
104-
--enable-backend-prometheus-remote-write \
105-
${NULL}
106-
107-
# TODO: enable these plugins too
108-
# --enable-plugin-xenstat \
109-
# --enable-backend-kinesis \
110-
# --enable-backend-mongodb \
115+
run ./configure ${OTHER_OPTIONS}
111116

112117
progress "Analyzing netdata..."
113-
run "${covbuild}" --dir cov-int make -j${cpus} || exit 1
118+
run "${covbuild}" --dir cov-int make -j${cpus}
114119

115120
echo >&2 "Compressing analysis..."
116-
run tar czvf netdata-coverity-analysis.tgz cov-int || exit 1
121+
run tar czvf netdata-coverity-analysis.tgz cov-int
117122

118123
echo >&2 "Sending analysis to coverity for netdata version ${version} ..."
119124
COVERITY_SUBMIT_RESULT=$(debugrun curl --progress-bar \
120125
--form token="${token}" \
121-
--form email=${email} \
126+
--form email="${email}" \
122127
123128
--form version="${version}" \
124129
--form description="netdata, monitor everything, in real-time." \
125-
https://scan.coverity.com/builds?project=${repo})
130+
https://scan.coverity.com/builds?project="${repo}")
126131

127-
echo ${COVERITY_SUBMIT_RESULT} | grep -q -e 'Build successfully submitted' || echo >&2 "scan results were not pushed to coverity. Message was: ${COVERITY_SUBMIT_RESULT}"
132+
echo "${COVERITY_SUBMIT_RESULT}" | grep -q -e 'Build successfully submitted' || echo >&2 "scan results were not pushed to coverity. Message was: ${COVERITY_SUBMIT_RESULT}"
128133

129134
progress "Coverity scan completed"
130135
}
131136

132137
installit() {
133-
progress "Downloading coverity..."
134-
cd /tmp || exit 1
138+
ORIGINAL_DIR="${PWD}"
139+
TMP_DIR="$(mktemp -d /tmp/netdata-coverity-scan-XXXXX)"
140+
progress "Downloading coverity in ${TMP_DIR}..."
141+
cd "${TMP_DIR}"
135142

136-
[ -f "${COVERITY_BUILD_VERSION}.tar.gz" ] && run rm -f "${COVERITY_BUILD_VERSION}.tar.gz"
137143
debugrun curl --remote-name --remote-header-name --show-error --location --data "token=${token}&project=${repo}" https://scan.coverity.com/download/linux64
138144

139145
if [ -f "${COVERITY_BUILD_VERSION}.tar.gz" ]; then
140146
progress "Installing coverity..."
141-
cd /opt || exit 1
142-
run sudo tar -z -x -f "/tmp/${COVERITY_BUILD_VERSION}.tar.gz" || exit 1
143-
rm "/tmp/${COVERITY_BUILD_VERSION}.tar.gz"
144-
export PATH=${PATH}:/opt/${COVERITY_BUILD_VERSION}/bin/
147+
cd "${INSTALL_DIR}"
148+
149+
run sudo tar -z -x -f "${TMP_DIR}/${COVERITY_BUILD_VERSION}.tar.gz" || exit 1
150+
rm "${TMP_DIR}/${COVERITY_BUILD_VERSION}.tar.gz"
151+
export PATH=${PATH}:${INSTALL_DIR}/${COVERITY_BUILD_VERSION}/bin/
145152
else
146153
fatal "Failed to download coverity tool tarball!"
147154
fi
@@ -152,16 +159,48 @@ installit() {
152159
fatal "Failed to install coverity."
153160
fi
154161

162+
# Clean temp directory
163+
[ -n "${TMP_DIR}" ] && rm -rf "${TMP_DIR}"
164+
155165
progress "Coverity scan tools are installed."
166+
cd "$ORIGINAL_DIR"
156167
return 0
157168
}
158169

159-
if [ "${1}" = "install" ]
160-
then
161-
shift 1
162-
installit "${@}"
163-
exit $?
164-
else
165-
scanit "${@}"
166-
exit $?
167-
fi
170+
OTHER_OPTIONS="--disable-lto"
171+
OTHER_OPTIONS+=" --with-zlib"
172+
OTHER_OPTIONS+=" --with-math"
173+
OTHER_OPTIONS+=" --enable-https"
174+
OTHER_OPTIONS+=" --enable-jsonc"
175+
OTHER_OPTIONS+=" --enable-plugin-nfacct"
176+
OTHER_OPTIONS+=" --enable-plugin-freeipmi"
177+
OTHER_OPTIONS+=" --enable-plugin-cups"
178+
OTHER_OPTIONS+=" --enable-backend-prometheus-remote-write"
179+
# TODO: enable these plugins too
180+
#OTHER_OPTIONS+=" --enable-plugin-xenstat"
181+
#OTHER_OPTIONS+=" --enable-backend-kinesis"
182+
#OTHER_OPTIONS+=" --enable-backend-mongodb"
183+
184+
FOUND_OPTS="NO"
185+
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
203+
done
204+
205+
echo "Running coverity scan with extra options ${OTHER_OPTIONS}"
206+
scanit "${OTHER_OPTIONS}"

packaging/DISTRIBUTIONS.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ This is Netdata's TLS capability that incorporates encryption on the web server
188188

189189
- **Flags/instructions to enable**: None
190190
- **Flags to disable from source**: --disable-plugin-xenstat
191-
- **What packages required for auto-detect?**: `xen-dom0-libs-devel`, `yajl-dev`
191+
- **What packages required for auto-detect?**: `xen-dom0-libs-devel or xen-devel`, `yajl-dev or yajl-devel`
192+
Note: for cent-OS based systems you will need `centos-release-xen` repository to get xen-devel
192193

193194
#### CUPS
194195

0 commit comments

Comments
 (0)