Clean up Makefile (#2924)

Add missing deprecated targets.  Remove `test` from `check` target since
we already have `test-race`.

Fixes #2901
This commit is contained in:
Cameron Moore 2017-01-11 03:07:35 -06:00 committed by Bjørn Erik Pedersen
parent db33a33e61
commit 1d7b960614
3 changed files with 47 additions and 59 deletions

View file

@ -12,12 +12,9 @@ matrix:
- go: tip - go: tip
fast_finish: true fast_finish: true
install: install:
- make govendor - make vendor
script: script:
- make check - make hugo-race check
# Test 64-bit alignment on 32-bit builds
- env GOARCH=386 make test
- go build -race
- ./hugo -s docs/ - ./hugo -s docs/
- ./hugo --renderToMemory -s docs/ - ./hugo --renderToMemory -s docs/
before_install: before_install:

View file

@ -1,83 +1,80 @@
# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
# Adds build information from git repo PACKAGE = github.com/spf13/hugo
#
# as suggested by tatsushid in
# https://github.com/spf13/hugo/issues/540
COMMIT_HASH = `git rev-parse --short HEAD 2>/dev/null` COMMIT_HASH = `git rev-parse --short HEAD 2>/dev/null`
BUILD_DATE = `date +%FT%T%z` BUILD_DATE = `date +%FT%T%z`
LDFLAGS=-ldflags "-X github.com/spf13/hugo/hugolib.CommitHash=${COMMIT_HASH} -X github.com/spf13/hugo/hugolib.BuildDate=${BUILD_DATE}" LDFLAGS = -ldflags "-X ${PACKAGE}/hugolib.CommitHash=${COMMIT_HASH} -X ${PACKAGE}/hugolib.BuildDate=${BUILD_DATE}"
PACKAGES = $(shell govendor list -no-status +local | sed 's/github.com.spf13.hugo/./') NOGI_LDFLAGS = -ldflags "-X ${PACKAGE}/hugolib.BuildDate=${BUILD_DATE}"
all: gitinfo .PHONY: vendor docker check fmt lint test test-race vet test-cover-html help
.DEFAULT_GOAL := help
install: install-gitinfo vendor: ## Install govendor and sync Hugo's vendored dependencies
go get github.com/kardianos/govendor
govendor sync ${PACKAGE}
help: hugo: vendor ## Build hugo binary
echo ${COMMIT_HASH} go build ${LDFLAGS} ${PACKAGE}
echo ${BUILD_DATE}
gitinfo: hugo-race: vendor ## Build hugo binary with race detector enabled
go build ${LDFLAGS} -o hugo main.go go build -race ${LDFLAGS} ${PACAGE}
install-gitinfo: install: vendor ## Install hugo binary
go install ${LDFLAGS} ./... go install ${LDFLAGS} ${PACKAGE}
no-git-info: hugo-no-gitinfo: LDFLAGS = ${NOGI_LDFLAGS}
go build -o hugo main.go hugo-no-gitinfo: vendor hugo ## Build hugo without git info
docker: docker: ## Build hugo Docker container
docker build -t hugo . docker build -t hugo .
docker rm -f hugo-build || true docker rm -f hugo-build || true
docker run --name hugo-build hugo ls /go/bin docker run --name hugo-build hugo ls /go/bin
docker cp hugo-build:/go/bin/hugo . docker cp hugo-build:/go/bin/hugo .
docker rm hugo-build docker rm hugo-build
govendor: govendor: vendor # Deprecated: use "vendor" target
go get -u github.com/kardianos/govendor get: vendor # Deprecated: use "vendor"
go install github.com/kardianos/govendor gitinfo: hugo # Deprecated: use "hugo" target
govendor sync github.com/spf13/hugo install-gitinfo: install # Deprecated: use "install" target
no-git-info: hugo-no-gitinfo # Deprecated: use "hugo-no-gitinfo" target
check: fmt vet test test-race check: test-race test386 fmt vet ## Run tests and linters
cyclo: test386: ## Run tests in 32-bit mode
@for d in `govendor list -no-status +local | sed 's/github.com.spf13.hugo/./'` ; do \ GOARCH=386 govendor test +local
if [ "`gocyclo -over 20 $$d | tee /dev/stderr`" ]; then \
echo "^ cyclomatic complexity exceeds 20, refactor the code!" && echo && exit 1; \
fi \
done
fmt: test: ## Run tests
govendor test +local
test-race: ## Run tests with race detector
govendor test -race +local
fmt: ## Run gofmt linter
@for d in `govendor list -no-status +local | sed 's/github.com.spf13.hugo/./'` ; do \ @for d in `govendor list -no-status +local | sed 's/github.com.spf13.hugo/./'` ; do \
if [ "`gofmt -l $$d/*.go | tee /dev/stderr`" ]; then \ if [ "`gofmt -l $$d/*.go | tee /dev/stderr`" ]; then \
echo "^ improperly formatted go files" && echo && exit 1; \ echo "^ improperly formatted go files" && echo && exit 1; \
fi \ fi \
done done
lint: lint: ## Run golint linter
@for d in `govendor list -no-status +local | sed 's/github.com.spf13.hugo/./'` ; do \ @for d in `govendor list -no-status +local | sed 's/github.com.spf13.hugo/./'` ; do \
if [ "`golint $$d | tee /dev/stderr`" ]; then \ if [ "`golint $$d | tee /dev/stderr`" ]; then \
echo "^ golint errors!" && echo && exit 1; \ echo "^ golint errors!" && echo && exit 1; \
fi \ fi \
done done
get: vet: ## Run go vet linter
go get -v -t ./...
test:
govendor test +local
test-race:
govendor test -race +local
vet:
@if [ "`govendor vet +local | tee /dev/stderr`" ]; then \ @if [ "`govendor vet +local | tee /dev/stderr`" ]; then \
echo "^ go vet errors!" && echo && exit 1; \ echo "^ go vet errors!" && echo && exit 1; \
fi fi
test-cover-html: test-cover-html: PACKAGES = $(shell govendor list -no-status +local | sed 's/github.com.spf13.hugo/./')
test-cover-html: ## Generate test coverage report
echo "mode: count" > coverage-all.out echo "mode: count" > coverage-all.out
$(foreach pkg,$(PACKAGES),\ $(foreach pkg,$(PACKAGES),\
govendor test -coverprofile=coverage.out -covermode=count $(pkg);\ govendor test -coverprofile=coverage.out -covermode=count $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;) tail -n +2 coverage.out >> coverage-all.out;)
go tool cover -html=coverage-all.out go tool cover -html=coverage-all.out
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

View file

@ -13,16 +13,10 @@ install:
pip install docutils pip install docutils
build_script: build_script:
- cmd: make govendor - cmd: make vendor
test_script: test_script:
- cmd: >- - cmd: >-
make check make hugo-race check
REM Test 64-bit alignment on 32-bit builds
set "GOARCH=386" & make test & set GOARCH=
go build -race
hugo -s docs/ hugo -s docs/