From 5f93c9f86106287581770d882669b33c2478f8d5 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 11 Apr 2016 14:10:46 +0800 Subject: [PATCH] #10 support testing in docker. Signed-off-by: Bo-Yi Wu --- Makefile | 21 +++++++++++++-------- docker/Dockerfile.build | 2 +- docker/Dockerfile.testing | 8 ++++++++ 3 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 docker/Dockerfile.testing diff --git a/Makefile b/Makefile index 0d11ab2..01f7a66 100644 --- a/Makefile +++ b/Makefile @@ -3,22 +3,27 @@ VERSION=0.0.1 DEPS := $(wildcard *.go) -BUILD_IMAGE := "gopush-build" +BUILD_IMAGE := "appleboy/gopush-build:latest" +TEST_IMAGE := "appleboy/gopush-testing:latest" all: build build: clean sh script/build.sh -docker_build: clean - tar -zcvf build.tar.gz gopush.go gopush script - docker build -t $(BUILD_IMAGE) -f docker/Dockerfile.build . - docker run $(BUILD_IMAGE) > bin.tar.gz - tar -zxvf bin.tar.gz - -rm -rf bin.tar.gz build.tar.gz - test: cd gopush && go test -v -covermode=count -coverprofile=coverage.out +docker_build: clean + tar -zcvf build.tar.gz gopush.go gopush script + docker build --rm -t $(BUILD_IMAGE) -f docker/Dockerfile.build . + docker run --rm $(BUILD_IMAGE) > bin.tar.gz + tar -zxvf bin.tar.gz + -rm -rf bin.tar.gz build.tar.gz + +docker_test: + @docker build --rm -t $(TEST_IMAGE) -f docker/Dockerfile.testing . + @docker run --rm -e ANDROID_TEST_TOKEN=$(ANDROID_TEST_TOKEN) -e ANDROID_API_KEY=$(ANDROID_API_KEY) $(TEST_IMAGE) sh -c "cd gopush && go test -v" + clean: rm -rf build.tar.gz bin.tar.gz bin/* diff --git a/docker/Dockerfile.build b/docker/Dockerfile.build index 0a84a47..1e318aa 100644 --- a/docker/Dockerfile.build +++ b/docker/Dockerfile.build @@ -5,7 +5,7 @@ MAINTAINER Bo-Yi Wu RUN mkdir -p /tmp/build Add build.tar.gz /tmp/build/ WORKDIR /tmp/build -RUN go get -d +RUN go get -v -d RUN sh script/build.sh CMD tar -czf - bin diff --git a/docker/Dockerfile.testing b/docker/Dockerfile.testing new file mode 100644 index 0000000..85cc97c --- /dev/null +++ b/docker/Dockerfile.testing @@ -0,0 +1,8 @@ +FROM golang:1.6 + +MAINTAINER Bo-Yi Wu + +RUN mkdir -p /tmp/build +Add . /tmp/build/ +WORKDIR /tmp/build +RUN go get -v -d -t ./...