From fbdb357823540de0111d87cd653af8169972f327 Mon Sep 17 00:00:00 2001 From: Hanzei Date: Fri, 12 Oct 2018 13:38:18 +0200 Subject: [PATCH 1/4] Add check-style makefile target --- Makefile | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9491e06..9f01b2d 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,39 @@ 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: webapp/.npminstall gofmt + @echo Checking for style guide compliance + +ifneq ($(HAS_WEBAPP),) + cd webapp && npm run lint +endif + +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 + # server/.depensure ensures the server dependencies are installed server/.depensure: ifneq ($(HAS_SERVER),) From 0f51dc026ed2503dc289c6b27d1584e9b1dbd294 Mon Sep 17 00:00:00 2001 From: Hanzei Date: Fri, 12 Oct 2018 13:38:41 +0200 Subject: [PATCH 2/4] Add make check-style to travis --- .travis.yml | 1 + Makefile | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa28f54..3ca37f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,5 @@ install: - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh script: + - make check-style - make test diff --git a/Makefile b/Makefile index 9f01b2d..8d031bc 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ endif gofmt: ifneq ($(HAS_SERVER),) - @echo Running GOFMT + @echo Running gomft @for package in $$(go list ./server/...); do \ echo "Checking "$$package; \ files=$$(go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $$package); \ @@ -36,12 +36,12 @@ ifneq ($(HAS_SERVER),) gofmt_output=$$(gofmt -d -s $$files 2>&1); \ if [ "$$gofmt_output" ]; then \ echo "$$gofmt_output"; \ - echo "gofmt failure"; \ + echo "Gofmt failure"; \ exit 1; \ fi; \ fi; \ done - @echo "gofmt success"; + @echo Gofmt success endif # server/.depensure ensures the server dependencies are installed From 1495c46ae6d3ab7e272a80a5fb22cfbdbc6326c7 Mon Sep 17 00:00:00 2001 From: Hanzei Date: Fri, 12 Oct 2018 15:03:10 +0200 Subject: [PATCH 3/4] Add govet target --- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8d031bc..4f31d05 100644 --- a/Makefile +++ b/Makefile @@ -19,16 +19,17 @@ apply: ./build/bin/manifest apply .PHONY: check-style -check-style: webapp/.npminstall gofmt +check-style: 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 gomft + @echo Running gofmt @for package in $$(go list ./server/...); do \ echo "Checking "$$package; \ files=$$(go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $$package); \ @@ -44,6 +45,14 @@ ifneq ($(HAS_SERVER),) @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),) From f31f0f8a0ad18b03b48578ecfc69e174b268a3d7 Mon Sep 17 00:00:00 2001 From: Hanzei Date: Fri, 12 Oct 2018 16:10:07 +0200 Subject: [PATCH 4/4] Fix bug --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4f31d05..8ffb8da 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ apply: ./build/bin/manifest apply .PHONY: check-style -check-style: webapp/.npminstall gofmt govet +check-style: server/.depensure webapp/.npminstall gofmt govet @echo Checking for style guide compliance ifneq ($(HAS_WEBAPP),)