From b42e6fd4dabe8baca4f56451a478619c4eec1502 Mon Sep 17 00:00:00 2001 From: Alistair Brown Date: Sat, 27 Oct 2018 17:26:31 +0100 Subject: [PATCH] Update travis output with timings --- .travis.yml | 8 +----- test.sh | 76 +++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce4880d4..efbb845f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ sudo: required install: - npm install -- npm install danger -g cache: directories: @@ -69,16 +68,11 @@ before_script: - export DISPLAY=:99.0 - export DOCKER_ENV=$(if [ "$TRAVIS_BRANCH" == "production" ]; then echo "prod"; else echo "stage"; fi) - sh -e /etc/init.d/xvfb start - - sleep 3 - - docker-compose -f docker-compose-stage.yml up --build -d script: - bash test.sh $DOCKER_ENV -after_script: - - docker-compose -f docker-compose-stage.yml down - after_success: - bash ./docker-push.sh - bash ./docker-deploy-stage.sh - - bash ./docker-deploy-prod.sh \ No newline at end of file + - bash ./docker-deploy-prod.sh diff --git a/test.sh b/test.sh index c89d133a..2c167cb4 100755 --- a/test.sh +++ b/test.sh @@ -16,52 +16,94 @@ else exit 1 fi +build() { + image_name=$1 + docker-compose -f $file build $image_name +} + +section_start() { + start_time=`date +%s` + echo -en "travis_fold:start:$1\\r" + echo $1 + set -x +} + +section_end() { + set +x + echo -en "travis_fold:end:$1\\r" + end_time=`date +%s` + runtime=$((end_time - start_time)) + echo "Took $runtime seconds" + echo "-------------------------" +} + inspect() { if [ $1 -ne 0 ]; then fails="${fails} $2" fi } -set -x - -# allows time for the docker containers to come up prior to running tests +# Build and start containers +section_start 'setup' +docker-compose -f $file up --build -d if [[ "${env}" != "dev" ]]; then - sleep 15 + sleep 15 # allow time for the docker containers to come up prior to running tests fi +section_end 'setup' # Users service -docker-compose -f $file run users-service py.test --black --pep8 --flakes -vv --mccabe --cov=project --cov-report=term-missing --junitxml=test-results/results.xml -inspect $? users-test +image='users-service' +section_start $image +build $image +docker-compose -f $file run $image py.test --black --pep8 --flakes -vv --mccabe --cov=project --cov-report=term-missing --junitxml=test-results/results.xml +inspect $? $image +section_end $image # Events service -docker-compose -f $file run events-service py.test --black --pep8 --flakes -vv --mccabe --cov=project --cov-report=term-missing --junitxml=test-results/results.xml -inspect $? events-test +image='events-service' +section_start $image +build $image +docker-compose -f $file run $image py.test --black --pep8 --flakes -vv --mccabe --cov=project --cov-report=term-missing --junitxml=test-results/results.xml +inspect $? $image +section_end $image # Client -docker-compose -f $file build client-test +image='client-test' +section_start $image +build $image docker-compose -f $file run client-test npm run lint inspect $? client-lint CI=true docker-compose -f $file run client-test npm test -- --coverage -inspect $? client-test +inspect $? $image +section_end $image # Lambdas -docker-compose -f $file build lambdas-test -docker-compose -f $file run lambdas-test npm run lint +image='lambdas-test' +section_start $image +build $image +docker-compose -f $file run $image npm run lint inspect $? lambdas-lint -docker-compose -f $file run lambdas-test npm test -inspect $? lambdas-test +docker-compose -f $file run $image npm test +inspect $? $image +section_end $image # Integration tests +section_start 'integration-test' if [[ "${env}" != "stage" ]]; then testcafe chrome e2e - inspect $? e2e + inspect $? integration-test else testcafe chrome e2e/index.test.js - inspect $? e2e + inspect $? integration-test fi +section_end 'integration-test' -set +x +# Stop containers +section_start 'teardown' +docker-compose -f $file down +section_end 'teardown' +# Output success / failure if [ -n "${fails}" ]; then echo "Tests failed: ${fails}" exit 1