2016-04-12 14:45:37 +00:00
|
|
|
.PHONY: all
|
2016-03-27 12:20:57 +00:00
|
|
|
|
|
|
|
DEPS := $(wildcard *.go)
|
2016-04-13 07:22:04 +00:00
|
|
|
BUILD_IMAGE := "gorush-build"
|
2016-06-12 03:10:08 +00:00
|
|
|
# docker hub project name.
|
2016-06-10 14:27:25 +00:00
|
|
|
PRODUCTION_IMAGE := "gorush"
|
2016-04-11 09:18:53 +00:00
|
|
|
DEPLOY_ACCOUNT := "appleboy"
|
2016-05-04 07:10:43 +00:00
|
|
|
VERSION := $(shell git describe --tags)
|
2016-06-28 01:19:25 +00:00
|
|
|
TARGETS_NOVENDOR := $(shell glide novendor)
|
2016-03-27 12:20:57 +00:00
|
|
|
|
|
|
|
all: build
|
|
|
|
|
2016-05-22 03:17:40 +00:00
|
|
|
init:
|
|
|
|
ifeq ($(ANDROID_API_KEY),)
|
|
|
|
@echo "Missing ANDROID_API_KEY Parameter"
|
|
|
|
@exit 1
|
|
|
|
endif
|
|
|
|
ifeq ($(ANDROID_TEST_TOKEN),)
|
|
|
|
@echo "Missing ANDROID_TEST_TOKEN Parameter"
|
|
|
|
@exit 1
|
|
|
|
endif
|
|
|
|
@echo "Already set ANDROID_API_KEY and ANDROID_TEST_TOKEN globale variable."
|
|
|
|
|
2016-03-27 12:20:57 +00:00
|
|
|
build: clean
|
2016-05-04 07:10:43 +00:00
|
|
|
sh script/build.sh $(VERSION)
|
2016-03-27 12:20:57 +00:00
|
|
|
|
2016-06-30 05:41:26 +00:00
|
|
|
coverage:
|
2016-07-20 07:50:28 +00:00
|
|
|
sh ./script/coverage.sh testing atomic
|
2016-06-30 05:41:26 +00:00
|
|
|
|
2016-05-04 01:29:36 +00:00
|
|
|
test: redis_test boltdb_test memory_test config_test
|
2016-07-20 07:50:28 +00:00
|
|
|
go test -v -cover ./gorush/...
|
2016-05-03 01:42:53 +00:00
|
|
|
|
2016-05-22 03:17:40 +00:00
|
|
|
redis_test: init
|
2016-07-20 07:50:28 +00:00
|
|
|
go test -v -cover ./storage/redis/...
|
2016-05-03 01:42:53 +00:00
|
|
|
|
2016-05-22 03:17:40 +00:00
|
|
|
boltdb_test: init
|
2016-07-20 07:50:28 +00:00
|
|
|
go test -v -cover ./storage/boltdb/...
|
2016-05-04 01:29:36 +00:00
|
|
|
|
2016-05-22 03:17:40 +00:00
|
|
|
memory_test: init
|
2016-07-20 07:50:28 +00:00
|
|
|
go test -v -cover ./storage/memory/...
|
2016-05-04 01:29:36 +00:00
|
|
|
|
2016-05-22 03:17:40 +00:00
|
|
|
config_test: init
|
2016-07-20 07:50:28 +00:00
|
|
|
go test -v -cover ./config/...
|
2016-05-03 01:42:53 +00:00
|
|
|
|
2016-05-04 01:29:36 +00:00
|
|
|
html:
|
2016-07-20 07:50:28 +00:00
|
|
|
go tool cover -html=.cover/coverage.txt
|
2016-04-11 06:10:46 +00:00
|
|
|
|
2016-03-27 12:20:57 +00:00
|
|
|
docker_build: clean
|
2016-05-04 07:32:51 +00:00
|
|
|
tar -zcvf build.tar.gz gorush.go gorush config storage Makefile glide.lock glide.yaml
|
2016-05-09 07:09:58 +00:00
|
|
|
sed -e "s/#VERSION#/$(VERSION)/g" docker/Dockerfile.build > docker/Dockerfile.tmp
|
|
|
|
docker build --rm -t $(BUILD_IMAGE) -f docker/Dockerfile.tmp .
|
2016-04-13 07:22:04 +00:00
|
|
|
docker run --rm $(BUILD_IMAGE) > gorush.tar.gz
|
2016-03-27 12:20:57 +00:00
|
|
|
|
2016-05-22 03:17:40 +00:00
|
|
|
docker_test: init
|
2016-07-11 02:33:18 +00:00
|
|
|
docker-compose -p ${PRODUCTION_IMAGE} -f docker/docker-compose.testing.yml run --rm gorush
|
|
|
|
docker-compose -p ${PRODUCTION_IMAGE} -f docker/docker-compose.testing.yml down
|
2016-04-10 03:36:49 +00:00
|
|
|
|
2016-05-22 14:28:57 +00:00
|
|
|
docker_production: docker_build
|
|
|
|
docker build --rm -t $(PRODUCTION_IMAGE) -f docker/Dockerfile.dist .
|
|
|
|
|
|
|
|
deploy: docker_production
|
2016-04-11 09:18:53 +00:00
|
|
|
ifeq ($(tag),)
|
|
|
|
@echo "Usage: make $@ tag=<tag>"
|
|
|
|
@exit 1
|
|
|
|
endif
|
2016-06-29 03:14:52 +00:00
|
|
|
docker tag $(PRODUCTION_IMAGE):latest $(DEPLOY_ACCOUNT)/$(PRODUCTION_IMAGE):$(tag)
|
2016-04-11 09:18:53 +00:00
|
|
|
docker push $(DEPLOY_ACCOUNT)/$(PRODUCTION_IMAGE):$(tag)
|
|
|
|
|
2016-07-22 03:15:31 +00:00
|
|
|
install: tool
|
2016-07-19 14:20:23 +00:00
|
|
|
@which glide || (curl https://glide.sh/get | sh)
|
2016-07-19 07:50:29 +00:00
|
|
|
@glide install
|
2016-05-04 03:05:44 +00:00
|
|
|
|
2016-07-19 07:50:29 +00:00
|
|
|
update:
|
|
|
|
@glide up
|
2016-05-04 03:05:44 +00:00
|
|
|
|
2016-06-28 01:19:25 +00:00
|
|
|
fmt:
|
2016-06-30 01:37:47 +00:00
|
|
|
@echo $(TARGETS_NOVENDOR) | xargs go fmt
|
2016-06-28 01:19:25 +00:00
|
|
|
|
2016-07-22 03:15:31 +00:00
|
|
|
tool:
|
|
|
|
sh ./script/coverage.sh tool
|
2016-07-20 06:13:30 +00:00
|
|
|
|
|
|
|
junit_report:
|
2016-07-20 07:50:28 +00:00
|
|
|
sh ./script/coverage.sh junit
|
2016-07-20 06:13:30 +00:00
|
|
|
|
|
|
|
coverage_report:
|
2016-07-20 07:50:28 +00:00
|
|
|
sh ./script/coverage.sh coverage
|
2016-07-20 06:13:30 +00:00
|
|
|
|
|
|
|
lint_report:
|
2016-07-20 07:50:28 +00:00
|
|
|
sh ./script/coverage.sh lint
|
2016-07-20 06:13:30 +00:00
|
|
|
|
|
|
|
vet_report:
|
2016-07-20 07:50:28 +00:00
|
|
|
sh ./script/coverage.sh vet
|
2016-07-20 06:13:30 +00:00
|
|
|
|
2016-07-20 14:49:59 +00:00
|
|
|
cloc_report:
|
|
|
|
sh ./script/coverage.sh cloc
|
|
|
|
|
|
|
|
report: junit_report coverage_report lint_report vet_report cloc_report
|
2016-04-13 06:59:28 +00:00
|
|
|
|
2016-03-27 12:20:57 +00:00
|
|
|
clean:
|
2016-07-20 06:13:30 +00:00
|
|
|
-rm -rf build.tar.gz \
|
|
|
|
gorush.tar.gz bin/* \
|
|
|
|
gorush.tar.gz \
|
|
|
|
gorush/gorush.db \
|
|
|
|
storage/boltdb/gorush.db \
|
2016-07-20 07:50:28 +00:00
|
|
|
.cover
|