From 61aaf45c04240eee6f399d3f06727debb6d6017e Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Thu, 12 Jul 2018 17:33:35 +0200 Subject: [PATCH] Makefile cleanup & structurize - makefile is now divided in sections - remove separate test.sh and added 3 additional tasks (qa, qa.test & qa.vet) - add realize tool (watch & rebuild) along with .realize.yaml config --- .realize.yaml | 41 +++++++++++++++++++++++++++++++++++ Makefile | 59 +++++++++++++++++++++++++++++++++++++++++---------- test.sh | 9 -------- 3 files changed, 89 insertions(+), 20 deletions(-) create mode 100755 .realize.yaml delete mode 100755 test.sh diff --git a/.realize.yaml b/.realize.yaml new file mode 100755 index 000000000..07194a032 --- /dev/null +++ b/.realize.yaml @@ -0,0 +1,41 @@ +settings: + files: + outputs: + status: false + path: "" + name: .r.outputs.log + logs: + status: false + path: "" + name: .r.logs.log + errors: + status: false + path: "" + name: .r.errors.log + legacy: + force: false + interval: 0s +server: + status: false +schema: +- name: crust + path: cmd/sam + commands: + vet: + status: true + test: + status: false + run: + status: true + args: + - api + watcher: + paths: + - . + - ../internal/ + extensions: + - go + ignored_paths: + - .git + - .realize + - vendor diff --git a/Makefile b/Makefile index 8c1ad5896..36e1eb363 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,32 @@ -.PHONY: build +.PHONY: build realize dep spec protobuf qa qa.test qa.vet + +PKG = "github.com/$(shell cat .project)" + +GO = go +GOGET = $(GO) get -u + +######################################################################################################################## +# Tool bins +SPEC = $(GOPATH)/bin/spec +PROTOC = $(GOPATH)/bin/protoc-gen-go +REALIZE = ${GOPATH}/bin/realize -SPEC=$(GOPATH)/bin/spec -PROTOC=$(GOPATH)/bin/protoc-gen-go build: docker build --rm -t $(shell cat .project) . -$(SPEC): - go get -u github.com/titpetric/spec/cmd/spec -$(PROTOC): - go get -u github.com/golang/protobuf/protoc-gen-go +######################################################################################################################## +# Development + +realize: $(REALIZE) + $(REALIZE) start + +dep.update: + dep ensure -update -v + +dep: + dep ensure -v spec: $(SPEC) cd sam/docs/src && $(SPEC) @@ -20,8 +36,29 @@ protobuf: $(PROTOC) # @todo this needs work (it hangs and outputs nothing) $(PROTOC) --go_out=plugins=grpc:. -I. sam/chat/*.proto -dep: - dep ensure -v -dep.update: - dep ensure -update -v +######################################################################################################################## +# QA + +qa: qa.vet qa.test + +qa.vet: + go vet `cd ${GOPATH}/src/; find $(PKG) -type f -name '*.go' -and -not -path '*vendor*'|xargs -n1 dirname|uniq` + +qa.test: + go test `cd ${GOPATH}/src/; find $(PKG) -type f -name '*_test.go' -and -not -path '*vendor*'|xargs -n1 dirname|uniq` + + + +######################################################################################################################## +# Toolset + +$(REALIZE): + $(GOGET) github.com/tockins/realize + +$(SPEC): + $(GOGET) github.com/titpetric/spec/cmd/spec + +$(PROTOC): + $(GOGET) github.com/golang/protobuf/protoc-gen-go + diff --git a/test.sh b/test.sh deleted file mode 100755 index 5d43f1612..000000000 --- a/test.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -e -set -u - -PKG="github.com/$(<.project)" - -go vet `cd ${GOPATH}/src/; find ${PKG} -type f -name '*.go' -and -not -path '*vendor*'|xargs -n1 dirname|uniq` -go test `cd ${GOPATH}/src/; find ${PKG} -type f -name '*_test.go' -and -not -path '*vendor*'|xargs -n1 dirname|uniq`