From 91b699fbe0fc3878c3673a6d397a95428e823429 Mon Sep 17 00:00:00 2001 From: emile Date: Fri, 19 Feb 2016 12:58:06 +0100 Subject: [PATCH] Migrate CI to travis - Add travis build file - Use golang alpine image - Clean scripts a little bit - Disable CGO for test-integration >_< --- .travis.yml | 30 ++++++++++++++++++++++++++++++ Makefile | 5 ++--- README.md | 2 +- build.Dockerfile | 7 ++++--- script/.validate | 21 +++++++++++---------- script/deploy.sh | 13 +++++++++++++ script/test-integration | 4 ++-- 7 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 .travis.yml create mode 100644 script/deploy.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..baa773733 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +env: + REPO: $TRAVIS_REPO_SLUG + VERSION: v1.0.alpha.$TRAVIS_COMMIT + +sudo: required + +services: + - docker + +install: + - sudo service docker stop + - sudo curl https://get.docker.com/builds/Linux/x86_64/docker-1.10.1 -o /usr/bin/docker + - sudo chmod +x /usr/bin/docker + - sudo service docker start + +before_script: + - make validate + - make binary + +script: + - make test-unit + - make test-integration + - make crossbinary + - make image + +deploy: + provider: script + script: script/deploy.sh + on: + branch: master diff --git a/Makefile b/Makefile index 9b7d622aa..790204f44 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,7 @@ TRAEFIK_ENVS := \ -e OS_ARCH_ARG \ -e OS_PLATFORM_ARG \ -e TESTFLAGS \ - -e CIRCLECI - + -e VERSION SRCS = $(shell git ls-files '*.go' | grep -v '^external/') @@ -18,7 +17,7 @@ REPONAME := $(shell echo $(REPO) | tr '[:upper:]' '[:lower:]') 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) $(INTEGRATION_OPTS) -it $(TRAEFIK_ENVS) $(TRAEFIK_MOUNT) "$(TRAEFIK_DEV_IMAGE)" +DOCKER_RUN_TRAEFIK := docker run $(INTEGRATION_OPTS) -it $(TRAEFIK_ENVS) $(TRAEFIK_MOUNT) "$(TRAEFIK_DEV_IMAGE)" print-%: ; @echo $*=$($*) diff --git a/README.md b/README.md index 543556d68..c2f3fd5da 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![Træfɪk](http://traefik.github.io/traefik.logo.svg "Træfɪk") ___ -[![Circle CI](https://circleci.com/gh/emilevauge/traefik/tree/master.png?circle-token)](https://circleci.com/gh/emilevauge/traefik) +[![Build Status](https://travis-ci.org/emilevauge/traefik.svg?branch=master)](https://travis-ci.org/emilevauge/traefik) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/EmileVauge/traefik/blob/master/LICENSE.md) [![Join the chat at https://traefik.herokuapp.com](https://img.shields.io/badge/style-register-green.svg?style=social&label=Slack)](https://traefik.herokuapp.com) diff --git a/build.Dockerfile b/build.Dockerfile index a80241b1c..76883064e 100644 --- a/build.Dockerfile +++ b/build.Dockerfile @@ -1,13 +1,14 @@ -FROM golang:1.6 +FROM golang:1.6.0-alpine + +RUN apk update && apk add git bash gcc RUN go get github.com/Masterminds/glide RUN go get github.com/mitchellh/gox -RUN go get github.com/tcnksm/ghr RUN go get github.com/jteeuwen/go-bindata/... RUN go get github.com/golang/lint/golint # Which docker version to test on -ENV DOCKER_VERSION 1.6.2 +ENV DOCKER_VERSION 1.10.1 # enable GO15VENDOREXPERIMENT ENV GO15VENDOREXPERIMENT 1 diff --git a/script/.validate b/script/.validate index 7f4a81096..6b55f2a73 100644 --- a/script/.validate +++ b/script/.validate @@ -3,23 +3,24 @@ if [ -z "$VALIDATE_UPSTREAM" ]; then # this is kind of an expensive check, so let's not do this twice if we # are running more than one validate bundlescript - + VALIDATE_REPO='https://github.com/emilevauge/traefik.git' VALIDATE_BRANCH='master' - - if [ "$TRAVIS" = 'true' -a "$TRAVIS_PULL_REQUEST" != 'false' ]; then - VALIDATE_REPO="https://github.com/${TRAVIS_REPO_SLUG}.git" - VALIDATE_BRANCH="${TRAVIS_BRANCH}" - fi - + + # Should not be needed for now O:) + # if [ "$TRAVIS" = 'true' -a "$TRAVIS_PULL_REQUEST" != 'false' ]; then + # VALIDATE_REPO="https://github.com/${TRAVIS_REPO_SLUG}.git" + # VALIDATE_BRANCH="${TRAVIS_BRANCH}" + # fi + VALIDATE_HEAD="$(git rev-parse --verify HEAD)" - + git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH" VALIDATE_UPSTREAM="$(git rev-parse --verify FETCH_HEAD)" - + VALIDATE_COMMIT_LOG="$VALIDATE_UPSTREAM..$VALIDATE_HEAD" VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD" - + validate_diff() { if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then git diff "$VALIDATE_COMMIT_DIFF" "$@" diff --git a/script/deploy.sh b/script/deploy.sh new file mode 100644 index 000000000..a9b22276a --- /dev/null +++ b/script/deploy.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +curl -LO https://github.com/tcnksm/ghr/releases/download/pre-release/linux_amd64.zip +unzip -q linux_amd64.zip +sudo mv grh /usr/bin/ghr +sudo chmod +x /usr/bin/ghr + +ghr -t $GITHUB_TOKEN -u emilevauge -r traefik --prerelease ${VERSION} dist/ +docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS +docker push ${REPO,,}:latest +docker tag ${REPO,,}:latest ${REPO,,}:${VERSION} +docker push ${REPO,,}:${VERSION} diff --git a/script/test-integration b/script/test-integration index 63f4b46f5..87d22a9e7 100755 --- a/script/test-integration +++ b/script/test-integration @@ -1,4 +1,5 @@ #!/bin/bash +set -e export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export DEST=. @@ -6,5 +7,4 @@ export DEST=. TESTFLAGS="$TESTFLAGS -test.timeout=30m -check.v" cd integration -go test $TESTFLAGS - +CGO_ENABLED=0 go test $TESTFLAGS