Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-09-22 16:35:01 +0300
committerNick Thomas <nick@gitlab.com>2017-09-29 15:04:49 +0300
commitd4aa227433be1b4c415ad8e70f5123b81a496360 (patch)
treee4a38cd7c6ee3fb64208fb53fb815dfc678d9a98 /Makefile.util.mk
parentd5360efc31b0c6b02ed17f77087226bba3916e36 (diff)
Rework the Makefile so "make" runs outside a GOPATH. Update CI to suit
Diffstat (limited to 'Makefile.util.mk')
-rw-r--r--Makefile.util.mk38
1 files changed, 38 insertions, 0 deletions
diff --git a/Makefile.util.mk b/Makefile.util.mk
new file mode 100644
index 00000000..18f6b0ff
--- /dev/null
+++ b/Makefile.util.mk
@@ -0,0 +1,38 @@
+.PHONY: verify fmt vet lint complexity test cover list
+
+verify: list fmt vet lint complexity
+
+fmt: bin/goimports .GOPATH/.ok
+ $Q ./bin/goimports -l $(allfiles) | awk '{ print "Please run go fmt"; exit 1 }'
+
+vet: .GOPATH/.ok
+ $Q go vet $(allpackages)
+
+lint: bin/golint
+ $Q ./bin/golint $(allpackages) | tee | ( ! grep -v "^$$" )
+
+complexity: .GOPATH/.ok bin/gocyclo
+ $Q ./bin/gocyclo -over 9 $(allfiles)
+
+test: .GOPATH/.ok gitlab-pages
+ go test $(if $V,-v) -timeout=1m $(allpackages)
+
+# The acceptance tests cannot count for coverage
+cover: bin/gocovmerge .GOPATH/.ok
+ @echo "NOTE: make cover does not exit 1 on failure, don't use it to check for tests success!"
+ $Q rm -f .GOPATH/cover/*.out .GOPATH/cover/all.merged
+ $(if $V,@echo "-- go test -coverpkg=./... -coverprofile=.GOPATH/cover/... ./...")
+ @for MOD in $(allpackages); do \
+ go test -coverpkg=`echo $(allpackages)|tr " " ","` \
+ -coverprofile=.GOPATH/cover/unit-`echo $$MOD|tr "/" "_"`.out \
+ $$MOD 2>&1 | grep -v "no packages being tested depend on"; \
+ done
+ $Q ./bin/gocovmerge .GOPATH/cover/*.out > .GOPATH/cover/all.merged
+ $Q go tool cover -html .GOPATH/cover/all.merged -o coverage.html
+ @echo ""
+ @echo "=====> Total test coverage: <====="
+ @echo ""
+ $Q go tool cover -func .GOPATH/cover/all.merged
+
+list: .GOPATH/.ok
+ @echo $(allpackages)