2017-10-02 14:23:41 -03:00
|
|
|
SOURCE_FILES?=./...
|
2017-01-02 11:23:28 +01:00
|
|
|
TEST_PATTERN?=.
|
|
|
|
TEST_OPTIONS?=
|
|
|
|
|
2018-04-24 22:20:12 -07:00
|
|
|
export PATH := ./bin:$(PATH)
|
2018-10-28 21:54:15 -03:00
|
|
|
export GO111MODULE := on
|
2019-08-05 14:58:18 -03:00
|
|
|
export GOPROXY := https://gocenter.io
|
2018-04-24 22:20:12 -07:00
|
|
|
|
2017-09-10 17:07:28 -03:00
|
|
|
# Install all the build and lint dependencies
|
|
|
|
setup:
|
2018-05-29 09:17:17 -03:00
|
|
|
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
|
2018-05-13 16:06:14 -03:00
|
|
|
curl -sfL https://install.goreleaser.com/github.com/gohugoio/hugo.sh | sh
|
2019-06-28 10:13:56 -03:00
|
|
|
curl -L https://git.io/misspell | sh
|
2019-08-27 14:09:21 -03:00
|
|
|
go mod tidy
|
2017-12-05 21:59:57 -02:00
|
|
|
.PHONY: setup
|
2017-01-02 11:23:28 +01:00
|
|
|
|
2017-09-10 17:07:28 -03:00
|
|
|
# Run all the tests
|
|
|
|
test:
|
2018-08-21 15:55:35 -03:00
|
|
|
go test $(TEST_OPTIONS) -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=2m
|
2018-05-03 22:07:20 -07:00
|
|
|
.PHONY: test
|
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-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:
|
2019-09-13 09:53:56 -03:00
|
|
|
# TODO: fix tests issues
|
|
|
|
# TODO: fix lll issues
|
|
|
|
# TODO: fix funlen issues
|
|
|
|
./bin/golangci-lint run --tests=false --enable-all --disable=lll --disable funlen ./...
|
2019-06-28 10:13:56 -03:00
|
|
|
./bin/misspell -error **/*
|
2017-12-05 21:59:57 -02:00
|
|
|
.PHONY: lint
|
2017-01-02 11:23:28 +01:00
|
|
|
|
2019-07-09 16:37:18 +02:00
|
|
|
# Clean go.mod
|
|
|
|
go-mod-tidy:
|
2019-07-15 17:12:36 -03:00
|
|
|
@go mod tidy -v
|
|
|
|
@git diff HEAD
|
|
|
|
@git diff-index --quiet HEAD
|
2019-07-09 16:37:18 +02:00
|
|
|
.PHONY: go-mod-tidy
|
|
|
|
|
2017-09-10 17:07:28 -03:00
|
|
|
# Run all the tests and code checks
|
2019-07-09 16:37:18 +02:00
|
|
|
ci: build test lint go-mod-tidy
|
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-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
|
2018-10-31 00:03:29 -03:00
|
|
|
static:
|
2018-06-25 14:51:10 -03:00
|
|
|
@hugo --enableGitInfo --source www
|
2017-12-05 21:59:57 -02:00
|
|
|
.PHONY: static
|
|
|
|
|
2019-04-23 06:18:22 -03:00
|
|
|
imgs:
|
|
|
|
wget -O www/static/card.png "https://og.caarlos0.dev/**GoReleaser**%20%7C%20Deliver%20Go%20binaries%20as%20fast%20and%20easily%20as%20possible.png?theme=light&md=1&fontSize=80px&images=https://github.com/goreleaser.png"
|
|
|
|
wget -O www/static/avatar.png https://github.com/goreleaser.png
|
2018-06-20 00:16:04 -03:00
|
|
|
convert www/static/avatar.png -define icon:auto-resize=64,48,32,16 www/static/favicon.ico
|
|
|
|
convert www/static/avatar.png -resize x120 www/static/apple-touch-icon.png
|
2019-04-23 06:18:22 -03:00
|
|
|
.PHONY: imgs
|
2018-06-20 00:16:04 -03:00
|
|
|
|
2019-04-23 06:18:22 -03:00
|
|
|
serve: imgs
|
2018-10-30 23:53:51 -03:00
|
|
|
@hugo server --enableGitInfo --watch --source www
|
2018-04-30 20:57:57 -07:00
|
|
|
.PHONY: serve
|
|
|
|
|
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 13:57:36 -02:00
|
|
|
.DEFAULT_GOAL := build
|