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