-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Ignore generated code by default, added -g flag to analyze generated code
- Loading branch information
Showing
13 changed files
with
176 additions
and
51 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,4 +1,7 @@ | ||
language: go | ||
|
||
go: | ||
- 1.14.x | ||
- 1.14.x | ||
|
||
before_script: | ||
- make lint-install |
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,31 +1,53 @@ | ||
BIN_DIR ?= $(shell go env GOPATH)/bin | ||
MAKEFLAGS += --warn-undefined-variables | ||
SHELL := bash | ||
.SHELLFLAGS := -euo pipefail -c | ||
.DEFAULT_GOAL := all | ||
|
||
default: test | ||
BIN_DIR ?= $(shell go env GOPATH)/bin | ||
export PATH := $(PATH):$(BIN_DIR) | ||
|
||
.PHONY: deps | ||
deps: ## download go modules | ||
go mod download | ||
|
||
fmt: lint/install # ensure consistent code style | ||
.PHONY: fmt | ||
fmt: lint/check ## ensure consistent code style | ||
go run oss.indeed.com/go/go-groups -w . | ||
gofmt -s -w . | ||
golangci-lint run --fix > /dev/null 2>&1 || true | ||
go mod tidy | ||
|
||
lint/install: | ||
.PHONY: lint/check | ||
lint/check: | ||
@if ! golangci-lint --version > /dev/null 2>&1; then \ | ||
echo "Installing golangci-lint"; \ | ||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(BIN_DIR) v1.28.3; \ | ||
echo -e "\033[0;33mgolangci-lint is not installed: run \`\033[0;32mmake lint-install\033[0m\033[0;33m\` or install it from https://golangci-lint.run\033[0m"; \ | ||
exit 1; \ | ||
fi | ||
|
||
lint: lint/install ## run golangci-lint | ||
@if ! golangci-lint run; then \ | ||
echo "\033[0;33mdetected fmt problems: run \`\033[0;32mmake fmt\033[0m\`"; \ | ||
exit 1; \ | ||
fi | ||
.PHONY: lint-install | ||
lint-install: ## installs golangci-lint to the go bin dir | ||
@if ! golangci-lint --version > /dev/null 2>&1; then \ | ||
echo "Installing golangci-lint"; \ | ||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(BIN_DIR) v1.30.0; \ | ||
fi | ||
|
||
.PHONY: lint | ||
lint: lint/check ## run golangci-lint | ||
golangci-lint run | ||
@if [ -n "$$(gofmt -s -l .)" ] || [ -n "$$(go run oss.indeed.com/go/go-groups -d .)" ]; then \ | ||
echo -e "\033[0;33mdetected fmt problems: run \`\033[0;32mmake fmt\033[0m\033[0;33m\`\033[0m"; \ | ||
exit 1; \ | ||
fi | ||
|
||
.PHONY: test | ||
test: lint ## run go tests | ||
go vet ./... | ||
go test ./... -race | ||
|
||
.PHONY: all | ||
all: test | ||
|
||
.PHONY: help | ||
help: ## displays this help message | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_\/-]+:.*?## / {printf "\033[34m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \ | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_\/-]+:.*?## / {printf "\033[34m%-12s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \ | ||
sort | \ | ||
grep -v '#' | ||
grep -v '#' |
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
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.