gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

Makefile (2055B)


      1 GO ?= go
      2 GOFMT ?= gofmt "-s"
      3 GO_VERSION=$(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
      4 PACKAGES ?= $(shell $(GO) list ./...)
      5 VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/)
      6 GOFILES := $(shell find . -name "*.go")
      7 TESTFOLDER := $(shell $(GO) list ./... | grep -E 'gin$$|binding$$|render$$' | grep -v examples)
      8 TESTTAGS ?= ""
      9 
     10 .PHONY: test
     11 test:
     12 	echo "mode: count" > coverage.out
     13 	for d in $(TESTFOLDER); do \
     14 		$(GO) test $(TESTTAGS) -v -covermode=count -coverprofile=profile.out $$d > tmp.out; \
     15 		cat tmp.out; \
     16 		if grep -q "^--- FAIL" tmp.out; then \
     17 			rm tmp.out; \
     18 			exit 1; \
     19 		elif grep -q "build failed" tmp.out; then \
     20 			rm tmp.out; \
     21 			exit 1; \
     22 		elif grep -q "setup failed" tmp.out; then \
     23 			rm tmp.out; \
     24 			exit 1; \
     25 		fi; \
     26 		if [ -f profile.out ]; then \
     27 			cat profile.out | grep -v "mode:" >> coverage.out; \
     28 			rm profile.out; \
     29 		fi; \
     30 	done
     31 
     32 .PHONY: fmt
     33 fmt:
     34 	$(GOFMT) -w $(GOFILES)
     35 
     36 .PHONY: fmt-check
     37 fmt-check:
     38 	@diff=$$($(GOFMT) -d $(GOFILES)); \
     39 	if [ -n "$$diff" ]; then \
     40 		echo "Please run 'make fmt' and commit the result:"; \
     41 		echo "$${diff}"; \
     42 		exit 1; \
     43 	fi;
     44 
     45 vet:
     46 	$(GO) vet $(VETPACKAGES)
     47 
     48 .PHONY: lint
     49 lint:
     50 	@hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
     51 		$(GO) get -u golang.org/x/lint/golint; \
     52 	fi
     53 	for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
     54 
     55 .PHONY: misspell-check
     56 misspell-check:
     57 	@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
     58 		$(GO) get -u github.com/client9/misspell/cmd/misspell; \
     59 	fi
     60 	misspell -error $(GOFILES)
     61 
     62 .PHONY: misspell
     63 misspell:
     64 	@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
     65 		$(GO) get -u github.com/client9/misspell/cmd/misspell; \
     66 	fi
     67 	misspell -w $(GOFILES)
     68 
     69 .PHONY: tools
     70 tools:
     71 	@if [ $(GO_VERSION) -gt 15 ]; then \
     72 		$(GO) install golang.org/x/lint/golint@latest; \
     73 		$(GO) install github.com/client9/misspell/cmd/misspell@latest; \
     74 	elif [ $(GO_VERSION) -lt 16 ]; then \
     75 		$(GO) install golang.org/x/lint/golint; \
     76 		$(GO) install github.com/client9/misspell/cmd/misspell; \
     77 	fi