Skip to content

Commit

Permalink
Add a Makefile target to run linters
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed Sep 30, 2019
1 parent 3575c05 commit 473f73a
Show file tree
Hide file tree
Showing 5 changed files with 447 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PACK_VERSION?=dev-$(shell date +%Y-%m-%d-%H:%M:%S)
PACK_BIN?=pack
PACKAGE_BASE=github.com/buildpack/pack
PACKAGES:=$(shell $(GOCMD) list -mod=vendor ./... | grep -v /testdata/)
SRC:=$(shell find . -type f -name '*.go' -not -path "./vendor/*")
SRC:=$(shell find . -type f -name '*.go' -not -path "*/vendor/*")
ARCHIVE_NAME=pack-$(PACK_VERSION)

all: clean verify test build
Expand All @@ -30,29 +30,33 @@ format: install-goimports
@echo "> Formating code..."
@goimports -l -w -local ${PACKAGE_BASE} ${SRC}

vet:
@echo "> Vetting code..."
@$(GOCMD) vet -mod=vendor ${PACKAGES}
install-golangci-lint:
@echo "> Installing golangci-lint..."
cd tools; $(GOCMD) install -mod=vendor github.com/golangci/golangci-lint/cmd/golangci-lint

lint: install-golangci-lint
@echo "> Linting code..."
@golangci-lint run -c golangci.yaml

test: unit acceptance

unit: format vet
unit: format lint
@echo "> Running unit/integration tests..."
$(GOCMD) test -mod=vendor -v -count=1 -parallel=1 -timeout=0 ./...

acceptance: format vet
acceptance: format lint
@echo "> Running acceptance tests..."
$(GOCMD) test -mod=vendor -v -count=1 -parallel=1 -timeout=0 -tags=acceptance ./acceptance

acceptance-all: format vet
acceptance-all: format lint
@echo "> Running acceptance tests..."
ACCEPTANCE_SUITE_CONFIG=$$(cat ./acceptance/testconfig/all.json) $(GOCMD) test -mod=vendor -v -count=1 -parallel=1 -timeout=0 -tags=acceptance ./acceptance

clean:
@echo "> Cleaning workspace..."
rm -rf ./out

verify: verify-format vet
verify: verify-format lint

generate: install-mockgen
@echo "> Generating mocks..."
Expand All @@ -66,4 +70,4 @@ verify-format: install-goimports
goimports -d -local ${PACKAGE_BASE} ${SRC} && exit $$_err;\
exit 0;

.PHONY: clean build format imports vet test unit acceptance verify verify-format
.PHONY: clean build format imports lint test unit acceptance verify verify-format
25 changes: 25 additions & 0 deletions golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
run:
deadline: 6m
modules-download-mode: vendor

linters:
disable-all: true
enable:
- bodyclose
- deadcode
- gocritic
- goimports
- golint
- gosimple
- govet
- ineffassign
- maligned
- misspell
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unused
- varcheck
- scopelint
41 changes: 41 additions & 0 deletions tools/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module github.com/buildpack/pack/tools

go 1.13

require (
github.com/OpenPeeDeeP/depguard v1.0.1 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/go-critic/go-critic v0.3.5-0.20190904082202-d79a9f0c64db // indirect
github.com/gogo/protobuf v1.3.0 // indirect
github.com/golang/mock v1.3.1
github.com/golang/protobuf v1.3.2 // indirect
github.com/golangci/gocyclo v0.0.0-20180528144436-0a533e8fa43d // indirect
github.com/golangci/golangci-lint v1.18.0
github.com/golangci/revgrep v0.0.0-20180812185044-276a5c0a1039 // indirect
github.com/google/go-cmp v0.3.1 // indirect
github.com/gostaticanalysis/analysisutil v0.0.3 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.9 // indirect
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect
github.com/onsi/ginkgo v1.10.1 // indirect
github.com/onsi/gomega v1.7.0 // indirect
github.com/pelletier/go-toml v1.4.0 // indirect
github.com/shurcooL/go v0.0.0-20190704215121-7189cc372560 // indirect
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cobra v0.0.5 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.4.0 // indirect
github.com/stretchr/testify v1.4.0 // indirect
github.com/timakin/bodyclose v0.0.0-20190926151346-866fdb772e33 // indirect
github.com/ultraware/funlen v0.0.2 // indirect
golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 // indirect
golang.org/x/sys v0.0.0-20190927073244-c990c680b611 // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20190929041059-e7abfedfabcf
mvdan.cc/unparam v0.0.0-20190917161559-b83a221c10a2 // indirect
sourcegraph.com/sqs/pbtypes v1.0.0 // indirect
)
Loading

0 comments on commit 473f73a

Please sign in to comment.