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"
|
|
|
|
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-05-13 06:54:35 +00:00
|
|
|
RANDOM := $(shell date '+%Y%m%d%H%M%S%s')
|
2016-03-27 12:20:57 +00:00
|
|
|
|
|
|
|
all: build
|
|
|
|
|
|
|
|
build: clean
|
2016-05-04 07:10:43 +00:00
|
|
|
sh script/build.sh $(VERSION)
|
2016-03-27 12:20:57 +00:00
|
|
|
|
2016-05-04 01:29:36 +00:00
|
|
|
test: redis_test boltdb_test memory_test config_test
|
2016-05-04 02:53:17 +00:00
|
|
|
go test -v -cover -covermode=count -coverprofile=coverage.out ./gorush/...
|
2016-05-03 01:42:53 +00:00
|
|
|
|
|
|
|
redis_test:
|
2016-05-04 02:53:17 +00:00
|
|
|
go test -v -cover -covermode=count -coverprofile=coverage.out ./storage/redis/...
|
2016-05-03 01:42:53 +00:00
|
|
|
|
|
|
|
boltdb_test:
|
2016-05-04 02:53:17 +00:00
|
|
|
go test -v -cover -covermode=count -coverprofile=coverage.out ./storage/boltdb/...
|
2016-05-04 01:29:36 +00:00
|
|
|
|
|
|
|
memory_test:
|
2016-05-04 02:53:17 +00:00
|
|
|
go test -v -cover -covermode=count -coverprofile=coverage.out ./storage/memory/...
|
2016-05-04 01:29:36 +00:00
|
|
|
|
|
|
|
config_test:
|
2016-05-04 02:53:17 +00:00
|
|
|
go test -v -cover -covermode=count -coverprofile=coverage.out ./config/...
|
2016-05-03 01:42:53 +00:00
|
|
|
|
2016-05-04 01:29:36 +00:00
|
|
|
html:
|
2016-05-13 06:54:35 +00:00
|
|
|
go tool cover -html=coverage.out && unlink coverage.out
|
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-04-11 08:38:59 +00:00
|
|
|
docker build --rm -t $(PRODUCTION_IMAGE) -f docker/Dockerfile.dist .
|
2016-03-27 12:20:57 +00:00
|
|
|
|
2016-04-11 06:10:46 +00:00
|
|
|
docker_test:
|
2016-05-13 06:54:35 +00:00
|
|
|
docker-compose -p ${RANDOM} -f docker/docker-compose.testing.yml run --rm gorush
|
|
|
|
docker-compose -p ${RANDOM} -f docker/docker-compose.testing.yml down
|
2016-04-10 03:36:49 +00:00
|
|
|
|
2016-04-11 09:18:53 +00:00
|
|
|
deploy:
|
|
|
|
ifeq ($(tag),)
|
|
|
|
@echo "Usage: make $@ tag=<tag>"
|
|
|
|
@exit 1
|
|
|
|
endif
|
|
|
|
docker tag -f $(PRODUCTION_IMAGE):latest $(DEPLOY_ACCOUNT)/$(PRODUCTION_IMAGE):$(tag)
|
|
|
|
docker push $(DEPLOY_ACCOUNT)/$(PRODUCTION_IMAGE):$(tag)
|
|
|
|
|
2016-05-04 03:05:44 +00:00
|
|
|
bundle:
|
|
|
|
glide install
|
|
|
|
|
|
|
|
bundle_update:
|
|
|
|
glide update --all-dependencies --resolve-current
|
|
|
|
|
2016-04-13 06:59:28 +00:00
|
|
|
lint:
|
2016-04-13 07:22:04 +00:00
|
|
|
golint gorush
|
2016-04-13 06:59:28 +00:00
|
|
|
|
2016-03-27 12:20:57 +00:00
|
|
|
clean:
|
2016-05-11 09:00:17 +00:00
|
|
|
-rm -rf build.tar.gz gorush.tar.gz bin/* coverage.out gorush.tar.gz
|