-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
49 lines (38 loc) · 1.4 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
47
48
49
OS_NAME := $(shell uname -s | tr A-Z a-z)
SHELL := /bin/bash
DB_URI := $(shell grep DB_URI .env | sed 's/DB_URI=//')
API_URL := $(shell grep API_URL .env | sed 's/API_URL=//')
### Migrations
get-migrator:
mkdir -p migrations/bin
cd migrations/bin && \
curl -L https://github.com/golang-migrate/migrate/releases/download/v4.14.1/migrate.$(OS_NAME)-amd64.tar.gz | tar xvz
create-migration:
./migrations/bin/migrate.$(OS_NAME)-amd64 create \
-dir ./migrations \
-ext "sql" \
-seq \
"$(name)"
migrate-up:
./migrations/bin/migrate.$(OS_NAME)-amd64 \
-source file://migrations \
-database $(DB_URI) up
migrate-down:
./migrations/bin/migrate.$(OS_NAME)-amd64 \
-source file://migrations \
-database $(DB_URI) down
## Docker Compose
compose-update:
export $$(cat .env | xargs) && docker-compose pull && docker-compose up -d --force-recreate
compose-dev:
export $$(cat .env | xargs) && docker-compose -f docker-compose.dev.yml up -d --force-recreate --build
compose-integration:
export $$(cat .test.env | xargs) && docker-compose -f docker-compose.dev.yml up -d --force-recreate --build
### tests
test:
go test ./app/... -v
test-color:
go test ./app/... -v | sed ''/PASS/s//$$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$$(printf "\033[31mFAIL\033[0m")/''
integration-tests:
API_URL=$(API_URL) DB_URI=$(DB_URI) go test ./tests/... -v
integration-tests-compose: compose-integration integration-tests