bitxhub/Makefile

70 lines
1.7 KiB
Makefile
Raw Normal View History

2020-03-29 21:32:01 +08:00
SHELL := /bin/bash
CURRENT_PATH = $(shell pwd)
APP_NAME = bitxhub
2020-03-31 14:00:16 +08:00
APP_VERSION = 1.0.0-rc1
2020-03-29 21:32:01 +08:00
# build with verison infos
VERSION_DIR = github.com/meshplus/${APP_NAME}
BUILD_DATE = $(shell date +%FT%T)
GIT_COMMIT = $(shell git log --pretty=format:'%h' -n 1)
GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
LDFLAGS += -X "${VERSION_DIR}.BuildDate=${BUILD_DATE}"
LDFLAGS += -X "${VERSION_DIR}.CurrentCommit=${GIT_COMMIT}"
LDFLAGS += -X "${VERSION_DIR}.CurrentBranch=${GIT_BRANCH}"
LDFLAGS += -X "${VERSION_DIR}.CurrentVersion=${APP_VERSION}"
GO = GO111MODULE=on go
TEST_PKGS := $(shell $(GO) list ./... | grep -v 'mock_*' | grep -v 'tester')
RED=\033[0;31m
GREEN=\033[0;32m
BLUE=\033[0;34m
NC=\033[0m
help: Makefile
@printf "${BLUE}Choose a command run:${NC}\n"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
## make prepare: Preparation before development
prepare:
@cd scripts && sh prepare.sh
## make test: Run go unittest
test:
go generate ./...
2020-03-30 18:46:49 +08:00
@$(GO) test ${TEST_PKGS} -count=1
2020-03-29 21:32:01 +08:00
## make test-coverage: Test project with cover
test-coverage:
@$(GO) test -coverprofile cover.out ${TEST_PKGS}
$(GO) tool cover -html=cover.out -o cover.html
## make tester: Run integration test
tester:
cd tester && $(GO) test -v -run TestTester
## make install: Go install the project
install:
cd internal/repo && packr
$(GO) install -ldflags '${LDFLAGS}' ./cmd/${APP_NAME}
@printf "${GREEN}Build bitxhub successfully!${NC}\n"
2020-03-30 12:59:22 +08:00
build:
cd internal/repo && packr
@mkdir -p bin
$(GO) build -ldflags '${LDFLAGS}' ./cmd/${APP_NAME}
@mv ./bitxhub bin
@printf "${GREEN}Build bitxhub successfully!${NC}\n"
2020-03-29 21:32:01 +08:00
## make linter: Run golanci-lint
linter:
2020-03-31 14:00:16 +08:00
golangci-lint run
2020-03-29 21:32:01 +08:00
## make cluster: Run cluster including 4 nodes
cluster:
2020-03-30 12:59:22 +08:00
@cd scripts && bash cluster.sh
2020-03-29 21:32:01 +08:00
.PHONY: tester