|
| 1 | +include openfisca_make/build.mk |
| 2 | +include openfisca_make/install.mk |
| 3 | +include openfisca_make/lint.mk |
| 4 | +include openfisca_make/test.mk |
| 5 | +include openfisca_make/serve.mk |
| 6 | + |
1 | 7 | help = sed -n "/^$1/ { x ; p ; } ; s/\#\#/[⚙]/ ; s/\./.../ ; x" ${MAKEFILE_LIST} |
2 | | -repo = https://github.com/openfisca/openfisca-doc |
3 | | -branch = $(shell git branch --show-current) |
4 | | -python_packages = $(shell python -c "import sysconfig; print(sysconfig.get_paths()[\"purelib\"])") |
| 8 | + |
| 9 | +.DEFAULT_GOAL := all |
5 | 10 |
|
6 | 11 | ## Same as `make test`. |
7 | 12 | all: test |
8 | | - |
9 | | -## Install project dependencies. |
10 | | -install: |
11 | | - @$(call help,$@:) |
12 | | - @pip install --upgrade pip twine wheel |
13 | | - @pip install --editable .[dev] --upgrade --use-deprecated=legacy-resolver |
14 | | - |
15 | | -## Install openfisca-core for deployment and publishing. |
16 | | -build: setup.py |
17 | | - @## This allows us to be sure tests are run against the packaged version |
18 | | - @## of openfisca-core, the same we put in the hands of users and reusers. |
19 | | - @$(call help,$@:) |
20 | | - @python $? bdist_wheel |
21 | | - @find dist -name "*.whl" -exec pip install --force-reinstall {}[dev] \; |
22 | | - |
23 | | -## Uninstall project dependencies. |
24 | | -uninstall: |
25 | | - @$(call help,$@:) |
26 | | - @pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y |
27 | | - |
28 | | -## Delete builds and compiled python files. |
29 | | -clean: \ |
30 | | - $(shell ls -d * | grep "build\|dist") \ |
31 | | - $(shell find . -name "*.pyc") |
32 | | - @$(call help,$@:) |
33 | | - @rm -rf $? |
34 | | - |
35 | | -## Compile python files to check for syntax errors. |
36 | | -check-syntax-errors: . |
37 | | - @$(call help,$@:) |
38 | | - @python -m compileall -q $? |
39 | | - |
40 | | -## Run linters to check for syntax and style errors. |
41 | | -check-style: $(shell git ls-files "*.py") |
42 | | - @$(call help,$@:) |
43 | | - @flake8 $? |
44 | | - |
45 | | -## Run code formatters to correct style errors. |
46 | | -format-style: $(shell git ls-files "*.py") |
47 | | - @$(call help,$@:) |
48 | | - @autopep8 $? |
49 | | - |
50 | | -## Run static type checkers for type errors. |
51 | | -check-types: openfisca_core openfisca_web_api |
52 | | - @$(call help,$@:) |
53 | | - @mypy $? |
54 | | - |
55 | | -## Run openfisca-core & country/extension template tests. |
56 | | -test: clean check-syntax-errors check-style check-types |
57 | | - @## Usage: |
58 | | - @## |
59 | | - @## make test [pytest_args="--ARG"] [openfisca_args="--ARG"] |
60 | | - @## |
61 | | - @## Examples: |
62 | | - @## |
63 | | - @## make test |
64 | | - @## make test pytest_args="--exitfirst" |
65 | | - @## make test openfisca_args="--performance" |
66 | | - @## make test pytest_args="--exitfirst" openfisca_args="--performance" |
67 | | - @## |
68 | | - @$(call help,$@:) |
69 | | - @${MAKE} test-core |
70 | | - @${MAKE} test-country |
71 | | - @${MAKE} test-extension |
72 | | - |
73 | | -# Run openfisca-core tests. |
74 | | -test-core: $(shell git ls-files "tests/*.py") |
75 | | - @$(call help,$@:) |
76 | | - @PYTEST_ADDOPTS="${PYTEST_ADDOPTS} --cov=openfisca_core ${pytest_args}" openfisca test $? ${openfisca_args} |
77 | | - |
78 | | -# Run country-template tests. |
79 | | -test-country: ${python_packages}/openfisca_country_template/tests |
80 | | - @$(call help,$@:) |
81 | | - @PYTEST_ADDOPTS="${PYTEST_ADDOPTS} ${pytest_args}" openfisca test $? --country-package openfisca_country_template ${openfisca_args} |
82 | | - |
83 | | -# Run extension-template tests. |
84 | | -test-extension: ${python_packages}/openfisca_extension_template/tests |
85 | | - @$(call help,$@:) |
86 | | - @PYTEST_ADDOPTS="${PYTEST_ADDOPTS} ${pytest_args}" openfisca test $? --country-package openfisca_country_template --extensions openfisca_extension_template ${openfisca_args} |
87 | | - |
88 | | -## Check that the current changes do not break the doc. |
89 | | -test-doc: |
90 | | - @## Usage: |
91 | | - @## |
92 | | - @## make test-doc [branch=BRANCH] |
93 | | - @## |
94 | | - @## Examples: |
95 | | - @## |
96 | | - @## # Will check the current branch in openfisca-doc. |
97 | | - @## make test-doc |
98 | | - @## |
99 | | - @## # Will check "test-doc" in openfisca-doc. |
100 | | - @## make test-doc branch=test-doc |
101 | | - @## |
102 | | - @## # Will check "master" if "asdf1234" does not exist. |
103 | | - @## make test-doc branch=asdf1234 |
104 | | - @## |
105 | | - @$(call help,$@:) |
106 | | - @${MAKE} test-doc-checkout |
107 | | - @${MAKE} test-doc-install |
108 | | - @${MAKE} test-doc-build |
109 | | - |
110 | | -## Update the local copy of the doc. |
111 | | -test-doc-checkout: |
112 | | - @$(call help,$@:) |
113 | | - @[ ! -d doc ] && git clone ${repo} doc || : |
114 | | - @cd doc && { \ |
115 | | - git reset --hard ; \ |
116 | | - git fetch --all ; \ |
117 | | - [ "$$(git branch --show-current)" != "master" ] && git checkout master || : ; \ |
118 | | - [ "${branch}" != "master" ] \ |
119 | | - && { \ |
120 | | - { \ |
121 | | - git branch -D ${branch} 2> /dev/null ; \ |
122 | | - git checkout ${branch} ; \ |
123 | | - } \ |
124 | | - && git pull --ff-only origin ${branch} \ |
125 | | - || { \ |
126 | | - >&2 echo "[!] The branch '${branch}' doesn't exist, checking out 'master' instead..." ; \ |
127 | | - git pull --ff-only origin master ; \ |
128 | | - } \ |
129 | | - } \ |
130 | | - || git pull --ff-only origin master ; \ |
131 | | - } 1> /dev/null |
132 | | - |
133 | | -## Install doc dependencies. |
134 | | -test-doc-install: |
135 | | - @$(call help,$@:) |
136 | | - @pip install --requirement doc/requirements.txt 1> /dev/null |
137 | | - @pip install --editable .[dev] --upgrade 1> /dev/null |
138 | | - |
139 | | -## Dry-build the doc. |
140 | | -test-doc-build: |
141 | | - @$(call help,$@:) |
142 | | - @sphinx-build -M dummy doc/source doc/build -n -q -W |
143 | | - |
144 | | -## Serve the openfisca Web API. |
145 | | -api: |
146 | | - @$(call help,$@:) |
147 | | - @openfisca serve \ |
148 | | - --country-package openfisca_country_template \ |
149 | | - --extensions openfisca_extension_template |
0 commit comments