Merge pull request #15 from hanzei/fmt

Add check-style makefile target
This commit is contained in:
Jesse Hallam 2018-10-17 18:02:45 -04:00 committed by GitHub
commit abded0bb53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 1 deletions

View file

@ -6,4 +6,5 @@ install:
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
script:
- make check-style
- make test

View file

@ -11,13 +11,48 @@ include build/setup.mk
BUNDLE_NAME ?= $(PLUGIN_ID)-$(PLUGIN_VERSION).tar.gz
# all, the default target, tests, builds and bundles the plugin.
all: test dist
all: check-style test dist
# apply propagates the plugin id into the server/ and webapp/ folders as required.
.PHONY: apply
apply:
./build/bin/manifest apply
.PHONY: check-style
check-style: server/.depensure webapp/.npminstall gofmt govet
@echo Checking for style guide compliance
ifneq ($(HAS_WEBAPP),)
cd webapp && npm run lint
endif
.PHONY: gofmt
gofmt:
ifneq ($(HAS_SERVER),)
@echo Running gofmt
@for package in $$(go list ./server/...); do \
echo "Checking "$$package; \
files=$$(go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $$package); \
if [ "$$files" ]; then \
gofmt_output=$$(gofmt -d -s $$files 2>&1); \
if [ "$$gofmt_output" ]; then \
echo "$$gofmt_output"; \
echo "Gofmt failure"; \
exit 1; \
fi; \
fi; \
done
@echo Gofmt success
endif
.PHONY: govet
govet:
ifneq ($(HAS_SERVER),)
@echo Running govet
@$(GO) vet $$(go list ./server/...) || exit 1
@echo Govet success
endif
# server/.depensure ensures the server dependencies are installed
server/.depensure:
ifneq ($(HAS_SERVER),)