From 121dd8cf90d359fb14c58d80b96562beaf3c011c Mon Sep 17 00:00:00 2001 From: lmat Date: Wed, 6 Sep 2017 13:23:59 -0400 Subject: [PATCH] Configure travis to use docker for CI Currently, there is an ubuntu 14.04 and archlinux build and they both use cmake with ninja, cmake with make, and autotools to build. It should be straightforward to add another configuration. Travis checks out the correct branch of the source code for us, and we expose that source code to the docker container using a docker run "volume". --- .travis.yml | 36 ++++++++++++++------------------- util/ci/afterfailure | 23 +++++++++++++++++++++ util/ci/arch-docker | 11 ++++++++++ util/ci/arch-testscript | 18 +++++++++++++++++ util/ci/commonbuild | 25 +++++++++++++++++++++++ util/ci/ubuntu-14.04-docker | 11 ++++++++++ util/ci/ubuntu-14.04-testscript | 8 ++++++++ util/travis-after-failure.sh | 19 ----------------- util/travis-script.sh | 30 --------------------------- 9 files changed, 111 insertions(+), 70 deletions(-) create mode 100755 util/ci/afterfailure create mode 100644 util/ci/arch-docker create mode 100644 util/ci/arch-testscript create mode 100644 util/ci/commonbuild create mode 100644 util/ci/ubuntu-14.04-docker create mode 100644 util/ci/ubuntu-14.04-testscript delete mode 100755 util/travis-after-failure.sh delete mode 100755 util/travis-script.sh diff --git a/.travis.yml b/.travis.yml index 64e663603b..374ea17ceb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,20 @@ # Test sudo: required -dist: trusty -branches: - except: - - trunk language: c++ -compiler: - - gcc -# - clang +compiler: gcc env: - - BUILDTYPE=cmake-make - - BUILDTYPE=cmake-ninja - - BUILDTYPE=autotools -before_install: -# - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - - sudo apt-get update -qq + - BUILDENV=arch BUILDTYPE=cmake-make + - BUILDENV=arch BUILDTYPE=cmake-ninja + - BUILDENV=arch BUILDTYPE=autotools + - BUILDENV=ubuntu-14.04 BUILDTYPE=cmake-make + - BUILDENV=ubuntu-14.04 BUILDTYPE=cmake-ninja + - BUILDENV=ubuntu-14.04 BUILDTYPE=autotools +services: + - docker install: -# - if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.9; export CXX="g++-4.9" CC="gcc-4.9"; fi - - sudo apt-get build-dep -qq gnucash - - sudo apt-get install -qq swig xsltproc libdbd-sqlite3 cmake3 texinfo ninja-build - - sudo apt-get install -qq libboost-all-dev libgtk-3-dev libwebkit2gtk-3.0-dev - - sudo apt-get --reinstall install -qq language-pack-en language-pack-fr - - git clone https://github.com/google/googletest -b release-1.8.0 ~/gtest -script: ./util/travis-script.sh -after_failure: ./util/travis-after-failure.sh + - docker --version + - echo BUILDENV="$BUILDENV" + - docker build -f util/ci/${BUILDENV}-docker -t ${BUILDENV}-gnucashbuild util/ci +script: + - echo BUILDTYPE="$BUILDTYPE" + - docker run -v "$(pwd)":/gnucash:rw --env="BUILDTYPE=$BUILDTYPE" --rm ${BUILDENV}-gnucashbuild diff --git a/util/ci/afterfailure b/util/ci/afterfailure new file mode 100755 index 0000000000..c71f7c7647 --- /dev/null +++ b/util/ci/afterfailure @@ -0,0 +1,23 @@ +#!/bin/bash + +if [[ "$BUILDTYPE" == "cmake-make" ]] || [[ "$BUILDTYPE" == "cmake-ninja" ]]; then + echo "########################"; + echo "##### LastTest.log #####"; + echo "########################"; + cat /build/Testing/Temporary/LastTest.log; +elif [[ "$BUILDTYPE" == "autotools" ]]; then + find . -name 'test*.log' -print0 | + while IFS= read -r -d '' logfile; do + SIZE=$((${#logfile} + 12)); + HRULE=$(head -c "$SIZE" < /dev/zero | tr '\0' '#'); + echo $HRULE; + echo "##### ${logfile} #####"; + echo $HRULE; + cat -- "$logfile"; + echo $'\n'$'\n'; + done; +else + echo "Unknown BUILDTYPE: \"$BUILDTYPE\", cannot create failure information."; +fi +# This script should fail so that the entire script will fail. +exit 1; diff --git a/util/ci/arch-docker b/util/ci/arch-docker new file mode 100644 index 0000000000..4d9bcc6723 --- /dev/null +++ b/util/ci/arch-docker @@ -0,0 +1,11 @@ +from base/archlinux +#run pacman -Syu --quiet --noconfirm > /dev/null +#run pacman -S --noconfirm archlinux-keyring +run pacman -Syu --quiet --noconfirm gcc cmake make autoconf automake boost python2 pkg-config guile2.0 guile git ninja gtest gmock sqlite3 webkit2gtk swig gwenhywfar aqbanking intltool libxslt postgresql-libs libmariadbclient libdbi libdbi-drivers > /dev/null +run echo en_US.UTF-8 UTF-8 >> /etc/locale.gen +run echo en_GB.UTF-8 UTF-8 >> /etc/locale.gen +run echo fr_FR.UTF-8 UTF-8 >> /etc/locale.gen +run locale-gen +copy arch-testscript afterfailure commonbuild / +run chmod +x /arch-testscript /afterfailure /commonbuild +entrypoint /arch-testscript diff --git a/util/ci/arch-testscript b/util/ci/arch-testscript new file mode 100644 index 0000000000..b97021d9b7 --- /dev/null +++ b/util/ci/arch-testscript @@ -0,0 +1,18 @@ +#!/bin/bash -le + +#-l above (login shell) so that /etc/profile runs so that perl is +# on the path. + +#-e so that if any command has an exit code != 0, this script will +# exit immediately. + +# Python is python 3, but gnucash doesn't work with python 3. There +# doesn't seem to be a way to tell automake to use /usr/bin/python2, +# so we'll mock this up +mkdir autotools_bin; +ln -s /usr/bin/python2 autotools_bin/python; +export PATH=/autotools_bin:"$PATH"; +echo path is "$PATH"; +echo python version is "$(python --version)"; + +../commonbuild diff --git a/util/ci/commonbuild b/util/ci/commonbuild new file mode 100644 index 0000000000..f94f9ffcf6 --- /dev/null +++ b/util/ci/commonbuild @@ -0,0 +1,25 @@ +#!/bin/bash -e + +mkdir build; +cd build; +export TZ="America/Los_Angeles"; + +mkdir -p /root/.local/share; + +if [[ "$BUILDTYPE" == "cmake-make" ]]; then + cmake ../gnucash + make -j 4; + make check || ../afterfailure; +elif [[ "$BUILDTYPE" == "cmake-ninja" ]]; then + cmake ../gnucash -DCMAKE_BUILD_TYPE=debug -DENABLE_DEBUG=on -G Ninja + ninja + ninja check || ../afterfailure; +elif [[ "$BUILDTYPE" == "autotools" ]]; then + ../gnucash/autogen.sh; + ../gnucash/configure --enable-python; + make; + make check || ../afterfailure; +else + echo "Unknown buildtype: \"$BUILDTYPE\". Not building."; +fi + diff --git a/util/ci/ubuntu-14.04-docker b/util/ci/ubuntu-14.04-docker new file mode 100644 index 0000000000..5609be442e --- /dev/null +++ b/util/ci/ubuntu-14.04-docker @@ -0,0 +1,11 @@ +from ubuntu:14.04 +#sudo apt-get install -qq software-properties-common +#sudo add-apt-repository -qq ppa:george-edison55/cmake-3.x +run apt-get update -qq +run apt-get build-dep -qq gnucash > /dev/null +run apt-get install -qq git bash-completion cmake3 make swig xsltproc libdbd-sqlite3 texinfo ninja-build libboost-all-dev libgtk-3-dev libwebkit2gtk-3.0-dev > /dev/null +run apt-get --reinstall install -qq language-pack-en language-pack-fr +run git clone https://github.com/google/googletest -b release-1.8.0 gtest +copy ubuntu-14.04-testscript afterfailure commonbuild / +run chmod +x /ubuntu-14.04-testscript /afterfailure /commonbuild +entrypoint /ubuntu-14.04-testscript diff --git a/util/ci/ubuntu-14.04-testscript b/util/ci/ubuntu-14.04-testscript new file mode 100644 index 0000000000..a5fe7aa383 --- /dev/null +++ b/util/ci/ubuntu-14.04-testscript @@ -0,0 +1,8 @@ +#!/bin/bash -e + +# -e above so that if any command has an exit code != 0, this script will +# exit immediately. + +export GTEST_ROOT=/gtest/googletest GMOCK_ROOT=/gtest/googlemock; + +../commonbuild diff --git a/util/travis-after-failure.sh b/util/travis-after-failure.sh deleted file mode 100755 index 64957def4b..0000000000 --- a/util/travis-after-failure.sh +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/bash - -# Build logs are located in different places depending on the build environment used -if [[ "$BUILDTYPE" == "cmake-make" ]] || [[ "$BUILDTYPE" == "cmake-ninja" ]]; then - echo "##### LastTest.log #####" - echo "#########################" - cat /tmp/gnucash-build-${BUILDTYPE}/Testing/Temporary/LastTest.log -elif [[ "$BUILDTYPE" == "autotools" ]]; then - for logfile in $( find . -name 'test*.log' ); do - SIZE=$((${#logfile} + 12)) - HRULE=$(head -c $SIZE < /dev/zero | tr '\0' '#') - echo $HRULE - echo "##### ${logfile} #####" - echo $HRULE - cat -- "$logfile" - echo -e "\n\n" - done -fi - diff --git a/util/travis-script.sh b/util/travis-script.sh deleted file mode 100755 index 8e14edd608..0000000000 --- a/util/travis-script.sh +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/bash -ev -# The -e above says that if any line below fails, the whole script fails - -# Run tests in different build configurations depending on the -# value of the BUILDTYPE environment variable -# 1. cmake build using the default Makefile generator -if [[ "$BUILDTYPE" == "cmake-make" ]]; then - mkdir /tmp/gnucash-build-cmake-make - cd /tmp/gnucash-build-cmake-make - GTEST_ROOT=~/gtest/googletest GMOCK_ROOT=~/gtest/googlemock cmake $TRAVIS_BUILD_DIR - make -j 4 - TZ="America/Los_Angeles" make check - -# 2. cmake build using the Ninja generator -elif [[ "$BUILDTYPE" == "cmake-ninja" ]]; then - mkdir /tmp/gnucash-build-cmake-ninja - cd /tmp/gnucash-build-cmake-ninja - GTEST_ROOT=~/gtest/googletest GMOCK_ROOT=~/gtest/googlemock cmake -G Ninja $TRAVIS_BUILD_DIR - ninja - TZ="America/Los_Angeles" ninja check - -# 3. autotools build -elif [[ "$BUILDTYPE" == "autotools" ]]; then - cd $TRAVIS_BUILD_DIR - ./autogen.sh - ./configure --enable-python GTEST_ROOT=~/gtest/googletest GMOCK_ROOT=~/gtest/googlemock - make - TZ="America/Los_Angeles" make check -fi -