From f84cabab4c94cafad985e35671f586f225311186 Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Tue, 20 Feb 2018 00:10:19 -0800 Subject: [PATCH 01/13] add versioned dockerfiles --- .travis.yml | 24 ++++++++++++++++++++---- Dockerfiles/Dockerfile.go1.10 | 9 +++++++++ Dockerfiles/Dockerfile.go1.8 | 9 +++++++++ Dockerfiles/Dockerfile.go1.9 | 9 +++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 Dockerfiles/Dockerfile.go1.10 create mode 100644 Dockerfiles/Dockerfile.go1.8 create mode 100644 Dockerfiles/Dockerfile.go1.9 diff --git a/.travis.yml b/.travis.yml index 33f94f5..965cf6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,23 @@ language: go -go: - - 1.6 - - 1.5 +sudo: required +services: + - docker +matrix: + include: + - go: "1.10" + env: GO_VERSION=1.10 + - go: "1.9" + env: GO_VERSION=1.9 + - go: "1.8" + env: GO_VERSION=1.8 env: - - GO15VENDOREXPERIMENT=1 + global: + - WATCHER_VERSION=0.2.4 + +matrix: + fast_finish: true + +script: | + docker build -f Dockerfiles/Dockerfile.go$GO_VERSION -t canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION . + docker push canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION diff --git a/Dockerfiles/Dockerfile.go1.10 b/Dockerfiles/Dockerfile.go1.10 new file mode 100644 index 0000000..4b112f6 --- /dev/null +++ b/Dockerfiles/Dockerfile.go1.10 @@ -0,0 +1,9 @@ +FROM golang:1.10-alpine3.7 + +VOLUME /go/src + +ARG WATCHER_VERSION 0.2.4 + +ADD https://github.com/canthefason/go-watcher/releases/download/v${WATCHER_VERSION}/watcher-${WATCHER_VERSION}-linux-amd64 $GOPATH/bin/watcher + +CMD ["watcher"] diff --git a/Dockerfiles/Dockerfile.go1.8 b/Dockerfiles/Dockerfile.go1.8 new file mode 100644 index 0000000..ae1cb93 --- /dev/null +++ b/Dockerfiles/Dockerfile.go1.8 @@ -0,0 +1,9 @@ +FROM golang:1.8-alpine3.6 + +VOLUME /go/src + +ARG WATCHER_VERSION 0.2.4 + +ADD https://github.com/canthefason/go-watcher/releases/download/v${WATCHER_VERSION}/watcher-${WATCHER_VERSION}-linux-amd64 $GOPATH/bin/watcher + +CMD ["watcher"] diff --git a/Dockerfiles/Dockerfile.go1.9 b/Dockerfiles/Dockerfile.go1.9 new file mode 100644 index 0000000..833c8fc --- /dev/null +++ b/Dockerfiles/Dockerfile.go1.9 @@ -0,0 +1,9 @@ +FROM golang:1.9-alpine3.7 + +VOLUME /go/src + +ARG WATCHER_VERSION 0.2.4 + +ADD https://github.com/canthefason/go-watcher/releases/download/v${WATCHER_VERSION}/watcher-${WATCHER_VERSION}-linux-amd64 $GOPATH/bin/watcher + +CMD ["watcher"] From 8e38fdebc068f66839c81c2224e5d4275019c75f Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Wed, 21 Feb 2018 23:26:01 -0800 Subject: [PATCH 02/13] update travis.yml --- .travis.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 965cf6c..cbe1d94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,12 @@ language: go sudo: required services: - docker -matrix: - include: - - go: "1.10" - env: GO_VERSION=1.10 - - go: "1.9" - env: GO_VERSION=1.9 - - go: "1.8" - env: GO_VERSION=1.8 + +go: + - GO_VERSION=1.10 + - GO_VERSION=1.9 + - GO_VERSION=1.8 + env: global: - WATCHER_VERSION=0.2.4 From c3181e62ff47307af30f76c8d1a079899891c50a Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Wed, 21 Feb 2018 23:32:03 -0800 Subject: [PATCH 03/13] version extracter --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index cbe1d94..d8d9c21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,9 @@ services: - docker go: - - GO_VERSION=1.10 - - GO_VERSION=1.9 - - GO_VERSION=1.8 + - 1.10 + - 1.9 + - 1.8 env: global: @@ -16,6 +16,6 @@ matrix: fast_finish: true script: | - docker build -f Dockerfiles/Dockerfile.go$GO_VERSION -t canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION . + docker build -f Dockerfiles/Dockerfile.$(go version | awk '{print $3}') -t canthefason/go-watcher:$WATCHER_VERSION-$(go version | awk '{print $3}') . docker push canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION From 5484a3b57d088e8360b303448bfff651dbcbeed8 Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Wed, 21 Feb 2018 23:35:46 -0800 Subject: [PATCH 04/13] string golang version --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d8d9c21..8559fe9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,9 @@ services: - docker go: - - 1.10 - - 1.9 - - 1.8 + - "1.10" + - "1.9" + - "1.8" env: global: From dfd0893effbf67f3fe0d11eaca04d7ef7392ab54 Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Wed, 21 Feb 2018 23:40:57 -0800 Subject: [PATCH 05/13] fix envvar --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8559fe9..d88ddcc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ matrix: fast_finish: true script: | - docker build -f Dockerfiles/Dockerfile.$(go version | awk '{print $3}') -t canthefason/go-watcher:$WATCHER_VERSION-$(go version | awk '{print $3}') . + GO_VERSION=$(go version | awk 'print $3') + docker build -f Dockerfiles/Dockerfile."$GO_VERSION" -t canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION . docker push canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION From ade93d4ecd5b22961e0b985eb12855866679fc89 Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Wed, 21 Feb 2018 23:41:12 -0800 Subject: [PATCH 06/13] limit scope --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d88ddcc..3d217d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ services: go: - "1.10" - - "1.9" - - "1.8" + #- "1.9" + #- "1.8" env: global: From 613ca9feb59e4b358902229384fe2d4cf4a7e9a6 Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Wed, 21 Feb 2018 23:54:15 -0800 Subject: [PATCH 07/13] build.sh --- .travis.yml | 6 +----- build.sh | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100755 build.sh diff --git a/.travis.yml b/.travis.yml index 3d217d5..180810e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,4 @@ env: matrix: fast_finish: true -script: | - GO_VERSION=$(go version | awk 'print $3') - docker build -f Dockerfiles/Dockerfile."$GO_VERSION" -t canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION . - docker push canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION - +script: ./build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..1aa2ef6 --- /dev/null +++ b/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash +GO_VERSION=$(go version | awk '{print $3}') + +/bin/bash -c "docker build -f Dockerfiles/Dockerfile.$GO_VERSION" -t "canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION" . + +docker push canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION From ececf27f293a157dee0c656337693d838e66f792 Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Thu, 22 Feb 2018 00:00:02 -0800 Subject: [PATCH 08/13] fix --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 1aa2ef6..d57d98c 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ -#!/bin/bash +#!/bin/bash -x GO_VERSION=$(go version | awk '{print $3}') -/bin/bash -c "docker build -f Dockerfiles/Dockerfile.$GO_VERSION" -t "canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION" . +docker build -f Dockerfiles/Dockerfile.$GO_VERSION -t canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION . docker push canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION From dd180bd655f11fb4085afba2e509bbb64147d81a Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Thu, 22 Feb 2018 00:04:44 -0800 Subject: [PATCH 09/13] fix --- Dockerfiles/Dockerfile.go1.10 | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfiles/Dockerfile.go1.10 b/Dockerfiles/Dockerfile.go1.10 index 4b112f6..ff682e8 100644 --- a/Dockerfiles/Dockerfile.go1.10 +++ b/Dockerfiles/Dockerfile.go1.10 @@ -2,7 +2,7 @@ FROM golang:1.10-alpine3.7 VOLUME /go/src -ARG WATCHER_VERSION 0.2.4 +ARG WATCHER_VERSION=0.2.4 ADD https://github.com/canthefason/go-watcher/releases/download/v${WATCHER_VERSION}/watcher-${WATCHER_VERSION}-linux-amd64 $GOPATH/bin/watcher diff --git a/build.sh b/build.sh index d57d98c..1872c81 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash -x +#!/bin/bash -xe GO_VERSION=$(go version | awk '{print $3}') docker build -f Dockerfiles/Dockerfile.$GO_VERSION -t canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION . From c22424336ca50e8635faea46422615c5613d1dc2 Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Thu, 22 Feb 2018 00:11:53 -0800 Subject: [PATCH 10/13] branch protection --- .travis.yml | 6 +++++- build.sh | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 180810e..f97038f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,8 @@ env: matrix: fast_finish: true -script: ./build.sh +script: go test ./... + +after_success: + ./build.sh + diff --git a/build.sh b/build.sh index 1872c81..3b6da07 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,9 @@ #!/bin/bash -xe -GO_VERSION=$(go version | awk '{print $3}') +#if [ "$TRAVIS_BRANCH" == "master" ]; then + docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" + GO_VERSION=$(go version | awk '{print $3}') -docker build -f Dockerfiles/Dockerfile.$GO_VERSION -t canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION . + docker build -f Dockerfiles/Dockerfile.$GO_VERSION -t canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION . -docker push canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION + docker push canthefason/go-watcher:$WATCHER_VERSION-$GO_VERSION +#fi From a658f0cee1698dd3a163383158b743b031ced169 Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Thu, 22 Feb 2018 00:15:24 -0800 Subject: [PATCH 11/13] fix tests --- common_test.go | 4 ++-- watch.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common_test.go b/common_test.go index 7847e1f..ae04adf 100644 --- a/common_test.go +++ b/common_test.go @@ -8,7 +8,7 @@ func TestParamsGet(t *testing.T) { run := params.Get("run") if run != "statler" { - t.Error("Expected statler but got %s in params.Get()", run) + t.Errorf("Expected statler but got %s in params.Get()", run) t.FailNow() } } @@ -20,7 +20,7 @@ func TestParamsClone(t *testing.T) { params.cloneRunFlag() watch := params.Get("watch") if watch != "statler" { - t.Error("Expected statler but got %s when watch param is not set", watch) + t.Errorf("Expected statler but got %s when watch param is not set", watch) } params.Watcher["watch"] = "waldorf" diff --git a/watch.go b/watch.go index 0704936..d576f88 100644 --- a/watch.go +++ b/watch.go @@ -41,7 +41,7 @@ func MustRegisterWatcher(params *Params) *Watcher { if watchVendorStr != "" { watchVendor, err = strconv.ParseBool(watchVendorStr) if err != nil { - log.Println("Wrong watch-vendor value: %s (default=false)", watchVendorStr) + log.Printf("Wrong watch-vendor value: %s (default=false)\n", watchVendorStr) } } From d55537b1c6947fd713e2bbf5a635f3f4adb0155f Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Thu, 22 Feb 2018 00:18:13 -0800 Subject: [PATCH 12/13] enable the last 3 go versions --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f97038f..3fbee5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ services: go: - "1.10" - #- "1.9" - #- "1.8" + - "1.9" + - "1.8" env: global: From 1a2dbb99dfa8784785da63a6d6c582a75c82d098 Mon Sep 17 00:00:00 2001 From: Jon Yucel Date: Thu, 22 Feb 2018 07:47:59 -0800 Subject: [PATCH 13/13] build watcher binary --- Dockerfiles/Dockerfile.go1.10 | 2 +- Dockerfiles/Dockerfile.go1.8 | 4 ++-- Dockerfiles/Dockerfile.go1.9 | 4 ++-- build.sh | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfiles/Dockerfile.go1.10 b/Dockerfiles/Dockerfile.go1.10 index ff682e8..47a432c 100644 --- a/Dockerfiles/Dockerfile.go1.10 +++ b/Dockerfiles/Dockerfile.go1.10 @@ -4,6 +4,6 @@ VOLUME /go/src ARG WATCHER_VERSION=0.2.4 -ADD https://github.com/canthefason/go-watcher/releases/download/v${WATCHER_VERSION}/watcher-${WATCHER_VERSION}-linux-amd64 $GOPATH/bin/watcher +ADD watcher $GOPATH/bin/watcher CMD ["watcher"] diff --git a/Dockerfiles/Dockerfile.go1.8 b/Dockerfiles/Dockerfile.go1.8 index ae1cb93..a6beadc 100644 --- a/Dockerfiles/Dockerfile.go1.8 +++ b/Dockerfiles/Dockerfile.go1.8 @@ -2,8 +2,8 @@ FROM golang:1.8-alpine3.6 VOLUME /go/src -ARG WATCHER_VERSION 0.2.4 +ARG WATCHER_VERSION=0.2.4 -ADD https://github.com/canthefason/go-watcher/releases/download/v${WATCHER_VERSION}/watcher-${WATCHER_VERSION}-linux-amd64 $GOPATH/bin/watcher +ADD watcher $GOPATH/bin/watcher CMD ["watcher"] diff --git a/Dockerfiles/Dockerfile.go1.9 b/Dockerfiles/Dockerfile.go1.9 index 833c8fc..d54130c 100644 --- a/Dockerfiles/Dockerfile.go1.9 +++ b/Dockerfiles/Dockerfile.go1.9 @@ -2,8 +2,8 @@ FROM golang:1.9-alpine3.7 VOLUME /go/src -ARG WATCHER_VERSION 0.2.4 +ARG WATCHER_VERSION=0.2.4 -ADD https://github.com/canthefason/go-watcher/releases/download/v${WATCHER_VERSION}/watcher-${WATCHER_VERSION}-linux-amd64 $GOPATH/bin/watcher +ADD watcher $GOPATH/bin/watcher CMD ["watcher"] diff --git a/build.sh b/build.sh index 3b6da07..2c39c1b 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,6 @@ #!/bin/bash -xe #if [ "$TRAVIS_BRANCH" == "master" ]; then + go build -o watcher cmd/watcher/main.go docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" GO_VERSION=$(go version | awk '{print $3}')