-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
154 lines (129 loc) · 5.45 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
comma := ,
.PHONY: help
help = help::; @echo $$$$(tput bold)$(strip $(1)):$$$$(tput sgr0) $(strip $(2))
$(call help,make help,print this help message)
.PHONY: services
$(call help,make services,start the services that the app needs)
services: args?=up -d --wait
services: python
@docker compose $(args)
.PHONY: db
$(call help,make db,initialize the DB and upgrade it to the latest migration)
db: args?=upgrade head
db: python
@tox -qe dev --run-command 'python3 -m lms.scripts.init_db --create --stamp'
@tox -qe dev --run-command 'alembic $(args)'
.PHONY: devdata
$(call help,make devdata,load development data and environment variables)
devdata: python
@tox -qe dev --run-command 'python3 -m lms.scripts.init_db --create --stamp'
@tox -qe dev --run-command 'python bin/make_devdata'
.PHONY: dev
$(call help,make dev,run the whole app \(all workers\))
dev: python
@pyenv exec tox -qe dev
.PHONY: web
$(call help,make web,run just a single web worker process)
web: python
@pyenv exec tox -qe dev --run-command 'gunicorn --bind :8001 --workers 1 --reload --timeout 0 --paste conf/development.ini'
.PHONY: shell
$(call help,make shell,"launch a Python shell in this project's virtualenv")
shell: python
@pyenv exec tox -qe dev --run-command 'pshell conf/development.ini'
.PHONY: sql
$(call help,make sql,"Connect to the dev database with a psql shell")
sql: python
@docker compose exec postgres psql --pset expanded=auto -U postgres
.PHONY: lint
$(call help,make lint,"lint the code and print any warnings")
lint: python
@pyenv exec tox -qe lint
.PHONY: typecheck
$(call help,make typecheck,"type check the code and print any warnings")
typecheck: python
@pyenv exec tox -qe typecheck
.PHONY: format
$(call help,make format,"format the code")
format: python
@pyenv exec tox -qe format
.PHONY: checkformatting
$(call help,make checkformatting,"crash if the code isn't correctly formatted")
checkformatting: python
@pyenv exec tox -qe checkformatting
.PHONY: test
$(call help,make test,"run the unit tests")
test: python
@pyenv exec tox -qe tests
.PHONY: coverage
$(call help,make coverage,"run the tests and print the coverage report")
coverage: python
@pyenv exec tox -qe 'tests,coverage'
.PHONY: functests
$(call help,make functests,"run the functional tests")
functests: python
@pyenv exec tox -qe functests
.PHONY: sure
$(call help,make sure,"make sure that the formatting$(comma) linting and tests all pass")
sure: python
sure:
@pyenv exec tox --parallel -qe 'checkformatting,lint,typecheck,tests,coverage,functests'
# Tell make how to compile requirements/*.txt files.
#
# `touch` is used to pre-create an empty requirements/%.txt file if none
# exists, otherwise tox crashes.
#
# $(subst) is used because in the special case of making prod.txt we actually
# need to touch dev.txt not prod.txt and we need to run `tox -e dev ...`
# not `tox -e prod ...`
#
# $(basename $(notdir $@))) gets just the environment name from the
# requirements/%.txt filename, for example requirements/foo.txt -> foo.
requirements/%.txt: requirements/%.in python
@touch -a $(subst prod.txt,dev.txt,$@)
@tox -qe $(subst prod,dev,$(basename $(notdir $@))) --run-command 'pip --quiet --disable-pip-version-check install pip-tools pip-sync-faster'
@tox -qe $(subst prod,dev,$(basename $(notdir $@))) --run-command 'pip-compile --allow-unsafe --quiet $(args) $<'
# Inform make of the dependencies between our requirements files so that it
# knows what order to re-compile them in and knows to re-compile a file if a
# file that it depends on has been changed.
requirements/dev.txt: requirements/prod.txt
requirements/tests.txt: requirements/prod.txt
requirements/functests.txt: requirements/prod.txt
requirements/lint.txt: requirements/tests.txt requirements/functests.txt
requirements/typecheck.txt: requirements/prod.txt
# Add a requirements target so you can just run `make requirements` to
# re-compile *all* the requirements files at once.
#
# This needs to be able to re-create requirements/*.txt files that don't exist
# yet or that have been deleted so it can't just depend on all the
# requirements/*.txt files that exist on disk $(wildcard requirements/*.txt).
#
# Instead we generate the list of requirements/*.txt files by getting all the
# requirements/*.in files from disk ($(wildcard requirements/*.in)) and replace
# the .in's with .txt's.
.PHONY: requirements requirements/
$(call help,make requirements,"compile the requirements files")
requirements requirements/: $(foreach file,$(wildcard requirements/*.in),$(basename $(file)).txt)
.PHONY: template
$(call help,make template,"update from the latest cookiecutter template")
template: python
@pyenv exec tox -e template -- $$(if [ -n "$${template+x}" ]; then echo "--template $$template"; fi) $$(if [ -n "$${checkout+x}" ]; then echo "--checkout $$checkout"; fi) $$(if [ -n "$${directory+x}" ]; then echo "--directory $$directory"; fi)
.PHONY: docker
$(call help,make docker,"make the app's docker image")
docker:
@git archive --format=tar HEAD | docker build -t hypothesis/lms:dev -
.PHONY: docker-run
$(call help,make docker-run,"run the app's docker image")
docker-run:
@bin/make_docker_run
.PHONY: clean
$(call help,make clean,"delete temporary files etc")
clean:
@rm -rf build dist .tox .coverage coverage .eslintcache node_modules supervisord.log supervisord.pid yarn-error.log
@find . -path '*/__pycache__*' -delete
@find . -path '*.egg-info*' -delete
@rm -f tests/bdd/steps/_compiled_feature_steps.py
.PHONY: python
python:
@bin/make_python
-include lms.mk
-include frontend.mk