Build and test in parallel

This speeds up builds when more CPUs are available. Also removed redundant
docker installation: mdbci already installs it.
This commit is contained in:
Markus Mäkelä
2019-11-08 14:11:28 +02:00
parent 638d1bf354
commit 9e931918e2
3 changed files with 23 additions and 26 deletions

View File

@ -5,25 +5,26 @@
set -x set -x
cd ./MaxScale cpus=$(grep -c processor /proc/cpuinfo)
cd ./MaxScale
mkdir _build mkdir _build
cd _build cd _build
cmake .. $cmake_flags cmake .. $cmake_flags
export LD_LIBRARY_PATH=$PWD/log_manager:$PWD/query_classifier export LD_LIBRARY_PATH=$PWD/log_manager:$PWD/query_classifier
make || exit 1 make -j $cpus || exit 1
if [[ "$cmake_flags" =~ "BUILD_TESTS=Y" ]] if [[ "$cmake_flags" =~ "BUILD_TESTS=Y" ]]
then then
# We don't care about memory leaks in the tests (e.g. servers are never freed) # We don't care about memory leaks in the tests (e.g. servers are never freed)
export ASAN_OPTIONS=detect_leaks=0 export ASAN_OPTIONS=detect_leaks=0
# All tests must pass otherwise the build is considered a failure # All tests must pass otherwise the build is considered a failure
ctest --output-on-failure || exit 1 ctest --output-on-failure -j 100 || exit 1
fi fi
export LD_LIBRARY_PATH=$(for i in `find $PWD/ -name '*.so*'`; do echo $(dirname $i); done|sort|uniq|xargs|sed -e 's/[[:space:]]/:/g') export LD_LIBRARY_PATH=$(for i in `find $PWD/ -name '*.so*'`; do echo $(dirname $i); done|sort|uniq|xargs|sed -e 's/[[:space:]]/:/g')
make package make package -j $cpus
res=$? res=$?
if [ $res != 0 ] ; then if [ $res != 0 ] ; then
echo "Make package failed" echo "Make package failed"
@ -35,7 +36,7 @@ sudo rm CMakeCache.txt
echo "Building tarball..." echo "Building tarball..."
cmake .. $cmake_flags -DTARBALL=Y cmake .. $cmake_flags -DTARBALL=Y
sudo make package sudo make package -j $cpus
cp _CPack_Packages/Linux/DEB/*.deb ../ cp _CPack_Packages/Linux/DEB/*.deb ../
@ -57,7 +58,7 @@ then
export LD_LIBRARY_PATH="" export LD_LIBRARY_PATH=""
cmake .. $cmake_flags -DTARGET_COMPONENT=$component cmake .. $cmake_flags -DTARGET_COMPONENT=$component
export LD_LIBRARY_PATH=$(for i in `find $PWD/ -name '*.so*'`; do echo $(dirname $i); done|sort|uniq|xargs|sed -e 's/[[:space:]]/:/g') export LD_LIBRARY_PATH=$(for i in `find $PWD/ -name '*.so*'`; do echo $(dirname $i); done|sort|uniq|xargs|sed -e 's/[[:space:]]/:/g')
make package make package -j $cpus
cp _CPack_Packages/Linux/DEB/*.deb ../ cp _CPack_Packages/Linux/DEB/*.deb ../
cd .. cd ..
cp _build/*.deb . cp _build/*.deb .
@ -68,7 +69,7 @@ fi
if [ "$BUILD_RABBITMQ" == "yes" ] ; then if [ "$BUILD_RABBITMQ" == "yes" ] ; then
cmake ../rabbitmq_consumer/ $cmake_flags cmake ../rabbitmq_consumer/ $cmake_flags
sudo make package sudo make package -j $cpus
res=$? res=$?
if [ $res != 0 ] ; then if [ $res != 0 ] ; then
exit $res exit $res

View File

@ -5,19 +5,21 @@
set -x set -x
cpus=$(grep -c processor /proc/cpuinfo)
cd ./MaxScale cd ./MaxScale
mkdir _build mkdir _build
cd _build cd _build
cmake .. $cmake_flags cmake .. $cmake_flags
make || exit 1 make -j $cpus || exit 1
if [[ "$cmake_flags" =~ "BUILD_TESTS=Y" ]] if [[ "$cmake_flags" =~ "BUILD_TESTS=Y" ]]
then then
# We don't care about memory leaks in the tests (e.g. servers are never freed) # We don't care about memory leaks in the tests (e.g. servers are never freed)
export ASAN_OPTIONS=detect_leaks=0 export ASAN_OPTIONS=detect_leaks=0
# All tests must pass otherwise the build is considered a failure # All tests must pass otherwise the build is considered a failure
ctest --output-on-failure || exit 1 ctest --output-on-failure -j 100 || exit 1
# See if docker is installed and run REST API and MaxCtrl tests if it is # See if docker is installed and run REST API and MaxCtrl tests if it is
command -v docker command -v docker
@ -41,7 +43,7 @@ sudo rm -rf /usr/bin/strip
sudo touch /usr/bin/strip sudo touch /usr/bin/strip
sudo chmod a+x /usr/bin/strip sudo chmod a+x /usr/bin/strip
sudo make package sudo make package -j $cpus
res=$? res=$?
if [ $res != 0 ] ; then if [ $res != 0 ] ; then
echo "Make package failed" echo "Make package failed"
@ -53,7 +55,7 @@ sudo rm CMakeCache.txt
echo "Building tarball..." echo "Building tarball..."
cmake .. $cmake_flags -DTARBALL=Y cmake .. $cmake_flags -DTARBALL=Y
sudo make package sudo make package -j $cpus
cd .. cd ..
cp _build/*.rpm . cp _build/*.rpm .
@ -66,7 +68,7 @@ then
cd _build cd _build
rm CMakeCache.txt rm CMakeCache.txt
cmake .. $cmake_flags -DTARGET_COMPONENT=$component cmake .. $cmake_flags -DTARGET_COMPONENT=$component
sudo make package sudo make package -j $cpus
cd .. cd ..
cp _build/*.rpm . cp _build/*.rpm .
cp _build/*.gz . cp _build/*.gz .
@ -75,7 +77,7 @@ fi
if [ "$BUILD_RABBITMQ" == "yes" ] ; then if [ "$BUILD_RABBITMQ" == "yes" ] ; then
cmake ../rabbitmq_consumer/ $cmake_flags cmake ../rabbitmq_consumer/ $cmake_flags
sudo make package sudo make package -j $cpus
res=$? res=$?
if [ $res != 0 ] ; then if [ $res != 0 ] ; then
exit $res exit $res

View File

@ -6,6 +6,8 @@
# Build in a temp directory so we don't pollute cwd # Build in a temp directory so we don't pollute cwd
tmpdir=$(mktemp -d) tmpdir=$(mktemp -d)
cpus=$(grep -c processor /proc/cpuinfo)
cd $tmpdir cd $tmpdir
command -v apt-get command -v apt-get
@ -102,14 +104,6 @@ else
# Enable it by default # Enable it by default
echo "source /opt/rh/devtoolset-7/enable" >> ~/.bashrc echo "source /opt/rh/devtoolset-7/enable" >> ~/.bashrc
else
# Installed for REST API and MaxCtrl unit tests
sudo yum -y install docker epel-release
sudo yum -y install docker-compose
sudo groupadd docker
sudo usermod -a -G docker `whoami`
sudo sed -i 's/--selinux-enabled/--selinux-enabled=false/' /etc/sysconfig/docker
sudo systemctl start docker
fi fi
fi fi
@ -131,7 +125,7 @@ if [ "`echo -e "3.7.1\n$cmake_version"|sort -V|head -n 1`" != "3.7.1" ] ; then
cd cmake-3.7.1 cd cmake-3.7.1
./bootstrap ./bootstrap
gmake make -j $cpus
sudo make install sudo make install
cd .. cd ..
fi fi
@ -151,7 +145,7 @@ fi
cd rabbitmq-c cd rabbitmq-c
git checkout v0.7.1 git checkout v0.7.1
cmake . -DCMAKE_C_FLAGS=-fPIC -DBUILD_SHARED_LIBS=N -DCMAKE_INSTALL_PREFIX=/usr cmake . -DCMAKE_C_FLAGS=-fPIC -DBUILD_SHARED_LIBS=N -DCMAKE_INSTALL_PREFIX=/usr
sudo make install sudo make install -j $cpus
cd ../../ cd ../../
# TCL # TCL
@ -180,7 +174,7 @@ then
tar xzf tcl8.6.5-src.tar.gz tar xzf tcl8.6.5-src.tar.gz
cd tcl8.6.5/unix cd tcl8.6.5/unix
./configure ./configure
sudo make install sudo make install -j $cpus
cd ../../.. cd ../../..
fi fi
@ -198,7 +192,7 @@ git checkout v2.9
mkdir build mkdir build
cd build cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS=-fPIC -DJANSSON_INSTALL_LIB_DIR=$install_libdir cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS=-fPIC -DJANSSON_INSTALL_LIB_DIR=$install_libdir
make make -j $cpus
sudo make install sudo make install
cd ../../ cd ../../
@ -218,7 +212,7 @@ pushd $avro_dir/build
# Make sure the library isn't linked against snappy # Make sure the library isn't linked against snappy
sed -i 's/find_package(Snappy)//' ../lang/c/CMakeLists.txt sed -i 's/find_package(Snappy)//' ../lang/c/CMakeLists.txt
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS=-fPIC -DCMAKE_CXX_FLAGS=-fPIC cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS=-fPIC -DCMAKE_CXX_FLAGS=-fPIC
make make -j $cpus
sudo make install sudo make install
popd popd