pulumi/Makefile
joeduffy 8b57310854 Tidy up more lint
This change fixes a few things:

* Most importantly, we need to place a leading "." in the paths
  to Gometalinter, otherwise some sub-linters just silently skip
  the directory altogether.  errcheck is one such linter, which
  is a very important one!

* Use an explicit Gometalinter.json file to configure the various
  settings.  This flips on a few additional linters that aren't
  on by default (line line length checking).  Sadly, a few that
  I'd like to enable take waaaay too much time, so in the future
  we may consider a nightly job (this includes code similarity,
  unused parameters, unused functions, and others that generally
  require global analysis).

* Now that we're running more, however, linting takes a while!
  The core Lumi project now takes 26 seconds to lint on my laptop.
  That's not terrible, but it's long enough that we don't want to
  do the silly "run them twice" thing our Makefiles were previously
  doing.  Instead, we shall deploy some $$($${PIPESTATUS[1]}-1))-fu
  to rely on the fact that grep returns 1 on "zero lines".

* Finally, fix the many issues that this turned up.

I think(?) we are done, except, of course, for needing to drive
down some of the cyclomatic complexity issues (which I'm possibly
going to punt on; see pulumi/lumi#259 for more details).
2017-06-22 12:09:46 -07:00

101 lines
2.9 KiB
Makefile

.SHELLFLAGS=-e
PROJECT=github.com/pulumi/lumi
PROJECT_PKGS=$(shell go list ./cmd/... ./pkg/... | grep -v /vendor/)
TESTPARALLELISM=10
GOMETALINTERBIN=gometalinter
GOMETALINTER=${GOMETALINTERBIN} --config=Gometalinter.json
.PHONY: default
default: banner vet test install lint_quiet
.PHONY: all
all: banner_all vet test install lint_quiet lumijs lumirtpkg lumijspkg lumipkg awspkg
.PHONY: nightly
nightly: banner_all vet test install lint_quiet lumijs lumirtpkg lumijspkg lumipkg awspkg examples
.PHONY: banner
banner:
@echo "\033[1;37m============\033[0m"
@echo "\033[1;37mLumi (Quick)\033[0m"
@echo "\033[1;37m============\033[0m"
@echo "\033[0;33mRunning quick build; to run full tests, run 'make all'\033[0m"
@echo "\033[0;33mRemember to do this before checkin, otherwise your CI will fail\033[0m"
.PHONY: banner_all
banner_all:
@echo "\033[1;37m============\033[0m"
@echo "\033[1;37mLumi (Full)\033[0m"
@echo "\033[1;37m============\033[0m"
.PHONY: install
install:
@echo "\033[0;32mINSTALL:\033[0m"
go install ${PROJECT}/cmd/lumi
go install ${PROJECT}/cmd/lumidl
.PHONY: lint
lint:
@echo "\033[0;32mLINT:\033[0m"
which ${GOMETALINTERBIN} >/dev/null
$(GOMETALINTER) ./pkg/... | sort ; exit "$${PIPESTATUS[0]}"
$(GOMETALINTER) ./cmd/lumi/... | sort ; exit "$${PIPESTATUS[0]}"
$(GOMETALINTER) ./cmd/lumidl/... | sort ; exit "$${PIPESTATUS[0]}"
# In quiet mode, suppress some messages.
# - "or be unexported": TODO[pulumi/lumi#191]: will fix when we write all of our API docs
# - "Subprocess launching with variable": we intentionally launch processes dynamically.
# - "cyclomatic complexity" (disabled in config): TODO[pulumi/lumi#259]: need to fix many of these.
LINT_SUPPRESS="or be unexported|Subprocess launching with variable"
.PHONY: lint_quiet
lint_quiet:
@echo "\033[0;32mLINT (quiet):\033[0m"
which ${GOMETALINTERBIN} >/dev/null
$(GOMETALINTER) ./pkg/... | grep -vE ${LINT_SUPPRESS} | sort ; exit $$(($${PIPESTATUS[1]}-1))
$(GOMETALINTER) ./cmd/lumi/... | grep -vE ${LINT_SUPPRESS} | sort ; exit $$(($${PIPESTATUS[1]}-1))
$(GOMETALINTER) ./cmd/lumidl/... | grep -vE ${LINT_SUPPRESS} | sort ; exit $$(($${PIPESTATUS[1]}-1))
@echo "\033[0;33mlint was run quietly; to run with noisy errors, run 'make lint'\033[0m"
.PHONY: vet
vet:
@echo "\033[0;32mVET:\033[0m"
go tool vet -printf=false cmd/ pkg/
.PHONY: test
test:
@echo "\033[0;32mTEST:\033[0m"
go test -cover -parallel ${TESTPARALLELISM} ${PROJECT_PKGS}
.PHONY: lumijs
lumijs:
@cd ./cmd/lumijs && $(MAKE)
.PHONY: lumirtpkg
lumirtpkg:
@cd ./lib/lumirt && $(MAKE)
.PHONY: lumijspkg
lumijspkg:
@cd ./lib/lumijs && $(MAKE)
.PHONY: lumipkg
lumipkg:
@cd ./lib/lumi && $(MAKE)
.PHONY: awspkg
awspkg:
@cd ./lib/aws && $(MAKE)
.PHONY: verify
verify:
@cd ./lib/aws && $(MAKE) verify
.PHONY: examples
examples:
@echo "\033[0;32mTEST EXAMPLES:\033[0m"
go test -v -cover -timeout 1h -parallel ${TESTPARALLELISM} ./examples