-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
46 lines (32 loc) · 1.09 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
CURDIR=$(shell pwd)
BINDIR=${CURDIR}/bin
LINTVER=v1.49.0
LINTBIN=${BINDIR}/lint_${GOVER}_${LINTVER}
PACKAGE=gitlab.ozon.dev/stepanov.ao.dev/telegram-bot/cmd/bot
PACKAGE_MIGRATE=gitlab.ozon.dev/stepanov.ao.dev/telegram-bot/cmd/migrate
MIGRATIONS_DIR=file://internal/migrations
DATABASE_URL=postgresql://${DATABASE_USER}:${DATABASE_PASS}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_DB}?sslmode=disable
all: build test lint
build: bindir
@go build -o ${BINDIR}/bot ${PACKAGE}
bindir:
@mkdir -p ${BINDIR}
test:
@go test ./...
run:
@go run ${PACKAGE} -config configs/config.example.yaml | pino-pretty
generate:
@go generate ./...
@go run ${PACKAGE_MIGRATE} -config configs/config.migrate.yaml -name ${MIGRATION_NAME}
lint: install-lint
@${LINTBIN} run
install-lint: bindir
@test -f ${LINTBIN} || \
(GOBIN=${BINDIR} go install github.com/golangci/golangci-lint/cmd/golangci-lint@${LINTVER} && \
mv ${BINDIR}/golangci-lint ${LINTBIN})
precommit: build test lint
echo "OK"
docker-run:
@sudo docker compose up -d
migrate:
@atlas migrate apply --dir "${MIGRATIONS_DIR}" --url "${DATABASE_URL}"