Skip to content
This repository has been archived by the owner on Apr 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #514 from apoclyps/spike-travis-docker-image-caching
Browse files Browse the repository at this point in the history
Update travis output with timings
  • Loading branch information
alistairjcbrown authored Nov 7, 2018
2 parents 34d5cb1 + b42e6fd commit 2e2a4ce
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 24 deletions.
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ sudo: required

install:
- npm install
- npm install danger -g

cache:
directories:
Expand Down Expand Up @@ -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
- bash ./docker-deploy-prod.sh
76 changes: 59 additions & 17 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2e2a4ce

Please sign in to comment.