2019-03-28 00:24:49 +03:00
|
|
|
.PHONY: build compile test e2e doc fmt lint vet release
|
2018-09-18 16:42:38 -04:00
|
|
|
|
|
|
|
export GOPATH
|
|
|
|
|
|
|
|
VERSION ?= $(shell git describe --tags --always --dirty)
|
2018-10-25 18:15:00 -04:00
|
|
|
RELEASE_VERSION ?= $(version)
|
2018-09-18 16:42:38 -04:00
|
|
|
DIR_BIN = ./bin
|
|
|
|
DIR_PKG = ./pkg
|
2018-10-04 22:13:52 -04:00
|
|
|
DIR_CLI = ./cli
|
2018-10-14 15:38:14 -04:00
|
|
|
DIR_E2E = ./e2e
|
2018-09-18 16:42:38 -04:00
|
|
|
|
|
|
|
default: build
|
|
|
|
|
2019-03-28 00:24:49 +03:00
|
|
|
build: vet generate test compile
|
2018-09-18 16:42:38 -04:00
|
|
|
|
2018-09-25 21:49:42 -04:00
|
|
|
compile:
|
2018-09-18 16:42:38 -04:00
|
|
|
go build -v -o ${DIR_BIN}/ferret \
|
2018-10-13 22:00:29 -04:00
|
|
|
-ldflags "-X main.version=${VERSION}" \
|
2018-10-04 22:13:52 -04:00
|
|
|
./main.go
|
2018-09-18 16:42:38 -04:00
|
|
|
|
|
|
|
test:
|
2018-11-05 19:54:36 +03:00
|
|
|
go test -race -v ${DIR_PKG}/...
|
2018-10-16 20:50:06 -04:00
|
|
|
|
|
|
|
cover:
|
2018-11-05 11:36:55 -05:00
|
|
|
go test -race -coverprofile=coverage.txt -covermode=atomic ${DIR_PKG}/... && \
|
2018-10-25 22:13:41 -04:00
|
|
|
curl -s https://codecov.io/bash | bash
|
2018-09-18 16:42:38 -04:00
|
|
|
|
2018-10-14 15:38:14 -04:00
|
|
|
e2e:
|
2019-03-15 19:59:05 -04:00
|
|
|
go run ${DIR_E2E}/main.go --tests ${DIR_E2E}/tests --pages ${DIR_E2E}/pages --filter doc_cookie_set*
|
2018-10-14 15:38:14 -04:00
|
|
|
|
2018-10-24 19:40:57 -04:00
|
|
|
bench:
|
|
|
|
go test -run=XXX -bench=. ${DIR_PKG}/...
|
|
|
|
|
2018-09-18 16:42:38 -04:00
|
|
|
generate:
|
2018-09-27 17:03:49 -04:00
|
|
|
go generate ${DIR_PKG}/...
|
2018-09-18 16:42:38 -04:00
|
|
|
|
|
|
|
doc:
|
|
|
|
godoc -http=:6060 -index
|
|
|
|
|
|
|
|
# http://golang.org/cmd/go/#hdr-Run_gofmt_on_package_sources
|
|
|
|
fmt:
|
2018-10-04 22:13:52 -04:00
|
|
|
go fmt ${DIR_CLI}/... ${DIR_PKG}/...
|
2018-09-18 16:42:38 -04:00
|
|
|
|
2018-10-05 18:59:42 -04:00
|
|
|
# https://github.com/mgechev/revive
|
|
|
|
# go get github.com/mgechev/revive
|
2018-09-18 16:42:38 -04:00
|
|
|
lint:
|
2018-10-05 20:56:15 -04:00
|
|
|
revive -config revive.toml -formatter friendly -exclude ./pkg/parser/fql/... -exclude ./vendor/... ./...
|
2018-09-18 16:42:38 -04:00
|
|
|
|
|
|
|
# http://godoc.org/code.google.com/p/go.tools/cmd/vet
|
|
|
|
# go get code.google.com/p/go.tools/cmd/vet
|
|
|
|
vet:
|
2018-10-05 18:59:42 -04:00
|
|
|
go vet ${DIR_CLI}/... ${DIR_PKG}/...
|
2018-10-13 21:30:50 -04:00
|
|
|
|
|
|
|
release:
|
2018-10-25 18:15:00 -04:00
|
|
|
ifeq ($(RELEASE_VERSION), )
|
2018-10-25 19:55:23 -04:00
|
|
|
$(error "Release version is required (version=x)")
|
2018-10-25 18:27:34 -04:00
|
|
|
else ifeq ($(GITHUB_TOKEN), )
|
2018-10-25 19:55:23 -04:00
|
|
|
$(error "GitHub token is required (GITHUB_TOKEN)")
|
2018-10-25 18:15:00 -04:00
|
|
|
else
|
2018-10-25 18:15:46 -04:00
|
|
|
rm -rf ./dist && \
|
2018-10-25 18:15:00 -04:00
|
|
|
git tag -a v$(RELEASE_VERSION) -m "New $(RELEASE_VERSION) version" && \
|
|
|
|
git push origin v$(RELEASE_VERSION) && \
|
|
|
|
goreleaser
|
2019-02-15 07:41:08 -05:00
|
|
|
endif
|