-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
129 additions
and
69 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
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,52 +1,100 @@ | ||
# sourced by https://github.com/octomation/makefiles | ||
|
||
.DEFAULT_GOAL = test-with-coverage | ||
|
||
SHELL = /bin/bash -euo pipefail | ||
|
||
GO111MODULE = on | ||
GOFLAGS = -mod=vendor | ||
MODULE = $(shell go list -m) | ||
PACKAGES = $(shell go list ./...) | ||
PATHS = $(shell go list ./... | sed -e "s|\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 | ||
|
||
.DEFAULT_GOAL = test-with-coverage | ||
ifeq (, $(PACKAGES)) | ||
PACKAGES = $(MODULE) | ||
endif | ||
|
||
.PHONY: env | ||
env: | ||
@echo "GO111MODULE: $(GO111MODULE)" | ||
@echo "GOFLAGS: $(GOFLAGS)" | ||
ifeq (, $(PATHS)) | ||
PATHS = . | ||
endif | ||
|
||
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 "PACKAGES: $(PACKAGES)" | ||
@echo "PATHS: $(PATHS)" | ||
@echo "SHELL: $(SHELL)" | ||
@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: format | ||
format: | ||
@goimports -local $(dir $(shell go list -m)) -ungroup -w $(PATHS) | ||
.PHONY: deps-clean | ||
deps-clean: | ||
@go clean -modcache | ||
|
||
.PHONY: generate | ||
generate: | ||
@go generate $(PACKAGES) | ||
.PHONY: deps-shake | ||
deps-shake: | ||
@go mod tidy | ||
|
||
.PHONY: update | ||
update: selector = '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' | ||
update: | ||
@go get -mod= -u | ||
|
||
.PHONY: refresh | ||
refresh: update deps generate format test-with-coverage | ||
@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: | ||
@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) $(PACKAGES) | column -t | sort -r | ||
|
||
.PHONY: test-with-coverage-profile | ||
test-with-coverage-profile: | ||
@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