Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync with go module template and update deps
- Loading branch information
Showing
49 changed files
with
1,191 additions
and
1,462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
# code coverage and quality reports | ||
*.out | ||
|
||
# binaries | ||
cc-test-reporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,51 @@ | ||
sudo: false | ||
language: go | ||
os: linux | ||
|
||
cache: | ||
directories: | ||
- $HOME/.cache/go-build | ||
- $HOME/gopath/pkg/mod | ||
- "$HOME/.cache/go-build" | ||
- "$HOME/gopath/pkg/mod" | ||
|
||
env: | ||
global: | ||
- CODECLIMATE=https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 | ||
- GO111MODULE=on | ||
- GOFLAGS=-mod=vendor | ||
|
||
go: | ||
- master | ||
- 1.x | ||
- 1.11.x | ||
- 1.12.x | ||
- 1.13.x | ||
- 1.14.x | ||
|
||
go_import_path: go.octolab.org/toolkit/cli | ||
|
||
jobs: | ||
allow_failures: | ||
- go: master | ||
|
||
before_script: | ||
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then curl -L $CODECLIMATE > ./cc-test-reporter; fi | ||
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then chmod +x ./cc-test-reporter; fi | ||
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then ./cc-test-reporter before-build; fi | ||
- | | ||
if [[ $TRAVIS_GO_VERSION == 1.14* ]]; then | ||
curl -L $CODECLIMATE > /home/travis/gopath/bin/cc-test-reporter | ||
chmod +x /home/travis/gopath/bin/cc-test-reporter | ||
cc-test-reporter before-build | ||
fi | ||
script: | ||
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then make test-with-coverage-profile; else make test; fi | ||
- | | ||
if [[ $TRAVIS_GO_VERSION == 1.14* ]]; then | ||
make test-with-coverage-profile | ||
else | ||
make test | ||
fi | ||
after_script: | ||
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then export EXIT_CODE=$TRAVIS_TEST_RESULT; fi | ||
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then export PREFIX=$(basename $(go list -m)); fi | ||
- if [[ $TRAVIS_GO_VERSION == 1.13* ]]; then ./cc-test-reporter after-build -t gocov -p $PREFIX; fi | ||
- | | ||
if [[ $TRAVIS_GO_VERSION == 1.14* ]]; then | ||
cc-test-reporter after-build -t gocov -p $(basename $(go list -m)) --exit-code $TRAVIS_TEST_RESULT | ||
fi | ||
notifications: | ||
slack: octolab:1eMS7IqOArBipiu31jYVd0cN | ||
slack: | ||
secure: VHWCBgcxc9BejOM9pSTqAyXzZN6DEW/UzJKGkNX+lWL1wREIDmJ7iFKM1ZUfTwU6j5WtOE4ruJlfpUlmmlzicqTZUBIkGCJH6LoX9kwP+6IKBD/aCFuGwRuptKKU0I8pLV6Jvs2m2WQBlKQrfSX9IIM4zqb0M+ST067huwRscJP/4bJJ2aPg+dQiGeR3VHLit/izMRzk/IjnT093i3qGlXDhdRZrxnlqd5flmSlnU5sBTfRr9wHcMdrxIXK3smhay/w8M7XeuIgpv9mUjizmg5e+bQkm4e8AZZxYasvUQAdLWWylcwMk9xPHYy9QGKRFTSl1weon6rRrXWVXP1b9PpR8PYeg1qPvV0k+QNKokDdveqzd2N6ZAilRqAMNVYYYnI1fgLTySfBdIXKMwZAM8OnQk0BBBfyPp+FkoB/zewC6pFy54w7gM2pjefdV3RWjOsc6ux/W6Ro2msZufDW1OzJU4Yj4uzWCtZdsjjkGcA2fB9cDQWlhhmkYVpc7tDfhQ2GFgRmTvuvCvZP2jfUbHcMTgK1CW0+zbX5gsGorWCrMvHL6boV3iRydndOvCFKBUFdDDPvKBjbRIJRuoNprpSmhjWwRYZdUUD+HU/S64vm4mKiWoLhP3hUeDHKSg26F7GomvEGoVz2MCkaqXteRUi9tAhNJIjy88a/l354IMWg= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,108 @@ | ||
# sourced by https://github.com/octomation/makefiles | ||
|
||
.DEFAULT_GOAL = test-with-coverage | ||
|
||
SHELL = /bin/bash -euo pipefail | ||
|
||
GO111MODULE = on | ||
GOFLAGS = -mod=vendor | ||
GOPROXY = https://proxy.golang.org,https://gocenter.io,direct | ||
MODULE = $(shell go list -m) | ||
PATHS = $(shell go list ./... | sed -e "s|$(shell go list -m)/\{0,1\}||g") | ||
SHELL = /bin/bash -euo pipefail | ||
GOPRIVATE = go.octolab.net | ||
GOPROXY = direct | ||
LOCAL = $(MODULE) | ||
MODULE = `go list -m` | ||
PACKAGES = `go list ./... 2> /dev/null` | ||
PATHS = $(shell echo $(PACKAGES) | sed -e "s|$(MODULE)/\{0,1\}||g") | ||
TIMEOUT = 1s | ||
|
||
ifeq (, $(PACKAGES)) | ||
PACKAGES = $(MODULE) | ||
endif | ||
|
||
.DEFAULT_GOAL = test-with-coverage | ||
ifeq (, $(PATHS)) | ||
PATHS = . | ||
endif | ||
|
||
.PHONY: env | ||
env: | ||
@echo "GO111MODULE: $(shell go env GO111MODULE)" | ||
@echo "GOFLAGS: $(shell go env GOFLAGS)" | ||
@echo "GOPRIVATE: $(shell go env GOPRIVATE)" | ||
@echo "GOPROXY: $(shell go env GOPROXY)" | ||
@echo "GONOPROXY: $(shell go env GONOPROXY)" | ||
@echo "GOSUMDB: $(shell go env GOSUMDB)" | ||
@echo "GONOSUMDB: $(shell go env GONOSUMDB)" | ||
export GO111MODULE := $(GO111MODULE) | ||
export GOFLAGS := $(GOFLAGS) | ||
export GOPRIVATE := $(GOPRIVATE) | ||
export GOPROXY := $(GOPROXY) | ||
|
||
.PHONY: go-env | ||
go-env: | ||
@echo "GO111MODULE: `go env GO111MODULE`" | ||
@echo "GOFLAGS: $(strip `go env GOFLAGS`)" | ||
@echo "GOPRIVATE: $(strip `go env GOPRIVATE`)" | ||
@echo "GOPROXY: $(strip `go env GOPROXY`)" | ||
@echo "LOCAL: $(LOCAL)" | ||
@echo "MODULE: $(MODULE)" | ||
@echo "PATHS: $(PATHS)" | ||
@echo "SHELL: $(SHELL)" | ||
@echo "PACKAGES: $(PACKAGES)" | ||
@echo "PATHS: $(strip $(PATHS))" | ||
@echo "TIMEOUT: $(TIMEOUT)" | ||
|
||
|
||
.PHONY: deps | ||
deps: | ||
@go mod tidy && go mod vendor && go mod verify | ||
@go mod download | ||
@if [[ "`go env GOFLAGS`" =~ -mod=vendor ]]; then go mod vendor; fi | ||
|
||
.PHONY: deps-update | ||
deps-update: | ||
@go get -mod= -u all | ||
.PHONY: deps-check | ||
deps-check: | ||
@go mod verify | ||
@if command -v egg > /dev/null; then \ | ||
egg deps check license; \ | ||
egg deps check version; \ | ||
fi | ||
|
||
.PHONY: deps-clean | ||
deps-clean: | ||
@go clean -modcache | ||
|
||
.PHONY: format | ||
format: | ||
@goimports -local $(dir $(shell go list -m)) -ungroup -w $(PATHS) | ||
.PHONY: deps-shake | ||
deps-shake: | ||
@go mod tidy | ||
|
||
.PHONY: generate | ||
generate: | ||
@go generate $(MODULE)/... | ||
|
||
.PHONY: refresh | ||
refresh: deps-update deps generate format test-with-coverage | ||
.PHONY: update | ||
update: selector = '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' | ||
update: | ||
@if command -v egg > /dev/null; then \ | ||
packages="`egg deps list`"; \ | ||
else \ | ||
packages="`go list -f $(selector) -m all`"; \ | ||
fi; go get -mod= -u $$packages | ||
|
||
.PHONY: update-all | ||
update-all: | ||
@go get -mod= -u ./... | ||
|
||
.PHONY: test | ||
test: | ||
# fix broken builds | ||
# go: downloading go.octolab.org v0.0.5 | ||
# go: module lookup disabled by -mod=vendor | ||
# Makefile:50: recipe for target 'test' failed | ||
# @go test -race -timeout $(TIMEOUT) $(MODULE)/... | ||
@GOFLAGS=-mod= go test -race -timeout $(TIMEOUT) $(MODULE)/... | ||
@go test -race -timeout $(TIMEOUT) $(PACKAGES) | ||
|
||
.PHONY: test-clean | ||
test-clean: | ||
@go clean -testcache | ||
|
||
.PHONY: test-with-coverage | ||
test-with-coverage: | ||
@go test -cover -timeout $(TIMEOUT) $(MODULE)/... | column -t | sort -r | ||
@go test -cover -timeout $(TIMEOUT) $(PACKAGES) | column -t | sort -r | ||
|
||
.PHONY: test-with-coverage-profile | ||
test-with-coverage-profile: | ||
@go test -cover -covermode count -coverprofile c.out -timeout $(TIMEOUT) $(MODULE)/... | ||
@go test -cover -covermode count -coverprofile c.out -timeout $(TIMEOUT) $(PACKAGES) | ||
|
||
.PHONY: format | ||
format: | ||
@goimports -local $(LOCAL) -ungroup -w $(PATHS) | ||
|
||
.PHONY: generate | ||
generate: | ||
@go generate $(PACKAGES) | ||
|
||
|
||
.PHONY: clean | ||
clean: deps-clean test-clean | ||
|
||
.PHONY: env | ||
env: go-env | ||
|
||
.PHONY: refresh | ||
refresh: deps-shake update deps generate format test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.