From 53c0756defd9ef6b7a02406c0c69a39b5d1f187e Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Wed, 11 Oct 2017 08:38:30 +0200 Subject: [PATCH] CircleCI: finishing touches (#3340) * junit test results; unfortunately this seems to conflict with the verbose out * fix deps cache: two files can change independently * verbose print obsoleted by gtest in upsream busted --- .ci/after_success.sh | 61 ++++++++++++++++++++----------------- .ci/test.sh | 8 +++-- .circleci/config.yml | 11 ++++--- Makefile | 3 +- spec/unit/verbose_print.lua | 22 ------------- 5 files changed, 47 insertions(+), 58 deletions(-) delete mode 100644 spec/unit/verbose_print.lua diff --git a/.ci/after_success.sh b/.ci/after_success.sh index 3632260f6..fe643e9c0 100755 --- a/.ci/after_success.sh +++ b/.ci/after_success.sh @@ -6,37 +6,42 @@ source "${CI_DIR}/common.sh" set +e -echo "CIRCLE_NODE_INDEX: ${CIRCLE_NODE_INDEX}" -if [ ! "$CIRCLE_NODE_INDEX" = 0 ]; then - echo -e "\\n${ANSI_GREEN}Not on first node. Skipping documentation update and coverage." -elif [ -z "${CIRCLE_PULL_REQUEST}" ] && [ "${CIRCLE_BRANCH}" = 'master' ]; then - echo -e "\\n${ANSI_GREEN}Checking out koreader/doc for update." - git clone git@github.com:koreader/doc.git koreader_doc +if [ -z "${CIRCLE_PULL_REQUEST}" ] && [ "${CIRCLE_BRANCH}" = 'master' ]; then + echo "CIRCLE_NODE_INDEX: ${CIRCLE_NODE_INDEX}" + if [ "$CIRCLE_NODE_INDEX" = 1 ]; then + echo -e "\\n${ANSI_GREEN}Checking out koreader/doc for update." + git clone git@github.com:koreader/doc.git koreader_doc - # push doc update - pushd doc && { - luajit "$(which ldoc)" . 2>/dev/null - if [ ! -d html ]; then - echo "Failed to generate documents..." - exit 1 - fi - } && popd || exit + # push doc update + pushd doc && { + luajit "$(which ldoc)" . 2>/dev/null + if [ ! -d html ]; then + echo "Failed to generate documents..." + exit 1 + fi + } && popd || exit - cp -r doc/html/* koreader_doc/ - pushd koreader_doc && { - git add -A - echo -e "\\n${ANSI_GREEN}Pushing document update..." - git -c user.name="KOReader build bot" -c user.email="non-reply@koreader.rocks" \ - commit -a --amend -m 'Automated documentation build from travis-ci.' - git push -f --quiet origin gh-pages >/dev/null - echo -e "\\n${ANSI_GREEN}Documentation update pushed." - } && popd || exit + cp -r doc/html/* koreader_doc/ + pushd koreader_doc && { + git add -A + echo -e "\\n${ANSI_GREEN}Pushing document update..." + git -c user.name="KOReader build bot" -c user.email="non-reply@koreader.rocks" \ + commit -a --amend -m 'Automated documentation build from travis-ci.' + git push -f --quiet origin gh-pages >/dev/null + echo -e "\\n${ANSI_GREEN}Documentation update pushed." + } && popd || exit - travis_retry make coverage - pushd koreader-*/koreader && { - # see https://github.com/codecov/example-lua - bash <(curl -s https://codecov.io/bash) - } && popd || exit + echo -e "\\n${ANSI_GREEN}Running make testfront for timings." + make testfront BUSTED_OVERRIDES="--output=junit -Xoutput junit-test-results.xml" + fi + + if [ "$CIRCLE_NODE_INDEX" = 0 ]; then + travis_retry make coverage + pushd koreader-*/koreader && { + # see https://github.com/codecov/example-lua + bash <(curl -s https://codecov.io/bash) + } && popd || exit + fi else echo -e "\\n${ANSI_GREEN}Not on official master branch. Skipping documentation update and coverage." fi diff --git a/.ci/test.sh b/.ci/test.sh index eda41a929..47fda1d70 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -5,6 +5,8 @@ CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${CI_DIR}/common.sh" pushd koreader-emulator-x86_64-linux-gnu/koreader && { - circleci tests glob "spec/front/unit/*_spec.lua" | circleci tests split --split-by=timings --timings-type=filename | xargs -I{} sh -c 'make -C ../.. testfront BUSTED_SPEC_FILE="{}" || exit 255' -} && popd -#make testfront + # the circleci command spits out newlines; we want spaces instead + BUSTED_SPEC_FILE="$(circleci tests glob "spec/front/unit/*_spec.lua" | circleci tests split --split-by=timings --timings-type=filename | tr '\n' ' ')" +} && popd || exit + +make testfront BUSTED_SPEC_FILE="${BUSTED_SPEC_FILE}" diff --git a/.circleci/config.yml b/.circleci/config.yml index a8782e387..273baf9da 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,13 +7,13 @@ jobs: EMULATE_READER: 1 # this is for shellcheck 0.4.5 and lower; can be removed for 0.4.6 LC_ALL: en_US.UTF8 - parallelism: 3 + parallelism: 2 steps: - checkout - restore_cache: keys: # binary dependencies require {{ arch }} because there are different CPUs in use on the servers - - deps-{{ arch }}-{{ checksum ".ci/install.sh" }} + - deps-{{ arch }}-{{ checksum ".ci/install.sh" }}-{{ checksum ".ci/helper_luarocks.sh" }} # need to init some stuff first or git will complain when sticking in base cache - run: git submodule init base && git submodule update base && pushd base && git submodule init && git submodule update && popd # we can't use command output directly for cache check so we write it to git-rev-base @@ -31,7 +31,7 @@ jobs: name: install command: .ci/install.sh - save_cache: - key: deps-{{ arch }}-{{ checksum ".ci/install.sh" }} + key: deps-{{ arch }}-{{ checksum ".ci/install.sh" }}-{{ checksum ".ci/helper_luarocks.sh" }} paths: - "/home/ko/bin" - "/home/ko/.luarocks" @@ -60,7 +60,10 @@ jobs: name: test command: .ci/test.sh - # docs and coverage, master branch only + # docs, coverage, and test timing (can we use two outputs at once?); master branch only - run: name: docs-and-coverage command: .ci/after_success.sh + # by storing the test results CircleCI automatically distributes tests based on execution time + - store_test_results: + path: koreader-emulator-x86_64-linux-gnu/koreader/junit-test-results.xml diff --git a/Makefile b/Makefile index eefda6931..0acb68dc2 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,8 @@ testfront: $(INSTALL_DIR)/koreader/.busted cd $(INSTALL_DIR)/koreader && ./luajit $(shell which busted) \ --sort-files \ --no-auto-insulate \ - -o verbose_print --exclude-tags=notest $(BUSTED_SPEC_FILE) + --output=gtest \ + --exclude-tags=notest $(BUSTED_OVERRIDES) $(BUSTED_SPEC_FILE) test: $(INSTALL_DIR)/koreader/.busted $(MAKE) -C $(KOR_BASE) test diff --git a/spec/unit/verbose_print.lua b/spec/unit/verbose_print.lua deleted file mode 100644 index f194a8dbe..000000000 --- a/spec/unit/verbose_print.lua +++ /dev/null @@ -1,22 +0,0 @@ --- from Mashape/kong/spec/busted-print.lua -local ansicolors = require 'ansicolors' - -return function(options) - local handler = require 'busted.outputHandlers.utfTerminal'(options) - - handler.fileStart = function(file) - io.write('\n' .. ansicolors('%{cyan}' .. file.name) .. ':') - end - - handler.testStart = function(element, parent, status, debug) - io.write('\n ' .. handler.getFullName(element) .. ' ... ') - io.flush() - end - - local busted = require 'busted' - - busted.subscribe({ 'file', 'start' }, handler.fileStart) - busted.subscribe({ 'test', 'start' }, handler.testStart) - - return handler -end