diff --git a/.ci/after_success.sh b/.ci/after_success.sh index 7aaae203c..50376677c 100755 --- a/.ci/after_success.sh +++ b/.ci/after_success.sh @@ -6,7 +6,8 @@ source "${CI_DIR}/common.sh" set +e -if [ "${TRAVIS_PULL_REQUEST}" = false ] && [ "${TRAVIS_BRANCH}" = 'master' ]; then +# if [ "${TRAVIS_PULL_REQUEST}" = false ] && [ "${TRAVIS_BRANCH}" = 'master' ]; then +if [ -z "${CIRCLE_PULL_REQUEST}" ] && [ "${CIRCLE_BRANCH}" = 'master' ]; then travis_retry luarocks --local install ldoc # get deploy key for doc repo openssl aes-256-cbc -k "${doc_build_secret:?}" -in .ci/koreader_doc.enc -out ~/.ssh/koreader_doc -d diff --git a/.ci/before_install.sh b/.ci/before_install.sh index ba9ee7671..f302b7168 100755 --- a/.ci/before_install.sh +++ b/.ci/before_install.sh @@ -8,10 +8,10 @@ fi 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 c++)" bin/c++ ln -s "$(which g++-4.8)" bin/g++ # Travis only makes a shallow clone of --depth=50. KOReader is small enough that # we can just grab it all. This is necessary to generate the version number, # without which some tests will fail. -git fetch --unshallow +# git fetch --unshallow diff --git a/.ci/build.sh b/.ci/build.sh new file mode 100755 index 000000000..04e486302 --- /dev/null +++ b/.ci/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=/dev/null +source "${CI_DIR}/common.sh" + +make all diff --git a/.ci/check.sh b/.ci/check.sh new file mode 100755 index 000000000..cc5d6fcb4 --- /dev/null +++ b/.ci/check.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=/dev/null +source "${CI_DIR}/common.sh" + +echo -e "\n${ANSI_GREEN}shellcheck results" +"${CI_DIR}/helper_shellchecks.sh" + +echo -e "\\n${ANSI_GREEN}Checking for unscaled sizes" +# stick `|| true` at the end to prevent Travis exit on failed command +unscaled_size_check=$(grep -nr --include=*.lua --exclude=koptoptions.lua --exclude-dir=base --exclude-dir=install --exclude-dir=keyboardlayouts --exclude-dir=*arm* "\\(padding\\|margin\\|bordersize\\|width\\|height\\|radius\\|linesize\\) = [0-9]\\{1,2\\}" | grep -v '= 0' | grep -v '= [0-9]/[0-9]' | grep -Ev '(default_option_height|default_option_padding)' | grep -v scaleBySize || true) +# Also check Geom objects; for legibility two regular expressions rather than +# one enormous indecipharable blob. +unscaled_size_check_geom=$(grep -E -nr --include=*.lua --exclude=gesturerange_spec.lua --exclude-dir=base --exclude-dir=*arm* 'Geom:new{.+ [wh] = [0-9]{1,4}' | grep -Ev '[wh] = 0' | grep -v '= [0-9]/[0-9]' | grep -v scaleBySize || true) + +if [ "${unscaled_size_check}" ] || [ "${unscaled_size_check_geom}" ]; then + echo -e "\\n${ANSI_RED}Warning: it looks like you might be using unscaled sizes.\\nIt is almost always preferable to defer to one of the predefined sizes in ui.elements.commonui in the following files:" + echo "${unscaled_size_check}" + echo "${unscaled_size_check_geom}" + exit 1 +fi + +echo -e "\n${ANSI_GREEN}Luacheck results" +luajit "$(which luacheck)" --no-color -q {reader,setupkoenv,datastorage}.lua frontend plugins spec diff --git a/.ci/common.sh b/.ci/common.sh old mode 100644 new mode 100755 index 2fa297541..121dca15a --- a/.ci/common.sh +++ b/.ci/common.sh @@ -61,9 +61,15 @@ retry_cmd() { return $result } -export PATH=$PWD/bin:$PATH -export PATH=$PATH:${TRAVIS_BUILD_DIR}/install/bin -if [ -f "${TRAVIS_BUILD_DIR}/install/bin/luarocks" ]; then +# export CI_BUILD_DIR=${TRAVIS_BUILD_DIR} +# use eval to get fully expanded path +eval CI_BUILD_DIR="${CIRCLE_WORKING_DIRECTORY}" +export CI_BUILD_DIR + +test -e "${HOME}/bin" || mkdir "${HOME}/bin" +export PATH=$PWD/bin:$HOME/bin:$PATH +export PATH=$PATH:${CI_BUILD_DIR}/install/bin +if [ -f "${CI_BUILD_DIR}/install/bin/luarocks" ]; then # add local rocks to $PATH eval "$(luarocks path --bin)" fi diff --git a/.ci/fetch.sh b/.ci/fetch.sh new file mode 100755 index 000000000..acaf5f377 --- /dev/null +++ b/.ci/fetch.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=/dev/null +source "${CI_DIR}/common.sh" + +travis_retry make fetchthirdparty diff --git a/.ci/helper_luarocks.sh b/.ci/helper_luarocks.sh index c50221f5f..d21becfa0 100755 --- a/.ci/helper_luarocks.sh +++ b/.ci/helper_luarocks.sh @@ -6,7 +6,7 @@ source "${CI_DIR}/common.sh" rm -rf "${HOME}/.luarocks" mkdir "${HOME}/.luarocks" -cp "${TRAVIS_BUILD_DIR}/install/etc/luarocks/config.lua" "${HOME}/.luarocks/config.lua" +cp "${CI_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 # for verbose_print module diff --git a/.ci/install.sh b/.ci/install.sh index a1e8c1cf8..e199c73a4 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -5,7 +5,7 @@ CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${CI_DIR}/common.sh" # print some useful info -echo "TRAVIS_BUILD_DIR: ${TRAVIS_BUILD_DIR}" +echo "BUILD_DIR: ${CI_BUILD_DIR}" echo "pwd: $(pwd)" ls @@ -24,11 +24,12 @@ else fi # install our own updated luarocks -if [ ! -f "${TRAVIS_BUILD_DIR}/install/bin/luarocks" ]; then +echo "luarocks installation path: ${CI_BUILD_DIR}" +if [ ! -f "${CI_BUILD_DIR}/install/bin/luarocks" ]; then 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" + cmake . -DWITH_LUAJIT21=ON -DCMAKE_INSTALL_PREFIX="${CI_BUILD_DIR}/install" make install } || exit popd @@ -38,6 +39,10 @@ fi if [ ! -d "${HOME}/.luarocks" ] || [ ! -f "${HOME}/.luarocks/$(md5sum <"${CI_DIR}/helper_luarocks.sh")" ]; then echo -e "${ANSI_GREEN}Grabbing new .luarocks." + sudo apt-get update + # install openssl devel for luasec + sudo apt-get -y install libssl-dev + "${CI_DIR}/helper_luarocks.sh" touch "${HOME}/.luarocks/$(md5sum <"${CI_DIR}/helper_luarocks.sh")" else diff --git a/.ci/script.sh b/.ci/script.sh index 7ede9ad0f..60bb19b52 100755 --- a/.ci/script.sh +++ b/.ci/script.sh @@ -5,28 +5,13 @@ CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${CI_DIR}/common.sh" echo -e "\\n${ANSI_GREEN}make fetchthirdparty" -travis_retry make fetchthirdparty +bash "${CI_DIR}/fetch.sh" -"${CI_DIR}/helper_shellchecks.sh" - -echo -e "\\n${ANSI_GREEN}Checking for unscaled sizes" -# stick `|| true` at the end to prevent Travis exit on failed command -unscaled_size_check=$(grep -nr --include=*.lua --exclude=koptoptions.lua --exclude-dir=base --exclude-dir=install --exclude-dir=keyboardlayouts --exclude-dir=*arm* "\\(padding\\|margin\\|bordersize\\|width\\|height\\|radius\\|linesize\\) = [0-9]\\{1,2\\}" | grep -v '= 0' | grep -v '= [0-9]/[0-9]' | grep -Ev '(default_option_height|default_option_padding)' | grep -v scaleBySize || true) -# Also check Geom objects; for legibility two regular expressions rather than -# one enormous indecipharable blob. -unscaled_size_check_geom=$(grep -E -nr --include=*.lua --exclude=gesturerange_spec.lua --exclude-dir=base --exclude-dir=*arm* 'Geom:new{.+ [wh] = [0-9]{1,4}' | grep -Ev '[wh] = 0' | grep -v '= [0-9]/[0-9]' | grep -v scaleBySize || true) - -if [ "${unscaled_size_check}" ] || [ "${unscaled_size_check_geom}" ]; then - echo -e "\\n${ANSI_RED}Warning: it looks like you might be using unscaled sizes.\\nIt is almost always preferable to defer to one of the predefined sizes in ui.size in the following files:" - echo "${unscaled_size_check}" - echo "${unscaled_size_check_geom}" - exit 1 -fi - -echo -e "\\n${ANSI_GREEN}Luacheck results" -luajit "$(which luacheck)" --no-color -q {reader,setupkoenv,datastorage}.lua frontend plugins spec +echo -e "\\n${ANSI_GREEN}static checks" +bash "${CI_DIR}/check.sh" echo -e "\\n${ANSI_GREEN}make all" -make all +bash "${CI_DIR}/build.sh" + echo -e "\\n${ANSI_GREEN}make testfront" -make testfront +bash "${CI_DIR}/test.sh" diff --git a/.ci/test.sh b/.ci/test.sh new file mode 100755 index 000000000..66202f500 --- /dev/null +++ b/.ci/test.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=/dev/null +source "${CI_DIR}/common.sh" + +make testfront diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..75e14f889 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,52 @@ +version: 2 +jobs: + build: + docker: + - image: houqp/kobase:0.0.5 + environment: + EMULATE_READER: 1 + steps: + - checkout + - restore_cache: + keys: + - deps + - build + - run: echo 'export PATH=${HOME}/bin:${PATH}' >> $BASH_ENV + + - run: + name: setup + command: .ci/before_install.sh + - run: + name: install + command: .ci/install.sh + - run: + name: fetch + command: .ci/fetch.sh + - run: + name: check + command: .ci/check.sh + - run: + name: build + command: .ci/build.sh + - run: + name: test + command: .ci/test.sh + - run: + name: cleanup + command: .ci/after_success.sh + + - run: + name: clean up cache + command: rm -frv ./base/build/*/{spec,cache/*} + - save_cache: + key: build + paths: + - "/home/ko/.ccache" + - "base" + - save_cache: + key: deps + paths: + - "/home/ko/bin" + - "/home/ko/.luarocks" + # compiled luarocks binaries + - "install" diff --git a/README.md b/README.md index 6629f45e7..4859962dd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status][travis-badge]][travis-link] +[![Build Status][circleci-badge]][circleci-link] [![Coverage Status][coverage-badge]][coverage-link] [![AGPL Licence][licence-badge]](COPYING) KOReader @@ -174,7 +174,7 @@ make static-check NOTE: Extra dependencies for tests: `luacheck` from luarocks -You may need to checkout the [travis config file][travis-conf] to setup up +You may need to checkout the [circleci config file][circleci-conf] to setup up a proper testing environment. Briefly, you need to install `luarocks` and then install `busted` with `luarocks`. The "eng" language data file for tesseract-ocr is also need to test OCR functionality. Finally, make sure @@ -294,9 +294,9 @@ http://ccache.samba.org [base-readme]:https://github.com/koreader/koreader-base/blob/master/README.md [nb-script]:https://gitlab.com/koreader/nightly-builds/blob/master/build_release.sh -[travis-badge]:https://travis-ci.org/koreader/koreader.svg?branch=master -[travis-link]:https://travis-ci.org/koreader/koreader -[travis-conf]:https://github.com/koreader/koreader-base/blob/master/.travis.yml +[circleci-badge]:https://circleci.com/gh/koreader/koreader.svg?style=svg +[circleci-link]:https://circleci.com/gh/koreader/koreader +[circleci-conf]:https://github.com/koreader/koreader-base/blob/master/.circleci/config.yml [linux-vm]:http://www.howtogeek.com/howto/11287/how-to-run-ubuntu-in-windows-7-with-vmware-player/ [l10n-readme]:https://github.com/koreader/koreader/blob/master/l10n/README.md [koreader-transifex]:https://www.transifex.com/projects/p/koreader/