diff --git a/.ci/after_success.sh b/.ci/after_success.sh new file mode 100755 index 000000000..64709c2a5 --- /dev/null +++ b/.ci/after_success.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +make coverage +cd koreader-*/koreader && luajit $(which luacov-coveralls) -v + +# get deploy key for doc repo +openssl aes-256-cbc -K $encrypted_dc71a4fb8382_key -iv $encrypted_dc71a4fb8382_iv \ + -in .ci/koreader_doc.enc -out ~/.ssh/koreader_doc -d +ssh-add ~/.ssh/koreader_doc +git clone git@github.com:koreader/doc.git +# push doc update +make doc +cp -r doc/html/* doc/ +pushd doc +git add . +git push origin gh-pages diff --git a/.ci/before_install.sh b/.ci/before_install.sh new file mode 100755 index 000000000..97eee7d67 --- /dev/null +++ b/.ci/before_install.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# don't do this for clang +if [ "$CXX" = "g++" ]; + then export CXX="g++-4.8" CC="gcc-4.8"; +fi +# in case anything ignores the environment variables, override through PATH +mkdir bin +ln -s $(which gcc-4.8) bin/cc +ln -s $(which gcc-4.8) bin/gcc +ln -s $(which c++-4.8) bin/c++ +ln -s $(which g++-4.8) bin/g++ diff --git a/.ci/common.sh b/.ci/common.sh new file mode 100644 index 000000000..7fbabd4e3 --- /dev/null +++ b/.ci/common.sh @@ -0,0 +1,32 @@ +ANSI_RED="\033[31;1m" +ANSI_GREEN="\033[32;1m" +ANSI_RESET="\033[0m" +ANSI_CLEAR="\033[0K" + +travis_retry() { + local result=0 + local count=1 + while [ $count -le 3 ]; do + [ $result -ne 0 ] && { + echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2 + } + "$@" + result=$? + [ $result -eq 0 ] && break + count=$(($count + 1)) + sleep 1 + done + + [ $count -gt 3 ] && { + echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2 + } + + return $result +} + +export PATH=$PWD/bin:$PATH +export PATH=$PATH:${TRAVIS_BUILD_DIR}/install/bin +if [ -f ${TRAVIS_BUILD_DIR}/install/bin/luarocks ]; then + # add local rocks to $PATH + eval $(luarocks path --bin) +fi diff --git a/.ci/install.sh b/.ci/install.sh new file mode 100755 index 000000000..95e7ca261 --- /dev/null +++ b/.ci/install.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${CI_DIR}/common.sh" + +# install our own updated luarocks +git clone https://github.com/torch/luajit-rocks.git +pushd luajit-rocks + git checkout 6529891 + cmake . -DWITH_LUAJIT21=ON -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/install + make install +popd + +mkdir $HOME/.luarocks +cp ${TRAVIS_BUILD_DIR}/install/etc/luarocks/config.lua $HOME/.luarocks/config.lua +echo "wrap_bin_scripts = false" >> $HOME/.luarocks/config.lua +travis_retry luarocks --local install luafilesystem +travis_retry luarocks --local install ansicolors +travis_retry luarocks --local install busted 2.0.rc11-0 +#- travis_retry luarocks --local install busted 1.11.1-1 +#- mv -f $HOME/.luarocks/bin/busted_bootstrap $HOME/.luarocks/bin/busted +travis_retry luarocks --local install luacov +# luasec doesn't automatically detect 64-bit libs +travis_retry luarocks --local install luasec OPENSSL_LIBDIR=/usr/lib/x86_64-linux-gnu +travis_retry luarocks --local install luacov-coveralls --server=http://rocks.moonscript.org/dev +travis_retry luarocks --local install luacheck +travis_retry luarocks --local install lanes # for parallel luacheck +travis_retry luarocks --local install ldoc diff --git a/.ci/koreader_doc.enc b/.ci/koreader_doc.enc new file mode 100644 index 000000000..c841e5e0c Binary files /dev/null and b/.ci/koreader_doc.enc differ diff --git a/.ci/script.sh b/.ci/script.sh new file mode 100755 index 000000000..16042e7f2 --- /dev/null +++ b/.ci/script.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${CI_DIR}/common.sh" + +travis_retry make fetchthirdparty +make all +travis_retry make testfront +luajit $(which luacheck) --no-color -q frontend | tee ./luacheck.out +test $(grep Total ./luacheck.out | awk '{print $2}') -le 63 diff --git a/.travis.yml b/.travis.yml index cece9136b..2dc6ca0a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,3 @@ -# Travis-CI Build for koreader -# see travis-ci.org for details - language: c sudo: false @@ -29,50 +26,7 @@ addons: # OpenSSL likes this (package contains makedepend) - xutils-dev -before_install: - # don't do this for clang - - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi - # in case anything ignores the environment variables, override through PATH - - mkdir bin - - ln -s $(which gcc-4.8) bin/cc - - ln -s $(which gcc-4.8) bin/gcc - - ln -s $(which c++-4.8) bin/c++ - - ln -s $(which g++-4.8) bin/g++ - - export PATH=$PWD/bin:$PATH - -install: - # install our own updated luarocks - - git clone https://github.com/torch/luajit-rocks.git - - pushd luajit-rocks - - git checkout 6529891 - - cmake . -DWITH_LUAJIT21=ON -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/install - - make install - - popd - - export PATH=$PATH:${TRAVIS_BUILD_DIR}/install/bin - - mkdir $HOME/.luarocks - - cp ${TRAVIS_BUILD_DIR}/install/etc/luarocks/config.lua $HOME/.luarocks/config.lua - - echo "wrap_bin_scripts = false" >> $HOME/.luarocks/config.lua - - travis_retry luarocks --local install luafilesystem - - travis_retry luarocks --local install ansicolors - - travis_retry luarocks --local install busted 2.0.rc11-0 - #- travis_retry luarocks --local install busted 1.11.1-1 - #- mv -f $HOME/.luarocks/bin/busted_bootstrap $HOME/.luarocks/bin/busted - - travis_retry luarocks --local install luacov - # luasec doesn't automatically detect 64-bit libs - - travis_retry luarocks --local install luasec OPENSSL_LIBDIR=/usr/lib/x86_64-linux-gnu - - travis_retry luarocks --local install luacov-coveralls --server=http://rocks.moonscript.org/dev - - travis_retry luarocks --local install luacheck - - travis_retry luarocks --local install lanes # for parallel luacheck - # add local rocks to $PATH - - eval $(luarocks path --bin) - -script: - - travis_retry make fetchthirdparty - - make all - - travis_retry make testfront - - luajit $(which luacheck) --no-color -q frontend | tee ./luacheck.out - - test $(grep Total ./luacheck.out | awk '{print $2}') -le 63 - -after_success: - - make coverage - - cd koreader-*/koreader && luajit $(which luacov-coveralls) -v +before_install: .ci/before_install.sh +install: .ci/install.sh +script: .ci/script.sh +after_success: .ci/after_success.sh