forked from retailcrm/mg-transport-telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
34 lines (26 loc) · 874 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
SRC_DIR=$(ROOT_DIR)/src
MIGRATIONS_DIR=$(ROOT_DIR)/migrations
CONFIG_FILE=$(ROOT_DIR)/config.yml
BIN=$(ROOT_DIR)/bin/transport
REVISION=$(shell git describe --tags 2>/dev/null || git log --format="v0.0-%h" -n 1 || echo "v0.0-unknown")
fmt:
@echo "==> Running gofmt"
@gofmt -l -s -w $(ROOT_DIR)
deps:
@echo "==> Installing dependencies"
@go mod tidy
build: deps fmt
@echo "==> Building"
@cd $(SRC_DIR) && CGO_ENABLED=0 go build -o $(BIN) -ldflags "-X common.build=${REVISION}" .
@echo $(BIN)
migrate: build
${BIN} --config $(CONFIG_FILE) migrate -p $(MIGRATIONS_DIR)
migrate_down: build
@${BIN} --config $(CONFIG_FILE) migrate -v down
run: migrate
@echo "==> Running"
@${BIN} --config $(CONFIG_FILE) run
test: migrate
@echo "==> Running tests"
@cd $(ROOT_DIR) && go test ./... -v -cpu 2