forked from department-of-veterans-affairs/vets-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (91 loc) · 1.86 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
$stdout.sync = true
export VETS_API_USER_ID := $(shell id -u)
ifdef env
ENV_ARG := $(env)
else
ENV_ARG := dev
endif
COMPOSE_DEV := docker-compose
COMPOSE_TEST := docker-compose -f docker-compose.test.yml
BASH := run --rm --service-ports vets-api bash
BASH_DEV := $(COMPOSE_DEV) $(BASH) -c
BASH_TEST := $(COMPOSE_TEST) $(BASH) --login -c
SPEC_PATH := spec/
DB := "bin/rails db:setup db:migrate"
LINT := "bin/rails lint"
DOWN := down
SECURITY := "bin/rails security"
.PHONY: default
default: ci
.PHONY: ci
ci:
@$(BASH_TEST) "bin/rails db:setup db:migrate ci"
.PHONY: bash
bash:
@$(COMPOSE_DEV) $(BASH)
.PHONY: build
build:
ifeq ($(ENV_ARG), dev)
$(COMPOSE_DEV) build
else
$(COMPOSE_TEST) build
endif
.PHONY: db
db:
ifeq ($(ENV_ARG), dev)
@$(BASH_DEV) $(DB)
else
@$(BASH_TEST) $(DB)
endif
.PHONY: lint
lint:
ifeq ($(ENV_ARG), dev)
@$(BASH_DEV) $(LINT)
else
@$(BASH_TEST) $(LINT)
endif
.PHONY: console
console:
@$(BASH_DEV) "bundle exec rails c"
.PHONY: danger
danger:
@$(BASH_TEST) "bundle exec danger --verbose"
.PHONY: docker-clean
docker-clean:
@$(COMPOSE_DEV) down --rmi all --volumes
.PHONY: down
down:
ifeq ($(ENV_ARG), dev)
@$(COMPOSE_DEV) $(DOWN)
else
@$(COMPOSE_TEST) $(DOWN)
endif
.PHONY: guard
guard:
@$(BASH_DEV) "bundle exec guard"
.PHONY: migrate
migrate:
@$(BASH_DEV) "bin/rails db:migrate"
.PHONY: rebuild
rebuild: down
@$(COMPOSE_DEV) build
.PHONY: security
security:
ifeq ($(ENV_ARG), dev)
@$(BASH_DEV) $(SECURITY)
else
@$(BASH_TEST) $(SECURITY)
endif
.PHONY: server
server:
@$(BASH_DEV) "rm -f tmp/pids/server.pid && bundle exec rails server"
.PHONY: spec
spec:
ifeq ($(ENV_ARG), dev)
@$(BASH_DEV) "bin/rspec ${SPEC_PATH}"
else
@$(BASH_TEST) "bin/rails spec:with_codeclimate_coverage"
endif
.PHONY: up
up: db
@$(BASH_DEV) "rm -f tmp/pids/server.pid && foreman start -m all=1,clamd=0,freshclam=0"