add docker compilation to travis (#3433)

* add docker compilation to travis

add new matrix entry in .travis.yml for compiling on 18.04
add Dockerfile in .ci to build ubuntu 18.04 inside docker
remove release entry for uvuntu 16.04 to not conflict
refactor .travis.yml
refactor travis-comile.sh
merge travis-dependencies.sh into the travis.yml
remove travis-dependencies.sh

* enable debugging on travis-compile.sh

* set ubuntu16 buildtype to "Debug"

set buildtype Debug for as requirement for "test"
add --debug and --release flags to travis-compile.sh

* make output prettier

edit the format warning message and clangify.sh output

* fix clangify.sh

fix --cf-version flag
fix directory argument parsing
add directory parsing details to --help
add examples to --help
This commit is contained in:
ebbit1q 2018-11-16 15:44:22 +01:00 committed by ctrlaltca
parent f70699d3de
commit 72ed98e404
5 changed files with 206 additions and 105 deletions

20
.ci/Dockerfile Normal file
View file

@ -0,0 +1,20 @@
FROM ubuntu:bionic
RUN apt-get update && apt-get install -y --no-install-recommends \
bc \
build-essential \
clang-format \
g++ \
git \
cmake \
libprotobuf-dev \
libqt5multimedia5-plugins \
libqt5svg5-dev \
libqt5sql5-mysql \
libqt5websockets5-dev \
protobuf-compiler \
qt5-default \
qttools5-dev \
qttools5-dev-tools \
qtmultimedia5-dev \
&& rm -rf /var/lib/apt/lists/*

View file

@ -1,59 +1,111 @@
#!/bin/bash
# This script is to be used in .travis.yaml from the project root directory, do not use it from somewhere else.
set -e
./servatrice/check_schema_version.sh
# Read arguments
while [[ "$@" ]]; do
case "$1" in
'--format')
CHECK_FORMAT=1
shift
;;
'--install')
MAKE_INSTALL=1
shift
;;
'--package')
MAKE_PACKAGE=1
shift
;;
'--server')
MAKE_SERVER=1
shift
;;
'--test')
MAKE_TEST=1
shift
;;
'--debug')
BUILDTYPE="Debug"
shift
;;
'--release')
BUILDTYPE="Release"
shift
;;
*)
BUILDTYPE="$1"
shift
;;
esac
done
# Check formatting using clang-format
if [[ $CHECK_FORMAT ]]; then
echo "Checking your code using clang-format..."
if ! diff="$(./clangify.sh --color-diff --cf-version)"; then
cat <<EOM
***********************************************************
*** ***
*** Your code does not comply with our styleguide. ***
*** ***
*** Please correct it or run the "clangify.sh" script. ***
*** Then commit and push those changes to this branch. ***
*** Check our CONTRIBUTING.md file for more details. ***
*** ***
*** Thank you ♥ ***
*** ***
***********************************************************
The following changes should be made:
$diff
Exiting...
EOM
exit 2
else
echo "Thank you for complying with our code standards."
fi
fi
# Setup
./servatrice/check_schema_version.sh
mkdir -p build
cd build
prefix=""
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
export PATH="/usr/local/opt/ccache/bin:$PATH"
prefix="-DCMAKE_PREFIX_PATH=$(echo /usr/local/opt/qt5/)"
# Add cmake flags
if [[ $MAKE_SERVER ]]; then
flags+=" -DWITH_SERVER=1"
fi
if [[ $TRAVIS_OS_NAME == "linux" ]]; then
prefix="-DCMAKE_PREFIX_PATH=$(echo /opt/qt5*/lib/cmake/)"
if [[ $MAKE_TEST ]]; then
flags+=" -DTEST=1"
BUILDTYPE="Debug" # test requires buildtype Debug
fi
if [[ $BUILDTYPE ]]; then
flags+=" -DCMAKE_BUILD_TYPE=$BUILDTYPE"
fi
# Add qt install location when using brew
if [[ $(uname) == "Darwin" ]]; then
PATH="/usr/local/opt/ccache/bin:$PATH"
flags+=" -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5/"
fi
# Compile
cmake --version
cmake .. $flags
make -j2
if [[ $BUILDTYPE == "Debug" ]]; then
cmake .. -DWITH_SERVER=1 -DCMAKE_BUILD_TYPE=$BUILDTYPE $prefix -DTEST=1
make -j2
if [[ $MAKE_TEST ]]; then
make test
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
make install
fi
if [[ $TRAVIS_OS_NAME == "linux" ]]; then
cd ..
clang-format -version
clang-format -i \
common/*.h \
common/*.cpp \
cockatrice/src/*.h \
cockatrice/src/*.cpp \
oracle/src/*.h \
oracle/src/*.cpp \
servatrice/src/*.h \
servatrice/src/*.cpp
git clean -f
git diff --quiet || (
echo "*****************************************************";
echo "*** This PR is not clean against our code style ***";
echo "*** Run clang-format and fix up any differences ***";
echo "*** Check our CONTRIBUTING.md file for details! ***";
echo "*** Thank you ♥ ***";
echo "*****************************************************";
)
git diff --exit-code
fi
fi
if [[ $BUILDTYPE == "Release" ]]; then
cmake .. -DWITH_SERVER=1 -DCMAKE_BUILD_TYPE=$BUILDTYPE $prefix
make package -j2
if [[ $MAKE_INSTALL ]]; then
make install
fi
if [[ $MAKE_PACKAGE ]]; then
make package
fi

View file

@ -1,9 +0,0 @@
#!/bin/bash
if [[ $TRAVIS_OS_NAME == "osx" ]] ; then
brew update
brew install ccache protobuf qt
fi
if [[ $TRAVIS_OS_NAME == "linux" ]] ; then
echo Skipping... packages are installed with the Travis apt addon for sudo disabled container builds
fi