From 8e4c4f840705b3a57de6a2ffebad936efc6a65fa Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Mon, 14 Nov 2016 17:41:12 +0100 Subject: [PATCH] Use deployment primitives from travis --- .travis.yml | 84 ++++++++++++++++++++++++++++++----------- Makefile | 7 ---- build.Dockerfile | 9 ++--- script/deploy-docker.sh | 19 ++++++++++ script/deploy-pr.sh | 27 ------------- script/deploy.sh | 31 --------------- script/test-integration | 2 +- 7 files changed, 84 insertions(+), 95 deletions(-) create mode 100644 script/deploy-docker.sh delete mode 100755 script/deploy-pr.sh diff --git a/.travis.yml b/.travis.yml index 184a29c56..d526df8d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,70 @@ -branches: +sudo: required +dist: trusty + +services: + - docker + env: global: - secure: btt4r13t09gQlHb6gYrvGC2yGCMMHfnp1Mz1RQedc4Mpf/FfT8aE6xmK2a2i9CCvskjrP0t/BFaS4yxIURjnFRn+ugQIEa0pLspB9UJArW/vgOSpIWM9/OQ/fg8z5XuMxN6Md4DL1/iLypMNSageA1x0TRdt89+D1N1dALpg5XRCXLFbC84TLi0gjlFuib9ibPKzEhLT+anCRJ6iZMzeupDSoaCVbAtJMoDvXw4+4AcRZ1+k4MybBLyCib5boaEOt4pTT88mz4Kk0YaMwPVJyg9Qv36VqyUcPS09Yd95LuyVQ4+tZt8Y1ccbIzULsK+sLM3hLCzxlmlpN3dQBlZJiiRtQde0mgGAKyC0P0A1XjuDTywcsa5edB+fTk1Dsewz9xZ9V0NmMz8t+UNZnaSsAPga9i86jULbXUUwMVSzVRc+Xgx02liB/8qI1xYC9FM6ilStt7rn7mF0k3KbiWhcptgeXjO6Lah9FjEKd5w4MXsdUSTi/86rQaLo+kj+XdaTrXCTulKHyRyQEUj+8V1w0oVz7pcGjePHd7y5oU9ByifVQy6sytuFBfRZvugM5bKHo+i0pcWvixrZS42DrzwxZJsspANOvqSe5ifVbvOkfUppQdCBIwptxV5N1b49XPKU3W/w34QJ8xGmKp3TFA7WwVCztriFHjPgiRpB3EG99Bg= - REPO: $TRAVIS_REPO_SLUG - VERSION: $TRAVIS_TAG - CODENAME: camembert - matrix: - - DOCKER_VERSION=1.9.1 - - DOCKER_VERSION=1.10.1 -sudo: required -services: -- docker + +#addons: +# apt: +# packages: +# - docker-engine=$DOCKER_VERSION.* + +before_install: + - sudo -E apt-get -yq update + - sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install docker-engine=${DOCKER_VERSION}* + install: -- sudo service docker stop -- sudo curl https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION} -o /usr/bin/docker -- sudo chmod +x /usr/bin/docker -- sudo service docker start -- sleep 5 -- docker version -- pip install --user -r requirements.txt + - docker version + - pip install --user -r requirements.txt before_script: -- make validate -- make binary + - make validate + - make binary script: -- make test-unit -- make test-integration -- make crossbinary -- make image -after_success: -- make deploy -- make deploy-pr + - make test-unit + - make test-integration +after_failure: + - docker ps + +matrix: + fast_finish: true + include: + - env: DOCKER_VERSION=1.10.3 + - env: DOCKER_VERSION=1.13.0 + - env: DOCKER_VERSION=1.12.6 + after_success: + - make crossbinary + - make image + before_deploy: + - mkdocs build --clean + - tar cfz dist/traefik-${VERSION}.src.tar.gz --exclude-vcs --exclude dist . + deploy: + - provider: pages + edge: true + github_token: ${GITHUB_TOKEN} + local_dir: site + on: + repo: containous/traefik + tags: true + - provider: releases + api_key: ${GITHUB_TOKEN} + file: dist/traefik_* + file_glob: true + on: + repo: containous/traefik + tags: true + - provider: scripts + script: script/deploy.sh + on: + repo: containous/traefik + tags: true + - provider: scripts + script: script/deploy-docker.sh + on: + repo: containous/traefik diff --git a/Makefile b/Makefile index d2ac520ac..6f687df46 100644 --- a/Makefile +++ b/Makefile @@ -82,12 +82,5 @@ lint: fmt: gofmt -s -l -w $(SRCS) - -deploy: - ./script/deploy.sh - -deploy-pr: - ./script/deploy-pr.sh - help: ## this help @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) diff --git a/build.Dockerfile b/build.Dockerfile index 5b25c5f8f..78ea3f7ac 100644 --- a/build.Dockerfile +++ b/build.Dockerfile @@ -10,12 +10,9 @@ RUN go get github.com/Masterminds/glide \ ARG DOCKER_VERSION=1.10.1 # 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 +RUN mkdir -p /usr/local/bin \ + && curl -SL https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz \ + | tar -xzC /usr/local/bin --transform 's#^.+/##x' WORKDIR /go/src/github.com/containous/traefik diff --git a/script/deploy-docker.sh b/script/deploy-docker.sh new file mode 100644 index 000000000..4f54329cb --- /dev/null +++ b/script/deploy-docker.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e + +if [ -n "$TRAVIS_COMMIT" ]; then + echo "Deploying PR..." +else + echo "Skipping deploy PR" + exit 0 +fi + +# create docker image containous/traefik +echo "Updating docker containous/traefik image..." +docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS +docker tag containous/traefik containous/traefik:${TRAVIS_COMMIT} +docker push containous/traefik:${TRAVIS_COMMIT} +docker tag containous/traefik containous/traefik:experimental +docker push containous/traefik:experimental + +echo "Deployed" diff --git a/script/deploy-pr.sh b/script/deploy-pr.sh deleted file mode 100755 index cbf1e6c81..000000000 --- a/script/deploy-pr.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -set -e - -if ([ -z "$TRAVIS_TAG" ]) && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$DOCKER_VERSION" = "1.10.1" ]; then - echo "Deploying PR..." -else - echo "Skipping deploy PR" - exit 0 -fi - -COMMENT=$(git log -1 --pretty=%B) -PR=$(echo $COMMENT | grep -oP "Merge pull request #\K(([0-9]*))(?=.*)") - -if [ -z "$PR" ]; then - echo "Unable to get PR number: $PR from: $COMMENT" - exit 0 -fi - -# create docker image containous/traefik -echo "Updating docker containous/traefik image..." -docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS -docker tag containous/traefik containous/traefik:pr-${PR} -docker push containous/traefik:pr-${PR} -docker tag containous/traefik containous/traefik:experimental -docker push containous/traefik:experimental - -echo "Deployed" diff --git a/script/deploy.sh b/script/deploy.sh index 0e5fd93c0..346b2a09f 100755 --- a/script/deploy.sh +++ b/script/deploy.sh @@ -18,37 +18,6 @@ eval "$(ssh-agent -s)" chmod 600 ~/.ssh/traefik.id_rsa ssh-add ~/.ssh/traefik.id_rsa -# download github release -echo "Downloading ghr..." -curl -LOs https://github.com/tcnksm/ghr/releases/download/v0.5.0/ghr_v0.5.0_linux_amd64.zip -unzip -q ghr_v0.5.0_linux_amd64.zip -sudo mv ghr /usr/bin/ghr -sudo chmod +x /usr/bin/ghr - -# github release and tag -echo "Github release..." -tar cfz dist/traefik-${VERSION}.src.tar.gz --exclude-vcs --exclude dist . -ghr -t $GITHUB_TOKEN -u containous -r traefik ${VERSION} dist/ - -# update docs.traefik.io -echo "Generating and updating documentation..." -# DOESN'T WORK :'( -# git remote add ssh git@github.com:containous/traefik.git -# mkdocs gh-deploy -m $VERSION -c -r ssh - -mkdir site -cd site -git init -git remote add origin git@github.com:containous/traefik.git -git fetch origin -git checkout gh-pages -cd .. -mkdocs build --clean -cd site -git add . -echo $VERSION | git commit --file - -git push -q -f origin gh-pages > /dev/null 2>&1 - # update traefik-library-image repo (official Docker image) echo "Updating traefik-library-imag repo..." git clone git@github.com:containous/traefik-library-image.git diff --git a/script/test-integration b/script/test-integration index 7f30406be..b889fb446 100755 --- a/script/test-integration +++ b/script/test-integration @@ -4,7 +4,7 @@ set -e export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export DEST=. -TESTFLAGS="${TESTFLAGS} -test.timeout=30m -check.v" +TESTFLAGS="${TESTFLAGS} -test.timeout=9m -check.v" if [ -n "$VERBOSE" ]; then TESTFLAGS="${TESTFLAGS} -v"