diff --git a/.travis.yml b/.travis.yml index 067c7a01..bf9708fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,18 +27,12 @@ before_script: # install aws CLI - (sudo pip install -q awscli; which aws > /dev/null) & -script: - # fail fast - - set -e - - export MAKE_ARGS=--no-print-directory - # compile and build Docker images - - glide -q install - - make $MAKE_ARGS build - - make $MAKE_ARGS docker-build - # deploy services - - make $MAKE_ARGS deploy - # submit a test job - - make $MAKE_ARGS test-submit +jobs: + include: + - stage: test + script: ./etc/travis/test-images-local.sh + - if: type IN (push, api, cron) + script: ./etc/travis/test-images-dockerhub.sh notifications: email: false diff --git a/Makefile b/Makefile index b0be21c0..6e667b2d 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,10 @@ UI_REPO = git@github.com:IBM/FfDL-dashboard.git CLI_CMD = $(shell pwd)/cli/bin/ffdl-$(UNAME_SHORT) CLUSTER_NAME ?= mycluster PUBLIC_IP ?= 127.0.0.1 +TRAVIS_IMAGE_VERSION ?= 0.0.1-master +TEST_IMAGES = $(addprefix $(DOCKER_NAMESPACE)/, $(TEST_IMAGES_SUFFIX)) +TEST_IMAGES_SUFFIX = ffdl-lcm ffdl-trainer ffdl-metrics ffdl-databroker_s3 ffdl-ui ffdl-restapi ffdl-jobmonitor ffdl-controller tensorboard_extract_1.3-py3 log_collector ffdl-databroker_objectstorage tensorboard_extract + IMAGE_DIR := $(IMAGE_NAME) ifneq ($(filter $(IMAGE_NAME),controller ),) @@ -203,8 +207,27 @@ test-submit: ## Submit test training job kubectl get pods | grep learner- | awk '{print $$1}' | xargs -I '{}' kubectl logs '{}' -c load-data; \ exit 1); +pull-dockerhub-images: ## Pull FfDL images from dockerhub +pull-dockerhub-images: $(addprefix pull-, $(TEST_IMAGES)) + +$(addprefix pull-, $(TEST_IMAGES)): pull-%: % + @TRAVIS_IMAGE=$< make .pull-dockerhub-images + +$(TEST_IMAGES): ; + +tag-dockerhub-images-to-latest: $(addprefix tag-, $(TEST_IMAGES)) + +$(addprefix tag-, $(TEST_IMAGES)): tag-%: % + @TRAVIS_IMAGE=$< make .tag-dockerhub-latest + # Helper targets +.pull-dockerhub-images: + docker pull $(TRAVIS_IMAGE):$(TRAVIS_IMAGE_VERSION) + +.tag-dockerhub-latest: + docker tag $(TRAVIS_IMAGE):$(TRAVIS_IMAGE_VERSION) $(TRAVIS_IMAGE):latest + .build-service: (cd ./$(SERVICE_NAME)/ && (test ! -e main.go || CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -a -installsuffix cgo -o bin/$(BINARY_NAME))) diff --git a/etc/travis/test-images-dockerhub.sh b/etc/travis/test-images-dockerhub.sh new file mode 100755 index 00000000..87dcc3dc --- /dev/null +++ b/etc/travis/test-images-dockerhub.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# fail fast +set -e +export MAKE_ARGS=--no-print-directory +# pull images from dockerhub +make $MAKE_ARGS pull-dockerhub-images +make $MAKE_ARGS tag-dockerhub-images-to-latest + +# deploy services +make $MAKE_ARGS deploy +# submit a test job +make $MAKE_ARGS test-submit diff --git a/etc/travis/test-images-local.sh b/etc/travis/test-images-local.sh new file mode 100755 index 00000000..3668b38e --- /dev/null +++ b/etc/travis/test-images-local.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# fail fast +set -e +export MAKE_ARGS=--no-print-directory +# compile and build Docker images +glide -q install +make $MAKE_ARGS build +make $MAKE_ARGS docker-build +# deploy services +make $MAKE_ARGS deploy +# submit a test job +make $MAKE_ARGS test-submit