2019-08-23 08:47:19 -07:00
|
|
|
dist: bionic
|
|
|
|
sudo: required
|
|
|
|
|
|
|
|
services:
|
|
|
|
- docker
|
|
|
|
|
|
|
|
env:
|
|
|
|
global:
|
|
|
|
- DOCKER_COMPOSE_VERSION=1.24.1
|
|
|
|
matrix:
|
|
|
|
- DOCKER_OS=ubuntu-18.04
|
|
|
|
- DOCKER_OS=centos-7
|
|
|
|
|
|
|
|
before_install:
|
|
|
|
# Install latest versions of docker and docker-compose
|
|
|
|
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
|
|
|
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
|
|
|
- sudo apt-get update
|
|
|
|
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
|
|
|
|
- sudo rm /usr/local/bin/docker-compose
|
|
|
|
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
|
|
|
|
- chmod +x docker-compose
|
|
|
|
- sudo mv docker-compose /usr/local/bin
|
|
|
|
- docker --version
|
|
|
|
- docker-compose --version
|
|
|
|
|
|
|
|
before_script:
|
|
|
|
# Set correct dockerfile
|
|
|
|
- cd $TRAVIS_BUILD_DIR/docker
|
|
|
|
- sed -i "s|Dockerfile\.base-.*|Dockerfile\.base-$DOCKER_OS|" docker-compose.yml
|
|
|
|
- sed -i "s|Dockerfile\.base-.*|Dockerfile\.base-$DOCKER_OS|" docker-compose.test.yml
|
|
|
|
- sudo service mysql stop || true
|
|
|
|
|
|
|
|
script:
|
2019-10-23 20:21:22 -07:00
|
|
|
- env | grep TRAVIS | sort
|
2019-08-23 08:47:19 -07:00
|
|
|
- cd $TRAVIS_BUILD_DIR/docker
|
|
|
|
# Build master images and run the webserver
|
|
|
|
- docker-compose build
|
|
|
|
- docker-compose up -d
|
|
|
|
- docker logs ottertune
|
|
|
|
- docker-compose rm -f -s -v
|
|
|
|
# Build test images and run tests
|
|
|
|
- ci_env=`bash <(curl -s https://codecov.io/env)`
|
|
|
|
- docker-compose -f docker-compose.test.yml build
|
|
|
|
- docker-compose -f docker-compose.test.yml up -d
|
|
|
|
- docker-compose -f docker-compose.test.yml run --workdir="/app/client/controller" --rm test gradle build
|
|
|
|
- docker-compose -f docker-compose.test.yml run --workdir="/app/server" --rm $ci_env test bash -c "coverage run --omit=\"*/tests/*\" -m unittest discover -s analysis/tests -v && (codecov -F analysis || (sleep 5 && codecov -F analysis) || (sleep 5 && codecov -F analysis))"
|
2019-10-08 17:59:08 -07:00
|
|
|
- docker-compose -f docker-compose.test.yml run --workdir="/app/server/website" --rm $ci_env test bash -c "./wait-for-it.sh && python3 manage.py makemigrations website && coverage run --source=website manage.py test --noinput -v 2 && (codecov -F website || (sleep 5 && codecov -F website) || (sleep 5 && codecov -F website))"
|
2019-10-26 20:00:49 -07:00
|
|
|
- docker-compose -f docker-compose.test.yml run --workdir="/app/server/website" --rm test bash -c "./start-test.sh"
|
2019-10-23 12:59:22 -07:00
|
|
|
# Only run the linter once on ubuntu 18.04
|
2019-08-23 08:47:19 -07:00
|
|
|
- if [ $DOCKER_OS == ubuntu-18.04 ]; then
|
2019-10-23 20:21:22 -07:00
|
|
|
docker-compose -f docker-compose.test.yml run --workdir="/app" --rm -e TRAVIS_COMMIT_RANGE=$TRAVIS_COMMIT_RANGE test bash -c "git reset --soft ${TRAVIS_COMMIT_RANGE%...*} && git status && git log | head -n 1 && git lint";
|
2019-08-23 08:47:19 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
after_script:
|
|
|
|
# Cleanup docker containers, images, and volumes
|
|
|
|
- docker-compose rm -f -s -v
|
|
|
|
- docker system prune -a -f
|
|
|
|
- docker volume prune -f
|
|
|
|
|