From 7ef3494c9bb215fc8657d16c4a0b8a15bd6dc28a Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Sat, 9 Sep 2017 17:28:13 -0300 Subject: [PATCH] Add support for travis-ci --- .travis.yml | 33 +++++++++++++++++++++++++++++++++ Makefile | 24 ++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..7b8aed78 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,33 @@ +sudo: required + +services: + - docker + +language: go + +notifications: + email: true + +go: + - 1.9 + +go_import_path: github.com/aledbf/kube-keepalived + +env: + global: + # to add additional secure variables: + # docker run --rm caktux/travis-cli encrypt key=value -r kubernetes/ingress + - RELEASE="ci-${TRAVIS_BUILD_ID}" + +jobs: + include: + - stage: Static Check + script: + - go get github.com/golang/lint/golint + - make fmt lint vet + - stage: Coverage + script: + - go get github.com/mattn/goveralls + - go get github.com/modocache/gover + - if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi + - make cover diff --git a/Makefile b/Makefile index 12da9101..0126159b 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ PREFIX = aledbf/kube-keepalived-vip BUILD_IMAGE = build-keepalived PKG = github.com/aledbf/kube-keepalived-vip +GO_LIST_FILES=$(shell go list ${PKG}/... | grep -v vendor) + controller: clean CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-s -w' \ -o rootfs/kube-keepalived-vip \ @@ -26,3 +28,25 @@ push: container clean: rm -f kube-keepalived-vip + +.PHONY: fmt +fmt: + @go list -f '{{if len .TestGoFiles}}"gofmt -s -l {{.Dir}}"{{end}}' ${GO_LIST_FILES} | xargs -L 1 sh -c + +.PHONY: lint +lint: + @go list -f '{{if len .TestGoFiles}}"golint -min_confidence=0.85 {{.Dir}}/..."{{end}}' ${GO_LIST_FILES} | xargs -L 1 sh -c + +.PHONY: test +test: + @go test -v -race -tags "$(BUILDTAGS) cgo" ${GO_LIST_FILES} + +.PHONY: cover +cover: + @go list -f '{{if len .TestGoFiles}}"go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"{{end}}' ${GO_LIST_FILES} | xargs -L 1 sh -c + gover + goveralls -coverprofile=gover.coverprofile -service travis-ci + +.PHONY: vet +vet: + @go vet ${GO_LIST_FILES}