Update build toolchain to the use of docker…
… for integration tests. - Update circle.yml to start the docker daemon listening on TCP (to be able to talk to it from the container running test-integration) - Update script/test-integration to prepare the use of go-check - Update Makefile in order to run less "binary" target and setting up the right environment variable for the builds Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
47015433cc
commit
a5a8d6929e
5 changed files with 39 additions and 14 deletions
18
Makefile
18
Makefile
|
@ -5,15 +5,16 @@ TRAEFIK_ENVS := \
|
||||||
-e OS_PLATFORM_ARG \
|
-e OS_PLATFORM_ARG \
|
||||||
-e TESTFLAGS
|
-e TESTFLAGS
|
||||||
|
|
||||||
BIND_DIR := $(if $(DOCKER_HOST),,dist)
|
BIND_DIR := "dist"
|
||||||
TRAEFIK_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/emilevauge/traefik/$(BIND_DIR)")
|
TRAEFIK_MOUNT := -v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/emilevauge/traefik/$(BIND_DIR)"
|
||||||
|
|
||||||
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
||||||
TRAEFIK_DEV_IMAGE := traefik-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
|
TRAEFIK_DEV_IMAGE := traefik-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
|
||||||
REPONAME := $(shell echo $(REPO) | tr '[:upper:]' '[:lower:]')
|
REPONAME := $(shell echo $(REPO) | tr '[:upper:]' '[:lower:]')
|
||||||
TRAEFIK_IMAGE := $(if $(REPONAME),$(REPONAME),"emilevauge/traefik")
|
TRAEFIK_IMAGE := $(if $(REPONAME),$(REPONAME),"emilevauge/traefik")
|
||||||
|
INTEGRATION_OPTS := $(if $(MAKE_DOCKER_HOST),-e "DOCKER_HOST=$(MAKE_DOCKER_HOST)", -v "/var/run/docker.sock:/var/run/docker.sock")
|
||||||
|
|
||||||
DOCKER_RUN_TRAEFIK := docker run $(if $(CIRCLECI),,--rm) -it $(TRAEFIK_ENVS) $(TRAEFIK_MOUNT) "$(TRAEFIK_DEV_IMAGE)"
|
DOCKER_RUN_TRAEFIK := docker run $(if $(CIRCLECI),,--rm) $(INTEGRATION_OPTS) -it $(TRAEFIK_ENVS) $(TRAEFIK_MOUNT) "$(TRAEFIK_DEV_IMAGE)"
|
||||||
|
|
||||||
print-%: ; @echo $*=$($*)
|
print-%: ; @echo $*=$($*)
|
||||||
|
|
||||||
|
@ -22,14 +23,17 @@ default: binary
|
||||||
binary: build
|
binary: build
|
||||||
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate binary
|
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate binary
|
||||||
|
|
||||||
|
crossbinary: build
|
||||||
|
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate crossbinary
|
||||||
|
|
||||||
test: build
|
test: build
|
||||||
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate test-unit test-integration
|
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate test-unit binary test-integration
|
||||||
|
|
||||||
test-unit: build
|
test-unit: build
|
||||||
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate test-unit
|
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate test-unit
|
||||||
|
|
||||||
test-integration: build
|
test-integration: build
|
||||||
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate binary test-integration
|
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate test-integration
|
||||||
|
|
||||||
validate: build
|
validate: build
|
||||||
$(DOCKER_RUN_TRAEFIK) ./script/make.sh validate-gofmt validate-govet
|
$(DOCKER_RUN_TRAEFIK) ./script/make.sh validate-gofmt validate-govet
|
||||||
|
@ -47,10 +51,6 @@ shell: build
|
||||||
$(DOCKER_RUN_TRAEFIK) /bin/bash
|
$(DOCKER_RUN_TRAEFIK) /bin/bash
|
||||||
|
|
||||||
image: build
|
image: build
|
||||||
if ! [ -a dist/traefik_linux-386 ] ; \
|
|
||||||
then \
|
|
||||||
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate binary; \
|
|
||||||
fi;
|
|
||||||
docker build -t $(TRAEFIK_IMAGE) .
|
docker build -t $(TRAEFIK_IMAGE) .
|
||||||
|
|
||||||
dist:
|
dist:
|
||||||
|
|
|
@ -4,10 +4,26 @@ RUN go get github.com/tools/godep
|
||||||
RUN go get github.com/mitchellh/gox
|
RUN go get github.com/mitchellh/gox
|
||||||
RUN go get github.com/tcnksm/ghr
|
RUN go get github.com/tcnksm/ghr
|
||||||
|
|
||||||
|
# Which docker version to test on
|
||||||
|
ENV DOCKER_VERSION 1.6.2
|
||||||
|
|
||||||
|
# Download docker
|
||||||
|
RUN set -ex; \
|
||||||
|
curl https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION} -o /usr/local/bin/docker-${DOCKER_VERSION}; \
|
||||||
|
chmod +x /usr/local/bin/docker-${DOCKER_VERSION}
|
||||||
|
|
||||||
|
# Set the default Docker to be run
|
||||||
|
RUN ln -s /usr/local/bin/docker-${DOCKER_VERSION} /usr/local/bin/docker
|
||||||
|
|
||||||
ENV PATH /go/src/github.com/emilevauge/traefik/Godeps/_workspace/bin:$PATH
|
ENV PATH /go/src/github.com/emilevauge/traefik/Godeps/_workspace/bin:$PATH
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/emilevauge/traefik
|
WORKDIR /go/src/github.com/emilevauge/traefik
|
||||||
|
|
||||||
|
# This is a hack (see libcompose#32) - will be removed when libcompose will be fixed
|
||||||
|
# (i.e go get able)
|
||||||
|
RUN mkdir -p /go/src/github.com/docker/docker/autogen/dockerversion/
|
||||||
|
COPY Godeps/_workspace/src/github.com/docker/docker/autogen/dockerversion/dockerversion.go /go/src/github.com/docker/docker/autogen/dockerversion/dockerversion.go
|
||||||
|
|
||||||
RUN mkdir Godeps
|
RUN mkdir Godeps
|
||||||
COPY Godeps/Godeps.json Godeps/
|
COPY Godeps/Godeps.json Godeps/
|
||||||
RUN godep restore
|
RUN godep restore
|
||||||
|
|
12
circle.yml
12
circle.yml
|
@ -1,11 +1,15 @@
|
||||||
machine:
|
machine:
|
||||||
services:
|
pre:
|
||||||
- docker
|
- sudo docker -d -e lxc -s btrfs -H tcp://0.0.0.0:2375:
|
||||||
|
background: true
|
||||||
|
- sleep 5
|
||||||
environment:
|
environment:
|
||||||
REPO: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
|
REPO: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
|
||||||
|
DOCKER_HOST: tcp://172.17.42.1:2375
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
pre:
|
pre:
|
||||||
|
- docker version
|
||||||
- go get github.com/tcnksm/ghr
|
- go get github.com/tcnksm/ghr
|
||||||
- make validate
|
- make validate
|
||||||
override:
|
override:
|
||||||
|
@ -13,8 +17,10 @@ dependencies:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
override:
|
override:
|
||||||
- make test
|
- make test-unit
|
||||||
|
- make MAKE_DOCKER_HOST=$DOCKER_HOST test-integration
|
||||||
post:
|
post:
|
||||||
|
- make crossbinary
|
||||||
- make image
|
- make image
|
||||||
|
|
||||||
deployment:
|
deployment:
|
||||||
|
|
|
@ -4,6 +4,7 @@ set -e
|
||||||
# List of bundles to create when no argument is passed
|
# List of bundles to create when no argument is passed
|
||||||
DEFAULT_BUNDLES=(
|
DEFAULT_BUNDLES=(
|
||||||
validate-gofmt
|
validate-gofmt
|
||||||
|
validate-govet
|
||||||
binary
|
binary
|
||||||
|
|
||||||
test-unit
|
test-unit
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
export DEST=.
|
export DEST=.
|
||||||
|
|
||||||
TESTFLAGS="$TESTFLAGS"
|
TESTFLAGS="$TESTFLAGS -test.timeout=30m -check.v"
|
||||||
#godep go test -v ./integration
|
|
||||||
|
cd integration
|
||||||
|
GOPATH=`godep path`:$GOPATH go test $TESTFLAGS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue