forked from pmaengineering/ppp-web
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmakefile
220 lines (212 loc) · 6.83 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
SHELL=/bin/bash
.PHONY: lint linttest lintall pylint pylinttest pylintall code codetest \
codeall doc doctest docall test testdoc serve serve-local serve-heroku-local \
serve-staging-linode serve-production-linode push-production-heroku \
serve-production push-staging-heroku serve-staging shell db production \
staging production-linode staging-linode tags ltags upgrade-pmix-trunk-master \
upgrade-pmix-trunk-develop upgrade-pmix-joeflack4-master \
upgrade-pmix-joeflack4-develop upgrade-pmix upgrade-ppp-web-joeflack4-develop \
upgrade-ppp-web activate upgrade-ppp serve-dev serve-dev-network-accessible \
production-connect-heroku staging-connect-heroku logs logs-staging production \
staging production-push staging-push push-production push-staging \
circleci-validate-config update-ppp ppp-update ppp-upgrade gunicorn-local \
serve-local production-push-ci stagingpush-ci logs-heroku logs-staging-heroku \
validations validate git-hash git-hash install upgrade-once upgrade uninstall \
reinstall install-internal-dependencies install-latest-internal-dependencies \
install-latest install-stable upgrade-latest upgrade-stable
# DEVELOPMENT
## Linting
SRC=./ppp_web/
TEST=./test/
### All linting
lint:
${LINT_SRC}; ${CODE_SRC}; ${DOC_SRC}
# If you want to run this command directly, use the following:
# python -m pylint --output-format=colorized --reports=n ppp_web test; \
# python -m pycodestyle ppp_web test; \
# python -m pydocstyle ppp_web test
linttest:
${LINT_TEST}; ${CODE_TEST}; ${DOC_TEST}
lintall: lint linttest
### Pylint only
PYLINT=python -m pylint \
--output-format=colorized \
--reports=n
LINT_SRC=${PYLINT} ${SRC}
LINT_TEST=${PYLINT} ${TEST}
pylint:
${LINT_SRC}
pylinttest:
${LINT_TEST}
pylintall: pylint pylinttest
### Pycodestyle only
PYCODESTYLE=python -m pycodestyle
CODE_SRC=${PYCODESTYLE} ${SRC}
CODE_TEST=${PYCODESTYLE} ${TEST}
code:
${CODE_SRC}
codetest:
${CODE_TEST}
codeall: code codetest
### Pydocstyle only
PYDOCSTYLE=python -m pydocstyle
DOC_SRC=${PYDOCSTYLE} ${SRC}
DOC_TEST=${PYDOCSTYLE} ${TEST}
doc:
${DOC_SRC}
doctest:
${DOC_TEST}
docall: doc doctest
## Testing
test:
python -m unittest discover -v
testdoc:
python -m test.test --doctests-only
## Validations
circleci-validate-config:
echo Make sure that Docker is running, or this command will fail.; \
circleci config validate
validations: circleci-validate-config
validate: validations
# SERVERS & ENVIRONMENTS
GUNICORN=gunicorn ppp_web.ppp_web:app
## Local
serve-local-flask:
python ppp_web/ppp_web.py
serve-heroku-local:
heroku local
serve-dev-network-accessible:
${GUNICORN} \
--access-logfile logs/access-logfile.log \
--error-logfile logs/error-logfile.log \
--capture-output \
--pythonpath python
gunicorn-local: serve-dev-network-accessible
## Heroku
### Pushing & Serving
push-production-heroku:
git status; \
printf "\nGit status should have reported 'nothing to commit, working tree\
clean'. Otherwise you should cancel this command, make sure changes are\
committed, and run it again.\n\n"; \
git checkout master; \
git branch -D production; \
git checkout -b production; \
git push -u trunk production --force; \
git checkout master; \
open https://dashboard.heroku.com/apps/ppp-web/activity; \
open https://circleci.com/gh/PMA-2020/workflows/ppp-web
push-staging-heroku:
git status; \
printf "\nGit status should have reported 'nothing to commit, working tree\
clean'. Otherwise you should cancel this command, make sure changes are\
committed, and run it again.\n\n"; \
git checkout develop; \
git branch -D staging; \
git checkout -b staging; \
git push -u trunk staging --force; \
git checkout develop; \
open https://dashboard.heroku.com/apps/ppp-web-staging/activity; \
open https://circleci.com/gh/PMA-2020/workflows/ppp-web
production-push-heroku: push-production-heroku
staging-push-heroku: push-staging-heroku
production: push-production-heroku
staging: push-staging-heroku
serve-production:
${GUNICORN}
serve-staging: serve-production
### SSH
production-connect-heroku:
heroku run bash --app ppp-web
staging-connect-heroku:
heroku run bash --app ppp-web-staging
### Logs
logs-heroku:
heroku logs --app ppp-web
logs-staging-heroku:
heroku logs --app ppp-web-staging
## Linode
### Notes
# (1) Use () syntax for subprocess,
# (2) leave off & to run in current terminal window.
### Pushing & Serving
SERVE=${GUNICORN} \
--access-logfile ../logs/access-logfile.log \
--error-logfile ../logs/error-logfile.log \
--capture-output \
--pythonpath ../.venv/bin
serve-production-linode:
(${SERVE} --env APP_SETTINGS=production &)
serve-staging-linode:
(${SERVE} --env APP_SETTINGS=staging &)
### SSH
production-connect-linode:
staging-connect-linode:
### Setup
ACTIVATE=source .venv/bin/activate
PIP=python -m pip install --upgrade git+https://github.com/
UPGRADE=${ACTIVATE}; ${PIP}
activate:
${ACTIVATE}
add-remotes:
git remote add trunk https://github.com/PMA-2020/ppp-web.git; \
git remote add joeflack4 https://github.com/joeflack4/ppp-web.git
## Defaults
### Pushing & Serving
serve: serve-local-flask
production-push-ci: production-push-heroku
staging-push-ci: staging-push-heroku
production-push: production-push-ci
staging-push: staging-push-ci
push-production: production-push
push-staging: staging-push
gunicorn: serve-production
serve-local: serve
serve-dev: serve-local-flask
### SSH
production-connect: production-connect-heroku
staging-connect: staging-connect-heroku
### Logs
logs: logs-heroku
logs-staging: logs-staging-heroku
### Dependency Management
# For some reason, if something has been uploaded to pip very recently, you
# need to --upgrade using --no-cache-dir.
git-hash:
git rev-parse --verify HEAD
# python -m pip install git+https://github.com/USER/REPO@BRANCH --upgrade
install-internal-dependencies:
pip install git+https://github.com/PMA-2020/pmix@master --upgrade; \
pip install git+https://github.com/PMA-2020/ppp@master --upgrade
install-latest-internal-dependencies:
pip install git+https://github.com/PMA-2020/pmix@develop --upgrade; \
pip install git+https://github.com/PMA-2020/ppp@develop --upgrade
install:
make install-latest-internal-dependencies; \
pip install -r requirements-unlocked.txt --no-cache-dir; \
pip freeze > requirements.txt
# make upgrade-once
#upgrade-once:
# pip install -r requirements-unlocked.txt --no-cache-dir --upgrade; \
# pip freeze > requirements.txt
upgrade:
make install-latest-internal-dependencies; \
pip freeze > requirements.txt
# make upgrade-once; \
# make upgrade-once
uninstall:
workon ppp-web; \
bash -c "pip uninstall -y -r <(pip freeze)"
reinstall:
make uninstall; \
make install; \
# make upgrade
install-latest: install
install-stable:
make install-internal-dependencies; \
pip install -r requirements-unlocked.txt --no-cache-dir; \
pip freeze > requirements.txt
upgrade-latest: install-latest-internal-dependencies
upgrade-stable: install-internal-dependencies