This repository has been archived by the owner on Aug 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds reviewdog as a way to integrate linting with pull requests. Already in use on fogg. Test Plan travis ci References
- Loading branch information
Showing
6 changed files
with
68 additions
and
27 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 |
---|---|---|
|
@@ -7,3 +7,4 @@ coverage.out | |
cmd/testdata | ||
|
||
dist | ||
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,8 @@ | ||
runner: | ||
golangci: | ||
cmd: ./bin/golangci-lint run --out-format=line-number | ||
errorformat: | ||
- '%E%f:%l:%c: %m' | ||
- '%E%f:%l: %m' | ||
- '%C%.%#' | ||
level: warning |
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,48 +1,69 @@ | ||
.PHONY: setup | ||
SHA=$(shell git rev-parse --short HEAD) | ||
VERSION=$(shell cat VERSION) | ||
DIRTY=false | ||
# TODO add release flag | ||
GO_PACKAGE=$(shell go list) | ||
LDFLAGS=-ldflags "-w -s -X $(GO_PACKAGE)/util.GitSha=${SHA} -X $(GO_PACKAGE)/util.Version=${VERSION} -X $(GO_PACKAGE)/util.Dirty=${DIRTY}" | ||
export GO111MODULE=on | ||
|
||
setup: # setup development dependencies | ||
export GO111MODULE=on | ||
go get github.com/rakyll/gotest | ||
go install github.com/rakyll/gotest | ||
go get -u github.com/haya14busa/goverage | ||
GOFLAGS='' go get -u github.com/haya14busa/goverage | ||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh | ||
curl -L https://raw.githubusercontent.com/chanzuckerberg/bff/master/download.sh | sh | ||
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- v0.9.14 | ||
.PHONY: setup | ||
|
||
.PHONY: install # .PHONY tells Make that the target is not associated with a file | ||
install: | ||
go install | ||
.PHONY: install | ||
|
||
.PHONY: test | ||
test: | ||
gotest -v -coverprofile=coverage.txt -covermode=atomic ./... | ||
go test -v -coverprofile=coverage.txt -covermode=atomic ./... | ||
.PHONY: test | ||
|
||
.PHONY: test-all | ||
test-all: | ||
gotest -v -coverprofile=coverage.txt -covermode=atomic ./... -tags=integration | ||
go test -v -coverprofile=coverage.txt -covermode=atomic ./... -tags=integration | ||
.PHONY: test-all | ||
|
||
.PHONY: test-coverage | ||
test-coverage: ## run the test with proper coverage reporting | ||
goverage -coverprofile=coverage.out -covermode=atomic ./... | ||
goverage -coverprofile=coverage.out -covermode=atomic ./... | ||
go tool cover -html=coverage.out | ||
.PHONY: test-coverage | ||
|
||
.PHONY: test-coverage-all | ||
test-coverage-integration: ## run the test with proper coverage reporting | ||
goverage -coverprofile=coverage.out -covermode=atomic ./... -tags=integration | ||
go tool cover -html=coverage.out | ||
.PHONY: test-coverage-all | ||
|
||
# lint: # run the fast go linters | ||
# ./bin/golangci-lint run --no-config \ | ||
# --disable-all --enable=deadcode --enable=gocyclo --enable=golint --enable=varcheck \ | ||
# --enable=structcheck --enable=errcheck --enable=dupl --enable=unparam --enable=goimports \ | ||
# --enable=interfacer --enable=unconvert --enable=gosec --enable=megacheck --deadline=5m | ||
# .PHONY: lint | ||
|
||
lint: ## run the fast go linters on the diff from master | ||
./bin/reviewdog -conf .reviewdog.yml -diff "git diff master" | ||
.PHONY: lint | ||
lint: # run the fast go linters | ||
golangci-lint run --no-config \ | ||
--disable-all --enable=deadcode --enable=gocyclo --enable=golint --enable=varcheck \ | ||
--enable=structcheck --enable=errcheck --enable=dupl --enable=unparam --enable=goimports \ | ||
--enable=interfacer --enable=unconvert --enable=gosec --enable=megacheck --deadline=5m | ||
|
||
.PHONY: deps | ||
lint-ci: ## run the fast go linters | ||
./bin/reviewdog -conf .reviewdog.yml -reporter=github-pr-review | ||
.PHONY: lint-ci | ||
|
||
lint-all: ## run the fast go linters | ||
# doesn't seem to be a way to get reviewdog to not filter by diff | ||
golangci-lint run | ||
.PHONY: lint-all | ||
|
||
|
||
deps: | ||
go mod tidy | ||
go mod vendor | ||
.PHONY: deps | ||
|
||
.PHONY: release | ||
release: ## run a release | ||
bff bump | ||
./bin/bff bump | ||
git push | ||
goreleaser release --rm-dist | ||
.PHONY: release |
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