Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
integrate reviewdog (#39)
Browse files Browse the repository at this point in the history
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
ryanking authored Dec 14, 2019
1 parent 22921d3 commit 52e5d39
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage.out
cmd/testdata

dist
bin
8 changes: 8 additions & 0 deletions .reviewdog.yml
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
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ os:
env:
- GO111MODULE=on
install:
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.17.1
- go get -u github.com/haya14busa/goverage
- env GO111MODULE=on go build
- make setup
jobs:
include:
- stage: test
- name: test
stage: test
script:
- make test-coverage
- make test
after_success:
- bash <(curl -s https://codecov.io/bash)
- stage: test
- name: lint
stage: test
script:
- make lint
- make lint-ci
61 changes: 41 additions & 20 deletions Makefile
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
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/golang/protobuf v1.3.2 // indirect
github.com/google/uuid v1.1.1
github.com/hashicorp/go-multierror v1.0.0
github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5 // indirect
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/leesper/go_rng v0.0.0-20190531154944-a612b043e353 // indirect
Expand All @@ -27,6 +28,7 @@ require (
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 // indirect
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 // indirect
golang.org/x/tools v0.0.0-20191212203136-8facea2ecf42 // indirect
gonum.org/v1/gonum v0.0.0-20190802084026-e9a50d643359 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.2.4
Expand Down
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uP
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5 h1:FdBGmSkD2QpQzRWup//SGObvWf2nq89zj9+ta9OvI3A=
github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5/go.mod h1:0YZ2wQSuwviXXXGUiK6zXzskyBLAbLXhamxzcFHSLoM=
github.com/honeycombio/libhoney-go v1.12.0/go.mod h1:jdLxh51fcBTy6XIpx1efuJmHePs2xUfVkw25lr+hsmg=
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c h1:aY2hhxLhjEAbfXOx2nRJxCXezC6CO2V/yN+OCr1srtk=
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs=
Expand Down Expand Up @@ -202,6 +204,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -226,7 +229,13 @@ golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b h1:mSUCVIwDx4hfXJfWsOPfdzEHxzb2Xjl6BQ8YgPnazQA=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20191211222325-ac2db28e8130 h1:I1qMQ9XwbfS8IeSi3wJTzkAO8cPVBQRki4RNY6+cESQ=
golang.org/x/tools v0.0.0-20191211222325-ac2db28e8130/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191212203136-8facea2ecf42 h1:K9HnGJhHohnAQJD0QScLWVvtHhw8//MaBiEJgFfs7Hg=
golang.org/x/tools v0.0.0-20191212203136-8facea2ecf42/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.0.0-20190802084026-e9a50d643359/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU=
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
Expand Down

0 comments on commit 52e5d39

Please sign in to comment.