Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Issue/100 #105

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 11 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,19 @@ services:
- docker
jdk:
- oraclejdk8
env:
- TEST_PHASE=unit
- TEST_PHASE=system-broccoli-only
- TEST_PHASE=system-broccoli-nomad
- TEST_PHASE=system-broccoli-nomad-consul
script:
- uname -r
- sbt test
- sbt dist
- unzip target/universal/cluster-broccoli*.zip
- cp -R cluster-broccoli-* docker/test/cluster-broccoli-dist
- cp -R cluster-broccoli-* docker/prod/cluster-broccoli-dist
- cp -R templates docker/test/
- cp -R templates docker/prod/
- docker build -t frosner/cluster-broccoli-test docker/test/
- bash <(curl -s https://raw.githubusercontent.com/FRosner/http-api-tester/master/http-api-tester) -v -d http-api-tests/broccoli-only
- bash <(curl -s https://raw.githubusercontent.com/FRosner/http-api-tester/master/http-api-tester) -v -d http-api-tests/broccoli-nomad
- bash <(curl -s https://raw.githubusercontent.com/FRosner/http-api-tester/master/http-api-tester) -v -d http-api-tests/broccoli-nomad-consul

- travis/test
cache:
directories:
- $HOME/.m2
- $HOME/.ivy2

after_success:
- bash <(curl -s https://codecov.io/bash)
- docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- export COMMIT=${TRAVIS_COMMIT::8}
- export REPO=frosner/cluster-broccoli
- export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH ; fi`
- docker build -t $REPO:$COMMIT docker/prod/
- docker tag $REPO:$COMMIT $REPO:$TAG
- docker tag $REPO:$COMMIT $REPO:travis-$TRAVIS_BUILD_NUMBER
- docker push $REPO
deploy:
provider: script
script: travis/deploy
on:
all_branches: true
25 changes: 25 additions & 0 deletions travis/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
# https://docs.travis-ci.com/user/deployment/script/

set -e
set -o pipefail

echo "Building Broccoli distribution"
sbt dist
unzip target/universal/cluster-broccoli*.zip
cp -R cluster-broccoli-* docker/prod/cluster-broccoli-dist
cp -R templates docker/prod/

echo "Logging into docker registry"
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD

echo "Building docker image"
export COMMIT=${TRAVIS_COMMIT::8}
export REPO=frosner/cluster-broccoli
export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH ; fi`
docker build -t $REPO:$COMMIT docker/prod/

echo "Pushing docker image"
docker tag $REPO:$COMMIT $REPO:$TAG
docker tag $REPO:$COMMIT $REPO:travis-$TRAVIS_BUILD_NUMBER
docker push $REPO
42 changes: 42 additions & 0 deletions travis/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

set -e
set -o pipefail

echo "Selected TEST_PHASE is $TEST_PHASE"

unit_tests() {
echo "Starting unit tests"
sbt test
}

system_tests() {
echo "Preparing system tests"
sbt dist
unzip target/universal/cluster-broccoli*.zip
cp -R cluster-broccoli-* docker/test/cluster-broccoli-dist
cp -R templates docker/test/
docker build -t frosner/cluster-broccoli-test docker/test/
if [ "${TEST_PHASE}" = "system-broccoli-only" ]; then
echo "Starting broccoli-only tests"
bash <(curl -s https://raw.githubusercontent.com/FRosner/http-api-tester/master/http-api-tester) -v -d http-api-tests/broccoli-only
elif [ "${TEST_PHASE}" = "system-broccoli-nomad" ]; then
echo "Starting broccoli-nomad tests"
bash <(curl -s https://raw.githubusercontent.com/FRosner/http-api-tester/master/http-api-tester) -v -d http-api-tests/broccoli-nomad
elif [ "${TEST_PHASE}" = "system-broccoli-nomad-consul" ]; then
echo "Starting broccoli-nomad-consul tests"
bash <(curl -s https://raw.githubusercontent.com/FRosner/http-api-tester/master/http-api-tester) -v -d http-api-tests/broccoli-nomad-consul
else
echo "Test phase '$TEST_PHASE' not recognized"
exit 1
fi
}

if [ "${TEST_PHASE}" = "unit" ]; then
unit_tests
elif [[ "$TEST_PHASE" == system* ]]; then
system_tests
else
echo '$TEST_PHASE not set correctly'
exit 1
fi