diff --git a/.ci/install.sh b/.ci/install.sh index e09aee37172b5751da6d5d4d6bf7222cb9602e04..078560c21df5d249b0b11df928a9c84ec8823386 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -7,26 +7,3 @@ if [ $TRAVIS_OS_NAME == osx ]; then brew upgrade boost cmake brew install libsodium fi - -if [ $TRAVIS_OS_NAME == linux ]; then - export CXX=${CXX_VERSION} - export CC=${CC_VERSION} - - sudo apt-get update -qq - sudo apt-get remove -y cmake - - # Build & install libsodium for source. - mkdir -p libsodium && pushd libsodium - curl -L \ - https://download.libsodium.org/libsodium/releases/libsodium-${LIBSODIUM_VERSION}.tar.gz \ - -o libsodium-${LIBSODIUM_VERSION}.tar.gz - tar xfz libsodium-${LIBSODIUM_VERSION}.tar.gz - pushd libsodium-${LIBSODIUM_VERSION}/ - ./configure && make && make check && sudo make install - popd - popd - - wget https://cmake.org/files/v3.11/cmake-3.11.4-Linux-x86_64.sh - sudo sh cmake-3.11.4-Linux-x86_64.sh --skip-license --prefix=/usr/local - export PATH="/usr/local/bin:$PATH" -fi diff --git a/.ci/script.sh b/.ci/script.sh index 5f9f5259d8a8ef3be92e9c4d4b585ef3ce71880c..05208e7d34ff9e2780fed048704e276eb9e4b1ab 100755 --- a/.ci/script.sh +++ b/.ci/script.sh @@ -11,29 +11,30 @@ if [ $TRAVIS_OS_NAME == linux ]; then sudo update-alternatives --set gcc "/usr/bin/${CC_VERSION}" sudo update-alternatives --set g++ "/usr/bin/${CXX_VERSION}" -fi -# Build dependencies. -cmake -Hdeps -B.deps -DCMAKE_BUILD_TYPE=Release \ - -DUSE_BUNDLED_BOOST=${USE_BUNDLED_BOOST} \ - -DUSE_BUNDLED_GTEST=${TESTS} -cmake --build .deps - -# Build the library. -cmake -H. -Bbuild -DOPENSSL_ROOT_DIR=${OPENSLL_ROOT_DIR} \ - -DBUILD_LIB_TESTS=${TESTS} \ - -DBUILD_SHARED_LIBS=ON \ - -DCMAKE_INSTALL_PREFIX=.deps/usr \ - -DCOVERAGE=${COVERAGE} || true -cmake --build build - -# Unit & Integration tests -if [ $TESTS == ON ]; then - make synapse + # Build the library. + cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug \ + -DBUILD_LIB_TESTS=ON \ + -DBUILD_SHARED_LIBS=ON \ + -DCOVERAGE=${COVERAGE} || true + cmake --build build + make test fi -# Linting -if [ $LINT == ON ]; then +if [ $TRAVIS_OS_NAME == osx ]; then + # Build dependencies. + cmake -Hdeps -B.deps -DCMAKE_BUILD_TYPE=Release \ + -DUSE_BUNDLED_BOOST=OFF \ + -DUSE_BUNDLED_GTEST=OFF + cmake --build .deps + + # Build the library. + cmake -H. -Bbuild -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl \ + -DBUILD_LIB_TESTS=OFF \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_INSTALL_PREFIX=.deps/usr || true + cmake --build build + make lint fi diff --git a/.travis.yml b/.travis.yml index e4f87a21828cea54297da3e7b94be1ba9f19e249..cc0b84785b058d30b7b483e44cf2bef14e59620d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,47 +10,36 @@ services: notifications: email: false +before_cache: + # Save tagged docker images + - > + mkdir -p $HOME/docker && docker images -a --filter='dangling=false' --format '{{.Repository}}:{{.Tag}} {{.ID}}' + | xargs -n 2 -t sh -c 'test -e $HOME/docker/$1.tar.gz || docker save $0 | gzip -2 > $HOME/docker/$1.tar.gz' + +cache: + directories: + - $HOME/docker + matrix: include: - os: osx osx_image: xcode9 compiler: clang - env: - - OPENSLL_ROOT_DIR=/usr/local/opt/openssl - - TESTS=OFF - - USE_BUNDLED_BOOST=OFF - os: linux compiler: gcc env: - CXX_VERSION=g++-8 - CC_VERSION=gcc-8 - - TESTS=ON - COVERAGE=ON - - USE_BUNDLED_BOOST=ON - - LIBSODIUM_VERSION=1.0.16 - addons: - apt: - sources: - - "ubuntu-toolchain-r-test" - packages: - - "g++-8" - - "lcov" - os: linux compiler: clang env: - CXX_VERSION=clang++-6.0 - CC_VERSION=clang-6.0 - - TESTS=ON - - USE_BUNDLED_BOOST=ON - - LIBSODIUM_VERSION=1.0.16 - addons: - apt: - sources: - - "ubuntu-toolchain-r-test" - - "llvm-toolchain-trusty-6.0" - packages: - - "clang++-6.0" - - "clang-6.0" + +before_install: + # Load cached docker images + - if [[ -d $HOME/docker ]]; then ls $HOME/docker/*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi install: - ./.ci/install.sh @@ -59,10 +48,33 @@ script: - $CXX --version - cmake --version - - ./.ci/script.sh + # Start the synapse server to run the tests. + - if [ $TRAVIS_OS_NAME == linux ]; then make synapse; fi + + # Build the lib and run the test suite against synapse. + - | + if [ $TRAVIS_OS_NAME == linux ]; then + docker run -v `pwd`:/build --net=host \ + -e CXX_VERSION=${CXX_VERSION} \ + -e CC_VERSION=${CC_VERSION} \ + -e COVERAGE=${COVERAGE} \ + -e TRAVIS_OS_NAME=${TRAVIS_OS_NAME} \ + mujx/mtxclient-dev:0.1.0 \ + /bin/bash -c "./.ci/script.sh" + fi + + # Build the lib and run the linter. + - | + if [ $TRAVIS_OS_NAME == osx ]; then + ./.ci/script.sh + fi after_success: # Generate coverage report and upload report to CodeCov. - - if [ $COVERAGE == ON ]; then make -C build/tests matrix_client_coverage; fi - - if [ $COVERAGE == ON ]; then ./.ci/coverage.sh; fi - - if [ $COVERAGE == ON ]; then bash <(curl -s https://codecov.io/bash) -f "!*tests*" || echo "Codecov failed"; fi + - | + if [ $COVERAGE == ON ]; then + docker run -v `pwd`:/build \ + --net=host mujx/mtxclient-dev:0.1.0 \ + /bin/bash -c "./.ci/coverage.sh" && \ + bash <(curl -s https://codecov.io/bash) -f "!*tests*" || echo "Codecov failed" + fi diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2052498534492ac0e76c9135e7e8d6b84fb720aa..d3043006ae1ac101c7be8e2e7fe6657a6b186d6c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,7 +1,5 @@ enable_testing() -file(COPY fixtures DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - find_package(GTest REQUIRED) file(COPY fixtures DESTINATION ${CMAKE_CURRENT_BINARY_DIR})