-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'golangci' of github.com:gssbzn/promptui into gssbzn-gol…
…angci
- Loading branch information
Showing
11 changed files
with
58 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
vendor | ||
all-cover.txt | ||
bin/ |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
run: | ||
deadline: 5m | ||
|
||
issues: | ||
# Disable maximums so we see all issues | ||
max-per-linter: 0 | ||
max-same-issues: 0 | ||
|
||
# golangci-lint ignores missing docstrings by default. That's no good! | ||
exclude-use-default: false | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- misspell | ||
- golint | ||
- goimports | ||
- ineffassign | ||
- deadcode | ||
- gofmt | ||
- govet | ||
- structcheck | ||
- unconvert | ||
- megacheck | ||
- typecheck | ||
- varcheck |
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,57 +1,40 @@ | ||
LINTERS=$(shell grep "// lint" tools/tools.go | awk '{gsub(/\"/, "", $$1); print $$1}' | awk -F / '{print $$NF}') \ | ||
gofmt \ | ||
vet | ||
|
||
ci: $(LINTERS) cover | ||
export GO111MODULE := on | ||
export PATH := ./bin:$(PATH) | ||
|
||
ci: bootstrap lint cover | ||
.PHONY: ci | ||
|
||
################################################# | ||
# Bootstrapping for base golang package and tool deps | ||
################################################# | ||
|
||
CMD_PKGS=$(shell grep ' "' tools/tools.go | awk -F '"' '{print $$2}') | ||
|
||
define VENDOR_BIN_TMPL | ||
tools/vendor/bin/$(notdir $(1)): tools/vendor/$(1) | vendor tools/vendor | ||
GOBIN=`pwd`/tools/vendor/bin sh -c 'cd tools && go install ./vendor/$(1)' | ||
VENDOR_BINS += tools/vendor/bin/$(notdir $(1)) | ||
tools/vendor/$(1): tools/vendor | ||
endef | ||
|
||
$(foreach cmd_pkg,$(CMD_PKGS),$(eval $(call VENDOR_BIN_TMPL,$(cmd_pkg)))) | ||
|
||
$(patsubst %,%-bin,$(filter-out gofmt vet,$(LINTERS))): %-bin: tools/vendor/bin/% | ||
gofmt-bin vet-bin: | ||
|
||
tools/vendor: tools/go.sum | ||
GO111MODULE=on sh -c 'cd tools && go mod vendor' | ||
|
||
vendor: go.sum | ||
GO111MODULE=on go mod vendor | ||
bootstrap: | ||
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.21.0 | ||
.PHONY: bootstrap | ||
|
||
mod-update: | ||
GO111MODULE=on go get -u -m | ||
GO111MODULE=on go mod tidy | ||
go get -u -m | ||
go mod tidy | ||
|
||
mod-tidy: | ||
GO111MODULE=on go mod tidy | ||
go mod tidy | ||
|
||
.PHONY: $(CMD_PKGS) | ||
.PHONY: mod-update mod-tidy | ||
|
||
################################################# | ||
# Test and linting | ||
################################################# | ||
# Run all the linters | ||
lint: | ||
bin/golangci-lint run ./... | ||
.PHONY: lint | ||
|
||
test: vendor | ||
test: | ||
CGO_ENABLED=0 go test $$(go list ./... | grep -v generated) | ||
.PHONY: test | ||
|
||
$(LINTERS): %: tools/vendor/bin/gometalinter %-bin tools/vendor | ||
PATH=`pwd`/tools/vendor/bin:$$PATH gometalinter --tests --disable-all --vendor \ | ||
--deadline=5m -s data --enable $@ ./... | ||
|
||
COVER_TEST_PKGS:=$(shell find . -type f -name '*_test.go' | grep -v vendor | rev | cut -d "/" -f 2- | rev | grep -v generated | sort -u) | ||
COVER_TEST_PKGS:=$(shell find . -type f -name '*_test.go' | rev | cut -d "/" -f 2- | rev | grep -v generated | sort -u) | ||
$(COVER_TEST_PKGS:=-cover): %-cover: all-cover.txt | ||
@CGO_ENABLED=0 go test -v [email protected] -covermode=atomic ./$* | ||
@if [ -f [email protected] ]; then \ | ||
|
@@ -62,7 +45,5 @@ $(COVER_TEST_PKGS:=-cover): %-cover: all-cover.txt | |
all-cover.txt: | ||
echo "mode: atomic" > all-cover.txt | ||
|
||
cover: vendor all-cover.txt $(COVER_TEST_PKGS:=-cover) | ||
|
||
.PHONY: $(LINTERS) test | ||
cover: all-cover.txt $(COVER_TEST_PKGS:=-cover) | ||
.PHONY: cover all-cover.txt |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.