-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
49 lines (38 loc) · 1.15 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
#
# Makefile
#
SRC = *.py standard_importer worldbank_wdi
default:
@echo 'Available commands:'
@echo
@echo ' make test Run all linting and unit tests'
@echo ' make watch Run all tests, watching for changes'
@echo
env: requirements.txt
@echo '==> Updating virtualenv'
test -d env || python -m venv env
env/bin/pip install -r requirements.txt
touch env
# check formatting before lint, since an autoformat might fix linting issues
test: check-formatting lint check-typing unittest
lint: env
@echo '==> Linting'
@env/bin/flake8 $(SRC)
check-formatting: env
@echo '==> Checking formatting'
@env/bin/black --check $(SRC)
# jump through some hoops because of a unusual module structure for importers
check-typing: env
@echo '==> Checking types'
@cd ..; ./importers/env/bin/mypy \
--cache-dir=importers/.mypy_cache \
--config-file=importers/.mypy.ini \
$$(for part in $(SRC); do echo importers/$$part; done)
unittest: env
@echo '==> Running unit tests'
@PYTHONPATH=. env/bin/pytest $(SRC)
format: env
@echo '==> Reformatting files'
@env/bin/black $(SRC)
watch: env
env/bin/watchmedo shell-command -c 'clear; make test' --recursive --drop .