-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
221 lines (193 loc) · 7.31 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# wp-veritas' Makefile
SHELL := /bin/bash
VERSION=$(shell ./change-version.sh -pv)
.PHONY: help
help:
@echo "Main:"
@echo " make help — Display this help"
@echo " make meteor — Run application wp-veritas on localhost"
@echo "Utilities:"
@echo " make print-env — Print the environment variables"
@echo " make test — Run test suite"
@echo " make apidoc — Refresh API documentation"
@echo " make prettier — Prettier all the things"
@echo " make prettier-check — Check if prettier need to be run"
@echo "Release:"
@echo " make version — Get the version number of wp-veritas"
@echo " make version-patch — Bump wp-veritas version (patch)"
@echo " make version-minor — Bump wp-veritas version (minor)"
@echo " make version-major — Bump wp-veritas version (major)"
@echo " make version-special — Bump wp-veritas to specified version"
@echo "Publication and deployment:"
@echo " make publish — To build, tag and push new Image"
@echo " make deploy-dev — To deploy on dev environment"
@echo " make deploy-test — To deploy on test environment"
@echo " make deploy-prod — To deploy on prod environment"
@echo "Development:"
@echo " make dev-up — Brings up Docker services for development"
@echo " make dev-build — Build Docker services for development"
@echo " make dev-build-force — Force build Docker services for development"
@echo " make dev-exec — Enter the meteor container"
@echo " make dev-cli — Install veritas-cli in the meteor container"
@echo " make dev-data — load-tests-data-on-localhost-db"
# To add all variable to your shell, use
# export $(xargs < /keybase/team/epfl_wpveritas/env);
check-env:
ifeq ($(wildcard /keybase/team/epfl_wpveritas/env),)
@echo "Be sure to have access to /keybase/team/epfl_wpveritas/env"
@exit 1
else
include /keybase/team/epfl_wpveritas/env
endif
print-env: check-env
@echo "WP_VERITAS_DB_PASSWORD_DEV=${WP_VERITAS_DB_PASSWORD_DEV}"
@echo "WP_VERITAS_DB_PASSWORD_TEST=${WP_VERITAS_DB_PASSWORD_TEST}"
@echo "WP_VERITAS_DB_PASSWORD_PROD=${WP_VERITAS_DB_PASSWORD_PROD}"
@echo "WP_VERITAS_BOT_TOKEN_TEST=${WP_VERITAS_BOT_TOKEN_TEST}"
@echo "WP_VERITAS_ALERTS_TELEGRAM_IDS_TEST=${WP_VERITAS_ALERTS_TELEGRAM_IDS_TEST}"
@echo "WP_VERITAS_BOT_TOKEN=${WP_VERITAS_BOT_TOKEN}"
@echo "WP_VERITAS_ALERTS_TELEGRAM_IDS=${WP_VERITAS_ALERTS_TELEGRAM_IDS}"
@echo "WP_VERITAS_AWX_TOKEN=${AWX_TOKEN}"
@echo "MOCHA_TIMEOUT=${MOCHA_TIMEOUT}"
.PHONY: meteor
meteor: check-env app/packages/meteor-synced-cron
@echo '**** Start meteor: ****'
cd app/; env WP_VERITAS_BOT_TOKEN=$$WP_VERITAS_BOT_TOKEN_TEST WP_VERITAS_ALERTS_TELEGRAM_IDS=$$WP_VERITAS_ALERTS_TELEGRAM_IDS_TEST WP_VERITAS_AWX_TOKEN=$$AWX_TOKEN meteor --settings meteor-settings.json
.PHONY: test
test: check-env app/packages/meteor-synced-cron
@echo '**** Run test: ****'
@cd app; env MOCHA_TIMEOUT=$$MOCHA_TIMEOUT WP_VERITAS_BOT_TOKEN=$$WP_VERITAS_BOT_TOKEN_TEST WP_VERITAS_ALERTS_TELEGRAM_IDS=$$WP_VERITAS_ALERTS_TELEGRAM_IDS_TEST TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha --port 3888
.PHONY: apidoc
apidoc:
@echo Running: npx apidoc --single -i $$(pwd)/app/server/ -o $$(pwd)/app/public/api/ -c $$(pwd)/app/apidoc.json
@npx apidoc --single -i $$(pwd)/app/server/ -o $$(pwd)/app/public/api/ -c $$(pwd)/app/apidoc.json
xdg-open $$(pwd)/app/public/api/index.html;
.PHONY: prettier-check
prettier-check:
npx prettier --check "app/{client, private, server, tests}/**/*.js"
npx prettier --check "cli/**/*.js"
npx prettier --check "test/**/*.js"
.PHONY: prettier
prettier:
npx prettier --write "app/{client, private, server, tests}/**/*.js"
npx prettier --write "cli/**/*.js"
npx prettier --write "test/**/*.js"
.PHONY: version
version:
@echo $(VERSION)
.PHONY: version-patch
version-patch:
@./change-version.sh -a
.PHONY: version-minor
version-minor:
@./change-version.sh -a -v minor
.PHONY: version-major
version-major:
@./change-version.sh -a -v major
.PHONY: version-special
version-special:
@if test "$(WP_VERITAS_VERSION)" = "" ; then \
echo "Please set WP_VERITAS_VERSION, example:"; \
echo " make version-special WP_VERITAS_VERSION=3.2.1"; \
exit 1; \
fi
@echo "Change version to $$WP_VERITAS_VERSION"
@./change-version.sh -a -v $$WP_VERITAS_VERSION
.PHONY: docker-build
docker-build:
@echo '**** Start build: ****'
docker build -t epflsi/wp-veritas .
@echo '**** End build: ****'
.PHONY: docker-tag
docker-tag:
@echo '**** Start tag: ****'
docker tag epflsi/wp-veritas:latest epflsi/wp-veritas:$(VERSION)
@echo '**** End tag: ****'
.PHONY: docker-push
docker-push:
@echo '**** Start push: ****'
docker push epflsi/wp-veritas:$(VERSION)
docker push epflsi/wp-veritas:latest
@echo '**** End push: ****'
.PHONY: deploy-dev
deploy-dev:
@echo '**** Start deploy: ****'
if [ -z "$$(oc project)" ]; then \
echo "pas loggué"; \
oc login; \
else \
echo "loggué"; \
fi
cd ansible/; \
export $$(xargs < /keybase/team/epfl_wpveritas/env); \
ansible-playbook playbook.yml -i hosts-dev -vvv
@echo '**** End deploy: ****'
@echo 'https://wp-veritas.128.178.222.83.nip.io'
.PHONY: deploy-test
deploy-test:
@echo '**** Start deploy: ****'
if [ -z "$$(oc project)" ]; then \
echo "pas loggué"; \
oc login; \
else \
echo "loggué"; \
fi
cd ansible/; \
export $$(xargs < /keybase/team/epfl_wpveritas/env); \
ansible-playbook playbook.yml -i hosts-test
@echo '**** End deploy: ****'
@echo 'https://wp-veritas-test.epfl.ch'
.PHONY: deploy-prod
deploy-prod:
@echo '**** Start deploy: ****'
if [ -z "$$(oc project)" ]; then \
echo "pas loggué"; \
oc login; \
else \
echo "loggué"; \
fi
cd ansible/; \
export $$(xargs < /keybase/team/epfl_wpveritas/env); \
ansible-playbook playbook.yml -i hosts-prod
@echo '**** End deploy: ****'
@echo 'https://wp-veritas.epfl.ch'
.PHONY: git-tag
git-tag:
git tag -a v$(VERSION) -m v$(VERSION)
.PHONY: publish
publish:
@read -p "Want to bump the version? [Yy]: " -n 1 -r; \
if [[ ! $$REPLY =~ ^[Yy]$$ ]]; then \
exit; \
else \
make version-minor; \
fi
$(MAKE) apidoc
$(MAKE) docker-build
$(MAKE) docker-tag
$(MAKE) docker-push
$(MAKE) git-tag
app/packages/meteor-synced-cron:
@mkdir -p $(dir $@) || true
cd $(dir $@); git clone -b update-to-async [email protected]:sebastianspiller/meteor-synced-cron.git
################################################################################
# Targets for development purpose only #
################################################################################
.PHONY: dev-up
dev-up: check-env
@docker compose -f docker-compose-dev.yml up
.PHONY: dev-build
dev-build: check-env
@docker compose -f docker-compose-dev.yml build
.PHONY: dev-build-force
dev-build-force: check-env
@docker compose -f docker-compose-dev.yml build --force-rm --no-cache --pull
.PHONY: dev-exec
dev-exec:
@docker exec -it --user root wp-veritas_meteor bash
.PHONY: dev-cli
dev-cli:
@docker exec -it --user root wp-veritas_meteor /bin/bash -c "cd /src/cli && npm install && npm install -g ./ && cd /src/ && veritas-cli --help"
.PHONY: dev-data
dev-data: dev-cli
@docker exec -it --user root wp-veritas_meteor /bin/bash -c "cd /src && veritas-cli load-tests-data-on-localhost-db"