2018-05-17 18:35:53 +03:00
|
|
|
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
2018-08-17 16:31:55 +03:00
|
|
|
SRC_DIR=$(ROOT_DIR)/src
|
2018-05-18 15:38:59 +03:00
|
|
|
MIGRATIONS_DIR=$(ROOT_DIR)/migrations
|
2018-05-17 18:35:53 +03:00
|
|
|
CONFIG_FILE=$(ROOT_DIR)/config.yml
|
2018-05-31 15:03:57 +03:00
|
|
|
BIN=$(ROOT_DIR)/bin/transport
|
2018-05-17 18:35:53 +03:00
|
|
|
REVISION=$(shell git describe --tags 2>/dev/null || git log --format="v0.0-%h" -n 1 || echo "v0.0-unknown")
|
|
|
|
|
|
|
|
fmt:
|
|
|
|
@echo "==> Running gofmt"
|
2018-08-23 13:11:40 +03:00
|
|
|
@gofmt -l -s -w $(ROOT_DIR)
|
2018-05-17 18:35:53 +03:00
|
|
|
|
2018-05-18 15:38:59 +03:00
|
|
|
deps:
|
|
|
|
@echo "==> Installing dependencies"
|
2018-08-17 13:36:25 +03:00
|
|
|
@go mod tidy
|
2018-05-17 18:35:53 +03:00
|
|
|
|
2020-03-27 15:11:00 +03:00
|
|
|
build: deps fmt
|
|
|
|
@echo "==> Building"
|
|
|
|
@cd $(SRC_DIR) && CGO_ENABLED=0 go build -o $(BIN) -ldflags "-X common.build=${REVISION}" .
|
|
|
|
@echo $(BIN)
|
|
|
|
|
2018-05-17 18:35:53 +03:00
|
|
|
migrate: build
|
2018-05-31 15:03:57 +03:00
|
|
|
${BIN} --config $(CONFIG_FILE) migrate -p $(MIGRATIONS_DIR)
|
2018-05-17 18:35:53 +03:00
|
|
|
|
2018-05-18 15:38:59 +03:00
|
|
|
migrate_down: build
|
|
|
|
@${BIN} --config $(CONFIG_FILE) migrate -v down
|
2020-03-27 15:11:00 +03:00
|
|
|
|
|
|
|
run: migrate
|
|
|
|
@echo "==> Running"
|
|
|
|
@${BIN} --config $(CONFIG_FILE) run
|
|
|
|
|
|
|
|
test: migrate
|
|
|
|
@echo "==> Running tests"
|
|
|
|
@cd $(ROOT_DIR) && go test ./... -v -cpu 2
|
|
|
|
|