2016-04-12 14:45:37 +00:00
|
|
|
.PHONY: all
|
2016-03-27 12:20:57 +00:00
|
|
|
|
2016-07-30 12:55:29 +00:00
|
|
|
export PROJECT_PATH = /go/src/github.com/appleboy/gorush
|
2016-03-27 12:20:57 +00:00
|
|
|
|
2016-12-07 08:40:00 +00:00
|
|
|
DIST := dist
|
|
|
|
EXECUTABLE := gorush
|
|
|
|
|
|
|
|
BUILD_IMAGE := "gorush-build"
|
|
|
|
DEPLOY_ACCOUNT := appleboy
|
|
|
|
DEPLOY_IMAGE := $(EXECUTABLE)
|
|
|
|
|
|
|
|
TARGETS ?= linux/*,darwin/*
|
|
|
|
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
|
|
|
|
SOURCES ?= $(shell find . -name "*.go" -type f)
|
|
|
|
TAGS ?=
|
|
|
|
LDFLAGS += -X 'main.Version=$(VERSION)'
|
|
|
|
|
2016-08-15 12:43:34 +00:00
|
|
|
ifneq ($(shell uname), Darwin)
|
|
|
|
EXTLDFLAGS = -extldflags "-static" $(null)
|
|
|
|
else
|
|
|
|
EXTLDFLAGS =
|
|
|
|
endif
|
|
|
|
|
2016-12-07 08:40:00 +00:00
|
|
|
ifneq ($(DRONE_TAG),)
|
|
|
|
VERSION ?= $(DRONE_TAG)
|
|
|
|
else
|
|
|
|
ifneq ($(DRONE_BRANCH),)
|
|
|
|
VERSION ?= $(DRONE_BRANCH)
|
|
|
|
else
|
|
|
|
VERSION ?= $(shell git describe --tags --always || git rev-parse --short HEAD)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
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-12-07 08:40:00 +00:00
|
|
|
fmt:
|
|
|
|
go fmt $(PACKAGES)
|
|
|
|
|
|
|
|
vet:
|
|
|
|
go vet $(PACKAGES)
|
|
|
|
|
|
|
|
errcheck:
|
|
|
|
@which errcheck > /dev/null; if [ $$? -ne 0 ]; then \
|
|
|
|
go get -u github.com/kisielk/errcheck; \
|
|
|
|
fi
|
|
|
|
errcheck $(PACKAGES)
|
|
|
|
|
|
|
|
lint:
|
|
|
|
@which golint > /dev/null; if [ $$? -ne 0 ]; then \
|
|
|
|
go get -u github.com/golang/lint/golint; \
|
|
|
|
fi
|
|
|
|
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
|
|
|
|
|
|
|
|
dep_install:
|
2016-07-30 14:05:38 +00:00
|
|
|
glide install
|
|
|
|
|
2016-12-07 08:40:00 +00:00
|
|
|
dep_update:
|
|
|
|
glide up
|
|
|
|
|
|
|
|
install: $(wildcard *.go)
|
|
|
|
go install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
|
|
|
|
|
|
|
|
build: $(EXECUTABLE)
|
2016-07-30 14:05:38 +00:00
|
|
|
|
2016-12-07 08:40:00 +00:00
|
|
|
$(EXECUTABLE): $(SOURCES)
|
|
|
|
go build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o bin/$@
|
2016-08-15 12:43:34 +00:00
|
|
|
|
2016-12-07 08:40:00 +00:00
|
|
|
corss_build: clean
|
2016-05-04 07:10:43 +00:00
|
|
|
sh script/build.sh $(VERSION)
|
2016-03-27 12:20:57 +00:00
|
|
|
|
2016-12-07 08:40:00 +00:00
|
|
|
test:
|
|
|
|
for PKG in $(PACKAGES); do go test -v -cover -coverprofile $$GOPATH/src/$$PKG/coverage.txt $$PKG || exit 1; done;
|
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-08-02 07:35:28 +00:00
|
|
|
buntdb_test: init
|
|
|
|
go test -v -cover ./storage/buntdb/...
|
|
|
|
|
2016-09-19 08:19:20 +00:00
|
|
|
leveldb_test: init
|
|
|
|
go test -v -cover ./storage/leveldb/...
|
|
|
|
|
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-12-07 08:40:00 +00:00
|
|
|
docker_binary_build:
|
|
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o bin/$@
|
|
|
|
|
|
|
|
docker_image:
|
|
|
|
docker build -t $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE) -f Dockerfile .
|
|
|
|
|
|
|
|
docker_release: docker_binary_build docker_image
|
|
|
|
|
2016-10-01 08:11:23 +00:00
|
|
|
docker_build:
|
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
|
2016-10-01 08:11:23 +00:00
|
|
|
docker build -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-08-15 12:43:34 +00:00
|
|
|
docker_production:
|
2016-12-07 08:40:00 +00:00
|
|
|
docker build -t $(EXECUTABLE) -f docker/Dockerfile.dist .
|
2016-05-22 14:28:57 +00:00
|
|
|
|
2016-10-01 08:11:23 +00:00
|
|
|
docker_deploy:
|
2016-04-11 09:18:53 +00:00
|
|
|
ifeq ($(tag),)
|
|
|
|
@echo "Usage: make $@ tag=<tag>"
|
|
|
|
@exit 1
|
|
|
|
endif
|
2016-12-07 08:40:00 +00:00
|
|
|
docker tag $(EXECUTABLE):latest $(DEPLOY_ACCOUNT)/$(EXECUTABLE):$(tag)
|
|
|
|
docker push $(DEPLOY_ACCOUNT)/$(EXECUTABLE):$(tag)
|
2016-04-11 09:18:53 +00:00
|
|
|
|
2016-08-15 12:43:34 +00:00
|
|
|
docker_test: init clean
|
2016-12-07 08:40:00 +00:00
|
|
|
docker-compose -p ${EXECUTABLE} -f docker/docker-compose.testing.yml run gorush
|
|
|
|
docker-compose -p ${EXECUTABLE} -f docker/docker-compose.testing.yml down
|
2016-06-28 01:19:25 +00:00
|
|
|
|
2016-03-27 12:20:57 +00:00
|
|
|
clean:
|
2016-12-07 08:40:00 +00:00
|
|
|
go clean -x -i ./...
|
|
|
|
find . -name coverage.txt -delete
|
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
|
2016-11-20 01:54:16 +00:00
|
|
|
|
|
|
|
version:
|
|
|
|
@echo $(VERSION)
|