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 06:13:30 +00:00
|
|
|
@sh go.test.sh atomic | tee junit.txt
|
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-06-30 02:09:02 +00:00
|
|
|
go test -v -cover -covermode=count -coverprofile=coverage.txt ./gorush/...
|
2016-05-03 01:42:53 +00:00
|
|
|
|
2016-05-22 03:17:40 +00:00
|
|
|
redis_test: init
|
2016-06-30 02:09:02 +00:00
|
|
|
go test -v -cover -covermode=count -coverprofile=coverage.txt ./storage/redis/...
|
2016-05-03 01:42:53 +00:00
|
|
|
|
2016-05-22 03:17:40 +00:00
|
|
|
boltdb_test: init
|
2016-06-30 02:09:02 +00:00
|
|
|
go test -v -cover -covermode=count -coverprofile=coverage.txt ./storage/boltdb/...
|
2016-05-04 01:29:36 +00:00
|
|
|
|
2016-05-22 03:17:40 +00:00
|
|
|
memory_test: init
|
2016-06-30 02:09:02 +00:00
|
|
|
go test -v -cover -covermode=count -coverprofile=coverage.txt ./storage/memory/...
|
2016-05-04 01:29:36 +00:00
|
|
|
|
2016-05-22 03:17:40 +00:00
|
|
|
config_test: init
|
2016-06-30 02:09:02 +00:00
|
|
|
go test -v -cover -covermode=count -coverprofile=coverage.txt ./config/...
|
2016-05-03 01:42:53 +00:00
|
|
|
|
2016-05-04 01:29:36 +00:00
|
|
|
html:
|
2016-06-30 05:41:26 +00:00
|
|
|
go tool cover -html=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-19 07:50:29 +00:00
|
|
|
install:
|
2016-07-19 14:20:23 +00:00
|
|
|
@which glide || (curl https://glide.sh/get | sh)
|
2016-07-20 06:13:30 +00:00
|
|
|
@which go-junit-report || go get -u github.com/jstemmer/go-junit-report
|
|
|
|
@which gocov || go get -u github.com/axw/gocov/gocov
|
|
|
|
@which gocov-xml || go get -u github.com/AlekSi/gocov-xml
|
|
|
|
@which golint || go get -u github.com/golang/lint/golint
|
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-04-13 06:59:28 +00:00
|
|
|
lint:
|
2016-07-20 06:13:30 +00:00
|
|
|
@golint -set_exit_status=1 ./...
|
|
|
|
|
|
|
|
vet:
|
|
|
|
@go vet -n -x ./...
|
|
|
|
|
|
|
|
junit_report:
|
|
|
|
cat junit.txt | go-junit-report > report.xml
|
|
|
|
|
|
|
|
coverage_report:
|
|
|
|
gocov convert coverage.txt | gocov-xml > coverage.xml
|
|
|
|
|
|
|
|
lint_report:
|
|
|
|
golint ./... > lint.txt
|
|
|
|
|
|
|
|
vet_report:
|
|
|
|
go vet -n -x ./... > vet.txt
|
|
|
|
|
|
|
|
report: junit_report coverage_report lint_report vet_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 \
|
|
|
|
*.txt \
|
|
|
|
*.xml
|