mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix Travis CI script to run Coverity build in container
It was previously running on the host and didn't have adequate compiler to do C++17.
This commit is contained in:
parent
49c59ceb99
commit
8d31baf3b7
1 changed files with 30 additions and 26 deletions
|
@ -9,6 +9,7 @@
|
||||||
# (if you don't, then the private tests will be skipped).
|
# (if you don't, then the private tests will be skipped).
|
||||||
|
|
||||||
LEAK_TEST_DISTRO="ubuntu_18.04_leaktest"
|
LEAK_TEST_DISTRO="ubuntu_18.04_leaktest"
|
||||||
|
COVERITY_DISTRO="ubuntu_18.04"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "usage: $0 CMD DISTRO"
|
echo "usage: $0 CMD DISTRO"
|
||||||
|
@ -96,7 +97,7 @@ install_in_docker() {
|
||||||
distro_cmds="apt-get update; apt-get -y install gdb cmake make flex bison python libpcap-dev libssl-dev zlib1g-dev libkrb5-dev git sqlite3 curl bsdmainutils wget xz-utils; wget -q https://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz; mkdir /clang-9; tar --strip-components=1 -C /clang-9 -xvf clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz; update-alternatives --install /usr/bin/cc cc /clang-9/bin/clang 100; update-alternatives --install /usr/bin/c++ c++ /clang-9/bin/clang++ 100"
|
distro_cmds="apt-get update; apt-get -y install gdb cmake make flex bison python libpcap-dev libssl-dev zlib1g-dev libkrb5-dev git sqlite3 curl bsdmainutils wget xz-utils; wget -q https://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz; mkdir /clang-9; tar --strip-components=1 -C /clang-9 -xvf clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz; update-alternatives --install /usr/bin/cc cc /clang-9/bin/clang 100; update-alternatives --install /usr/bin/c++ c++ /clang-9/bin/clang++ 100"
|
||||||
;;
|
;;
|
||||||
ubuntu_18.04)
|
ubuntu_18.04)
|
||||||
distro_cmds="apt-get update; apt-get -y install gdb cmake make gcc g++ flex bison python3 libpcap-dev libssl-dev zlib1g-dev libkrb5-dev git sqlite3 curl bsdmainutils; ln -s /usr/bin/python3 /usr/local/bin/python"
|
distro_cmds="apt-get update; apt-get -y install wget xz-utils gdb cmake make gcc g++ flex bison python3 libpcap-dev libssl-dev zlib1g-dev libkrb5-dev git sqlite3 curl bsdmainutils; ln -s /usr/bin/python3 /usr/local/bin/python"
|
||||||
;;
|
;;
|
||||||
${LEAK_TEST_DISTRO})
|
${LEAK_TEST_DISTRO})
|
||||||
distro_cmds="apt-get update; apt-get -y install gdb cmake make gcc g++ flex bison python3 libpcap-dev libssl-dev zlib1g-dev libkrb5-dev git sqlite3 curl bsdmainutils google-perftools libgoogle-perftools4 libgoogle-perftools-dev; ln -s /usr/bin/python3 /usr/local/bin/python"
|
distro_cmds="apt-get update; apt-get -y install gdb cmake make gcc g++ flex bison python3 libpcap-dev libssl-dev zlib1g-dev libkrb5-dev git sqlite3 curl bsdmainutils google-perftools libgoogle-perftools4 libgoogle-perftools-dev; ln -s /usr/bin/python3 /usr/local/bin/python"
|
||||||
|
@ -116,17 +117,29 @@ install_in_docker() {
|
||||||
|
|
||||||
# Build Zeek in a docker container.
|
# Build Zeek in a docker container.
|
||||||
build_in_docker() {
|
build_in_docker() {
|
||||||
|
recursed_distro=travis
|
||||||
|
|
||||||
|
if [ "${TRAVIS_EVENT_TYPE}" = "cron" ]; then
|
||||||
|
recursed_distro=coverity
|
||||||
|
fi
|
||||||
|
|
||||||
# Pass the distro as a different environment variable name to docker since
|
# Pass the distro as a different environment variable name to docker since
|
||||||
# the script will set $distro to "travis" as part of the invocation.
|
# the script will set $distro to "travis" as part of the invocation.
|
||||||
docker exec -e BUILD_DISTRO=${distro} zeektest sh testing/scripts/travis-job build travis
|
docker exec -e COV_TOKEN -e BUILD_DISTRO=${distro} zeektest sh testing/scripts/travis-job build ${recursed_distro}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Run Zeek tests in a docker container.
|
# Run Zeek tests in a docker container.
|
||||||
run_in_docker() {
|
run_in_docker() {
|
||||||
|
recursed_distro=travis
|
||||||
|
|
||||||
|
if [ "${TRAVIS_EVENT_TYPE}" = "cron" ]; then
|
||||||
|
recursed_distro=coverity
|
||||||
|
fi
|
||||||
|
|
||||||
# Pass the distro as a different environment variable name to docker since
|
# Pass the distro as a different environment variable name to docker since
|
||||||
# the script will set $distro to "travis" as part of the invocation.
|
# the script will set $distro to "travis" as part of the invocation.
|
||||||
docker exec -t -e TRAVIS -e TRAVIS_PULL_REQUEST -e TESTING_PRIVATE_DEPLOYKEY -e BUILD_DISTRO=${distro} zeektest sh testing/scripts/travis-job run travis
|
docker exec -t -e TRAVIS -e TRAVIS_PULL_REQUEST -e TESTING_PRIVATE_DEPLOYKEY -e COV_TOKEN -e BUILD_DISTRO=${distro} zeektest sh testing/scripts/travis-job run ${recursed_distro}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_env() {
|
update_env() {
|
||||||
|
@ -326,29 +339,7 @@ fi
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ "${TRAVIS_EVENT_TYPE}" = "cron" ]; then
|
|
||||||
# This is a Travis CI cron job, so check the job number.
|
|
||||||
|
|
||||||
# Extract second component of the job number.
|
|
||||||
if [ -z "${TRAVIS_JOB_NUMBER}" ]; then
|
|
||||||
echo "Error: TRAVIS_JOB_NUMBER is not defined (it should be defined by Travis CI)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
job=`echo ${TRAVIS_JOB_NUMBER} | cut -d . -f 2`
|
|
||||||
|
|
||||||
# If this isn't the first job in a Travis CI build, then just output a
|
|
||||||
# message and exit (this is not an error).
|
|
||||||
if [ "$job" != "1" ]; then
|
|
||||||
echo "Coverity scan is performed only in the first job of this build"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ "${TRAVIS_EVENT_TYPE}" = "cron" ] || [ "$distro" = "coverity" ]; then
|
if [ "${TRAVIS_EVENT_TYPE}" = "cron" ] || [ "$distro" = "coverity" ]; then
|
||||||
# Run coverity scan when this script is run from a Travis cron job, or
|
|
||||||
# if the user specifies the "coverity" distro.
|
|
||||||
|
|
||||||
# Check if the project token is available (this is a secret value and
|
# Check if the project token is available (this is a secret value and
|
||||||
# should not be hard-coded in this script). This value can be found by
|
# should not be hard-coded in this script). This value can be found by
|
||||||
# logging into the coverity scan web site and looking in the project
|
# logging into the coverity scan web site and looking in the project
|
||||||
|
@ -357,13 +348,26 @@ if [ "${TRAVIS_EVENT_TYPE}" = "cron" ] || [ "$distro" = "coverity" ]; then
|
||||||
echo "Error: COV_TOKEN is not defined (should be defined in environment variables section of Travis settings for this repo)"
|
echo "Error: COV_TOKEN is not defined (should be defined in environment variables section of Travis settings for this repo)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${TRAVIS_EVENT_TYPE}" = "cron" ]; then
|
||||||
|
# This is a Travis CI cron job which only runs the Coverity build inside
|
||||||
|
# a single container.
|
||||||
|
|
||||||
|
if [ "$distro" != "${COVERITY_DISTRO}" ]; then
|
||||||
|
echo "Coverity scan is performed on ${COVERITY_DISTRO}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$distro" = "coverity" ]; then
|
||||||
# The "build" and "run" steps are split up into separate steps because the
|
# The "build" and "run" steps are split up into separate steps because the
|
||||||
# build outputs thousands of lines (which are conveniently collapsed into
|
# build outputs thousands of lines (which are conveniently collapsed into
|
||||||
# a single line when viewing the "Job log" on the Travis CI web site).
|
# a single line when viewing the "Job log" on the Travis CI web site).
|
||||||
if [ "$step" = "install" ]; then
|
if [ "$step" = "install" ]; then
|
||||||
install_coverity
|
echo "No 'install' step needed for Coverity build"
|
||||||
elif [ "$step" = "build" ]; then
|
elif [ "$step" = "build" ]; then
|
||||||
|
install_coverity
|
||||||
build_coverity
|
build_coverity
|
||||||
elif [ "$step" = "run" ]; then
|
elif [ "$step" = "run" ]; then
|
||||||
run_coverity
|
run_coverity
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue