2017-10-02 14:23:41 -03:00
|
|
|
SOURCE_FILES?=./...
|
2017-01-02 11:23:28 +01:00
|
|
|
TEST_PATTERN?=.
|
|
|
|
TEST_OPTIONS?=
|
2018-03-02 00:27:34 -03:00
|
|
|
OS=$(shell uname -s)
|
2017-01-02 11:23:28 +01:00
|
|
|
|
2017-09-10 17:07:28 -03:00
|
|
|
# Install all the build and lint dependencies
|
|
|
|
setup:
|
2017-12-18 09:19:02 -02:00
|
|
|
go get -u golang.org/x/tools/cmd/stringer
|
2017-02-07 17:00:46 -02:00
|
|
|
go get -u golang.org/x/tools/cmd/cover
|
2018-02-17 18:16:02 -02:00
|
|
|
go get -u github.com/caarlos0/static/cmd/static-docs
|
2017-12-23 11:45:17 -02:00
|
|
|
go get -u github.com/caarlos0/bandep
|
2018-03-02 00:27:34 -03:00
|
|
|
go get -u gopkg.in/alecthomas/gometalinter.v2
|
|
|
|
ifeq ($(OS), Darwin)
|
|
|
|
brew install dep
|
|
|
|
else
|
|
|
|
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
|
|
|
endif
|
2017-03-25 21:00:03 -03:00
|
|
|
dep ensure
|
2018-03-02 09:28:08 -03:00
|
|
|
gometalinter.v2 --install
|
2017-12-23 11:45:17 -02:00
|
|
|
echo "make check" > .git/hooks/pre-commit
|
|
|
|
chmod +x .git/hooks/pre-commit
|
2017-12-05 21:59:57 -02:00
|
|
|
.PHONY: setup
|
2017-01-02 11:23:28 +01:00
|
|
|
|
2017-12-23 11:45:17 -02:00
|
|
|
check:
|
|
|
|
bandep --ban github.com/tj/assert
|
|
|
|
.PHONY: check
|
|
|
|
|
2017-09-10 17:07:28 -03:00
|
|
|
# Run all the tests
|
|
|
|
test:
|
2018-02-24 17:31:07 -03:00
|
|
|
go test $(TEST_OPTIONS) -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=2m
|
2017-12-05 21:59:57 -02:00
|
|
|
.PHONY: cover
|
2017-01-15 09:11:37 -02:00
|
|
|
|
2017-09-10 17:07:28 -03:00
|
|
|
# Run all the tests and opens the coverage report
|
|
|
|
cover: test
|
2017-04-21 21:22:11 -03:00
|
|
|
go tool cover -html=coverage.txt
|
2017-12-05 21:59:57 -02:00
|
|
|
.PHONY: cover
|
2017-04-14 15:39:32 -03:00
|
|
|
|
2017-09-10 17:07:28 -03:00
|
|
|
# gofmt and goimports all go files
|
|
|
|
fmt:
|
2017-01-30 14:24:32 -02:00
|
|
|
find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
|
2017-12-10 15:17:29 -02:00
|
|
|
find . -name '*.md' -not -wholename './vendor/*' | xargs prettier --write
|
2017-12-05 21:59:57 -02:00
|
|
|
.PHONY: fmt
|
2017-01-02 11:23:28 +01:00
|
|
|
|
2017-09-10 17:07:28 -03:00
|
|
|
# Run all the linters
|
|
|
|
lint:
|
2018-03-02 09:40:19 -03:00
|
|
|
gometalinter.v2 --vendor ./...
|
2017-12-10 15:17:29 -02:00
|
|
|
find . -name '*.md' -not -wholename './vendor/*' | xargs prettier -l
|
2017-12-05 21:59:57 -02:00
|
|
|
.PHONY: lint
|
2017-01-02 11:23:28 +01:00
|
|
|
|
2017-09-10 17:07:28 -03:00
|
|
|
# Run all the tests and code checks
|
2017-12-18 09:28:36 -02:00
|
|
|
ci: build test lint
|
2017-12-05 21:59:57 -02:00
|
|
|
.PHONY: ci
|
2017-01-02 11:23:28 +01:00
|
|
|
|
2017-09-10 17:07:28 -03:00
|
|
|
# Build a beta version of goreleaser
|
|
|
|
build:
|
2017-12-18 09:19:02 -02:00
|
|
|
go generate ./...
|
2017-04-23 13:22:12 +02:00
|
|
|
go build
|
2017-12-05 21:59:57 -02:00
|
|
|
.PHONY: build
|
2017-09-10 21:11:37 -03:00
|
|
|
|
2017-09-10 17:07:28 -03:00
|
|
|
# Generate the static documentation
|
|
|
|
static:
|
2017-12-05 21:59:57 -02:00
|
|
|
@rm -rf dist/goreleaser.github.io
|
|
|
|
@mkdir -p dist
|
2017-12-05 22:22:43 -02:00
|
|
|
@git clone https://github.com/goreleaser/goreleaser.github.io.git dist/goreleaser.github.io
|
2017-12-05 21:59:57 -02:00
|
|
|
@rm -rf dist/goreleaser.github.io/theme
|
2017-09-10 21:11:37 -03:00
|
|
|
@static-docs \
|
2018-02-17 18:16:02 -02:00
|
|
|
--syntax dracula \
|
2017-09-10 21:11:37 -03:00
|
|
|
--in docs \
|
2017-12-05 21:59:57 -02:00
|
|
|
--out dist/goreleaser.github.io \
|
2017-09-10 21:11:37 -03:00
|
|
|
--title GoReleaser \
|
|
|
|
--subtitle "Deliver Go binaries as fast and easily as possible" \
|
2017-12-04 09:49:29 -02:00
|
|
|
--google UA-106198408-1
|
2017-12-05 21:59:57 -02:00
|
|
|
.PHONY: static
|
|
|
|
|
2017-10-19 10:50:49 -02:00
|
|
|
# Show to-do items per file.
|
|
|
|
todo:
|
|
|
|
@grep \
|
|
|
|
--exclude-dir=vendor \
|
|
|
|
--exclude-dir=node_modules \
|
|
|
|
--exclude=Makefile \
|
|
|
|
--text \
|
|
|
|
--color \
|
2018-03-04 20:23:38 -03:00
|
|
|
-nRo -E ' TODO:.*|SkipNow' .
|
2017-10-19 10:50:49 -02:00
|
|
|
.PHONY: todo
|
|
|
|
|
2017-01-02 11:23:28 +01:00
|
|
|
|
2017-01-02 13:57:36 -02:00
|
|
|
.DEFAULT_GOAL := build
|