-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
193 lines (156 loc) · 4.37 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
.PHONY: test full-test clean setup default
PKG=$(SRC)
INSTANCE_FOLDER=$(shell \
$(VIRTUAL_ENV)/bin/python \
-c 'from flask import Flask; print Flask("myapp").instance_path')
all: test lint
install:
poetry install
yarn
#
# Environment
#
develop: setup-git
@echo "--> Installing/updating dependencies"
poetry install
# pip uninstall -y abilian-core
# pip install -q -e ../abilian-core
yarn
setup-git:
@echo "--> Configuring git and installing hooks"
git config branch.autosetuprebase always
pre-commit install --install-hooks
@echo ""
#
# testing
#
instance:
ifndef VIRTUAL_ENV
@echo "********************************************************************"
@echo "Error: not running in virtualenv."
@echo "Please activate virtualenv. (\"source /path/to/env_dir/bin/activate\")"
@echo "********************************************************************"
@exit 1;
endif
poetry install
@mkdir -pv "$(INSTANCE_FOLDER)"
@cp -v "etc/config_dev.py" "$(INSTANCE_FOLDER)/config.py"
@cp -v "etc/logging-dev.yml" "$(INSTANCE_FOLDER)/logging.yml"
@sed -i -e 's#INSTANCE_FOLDER#$(INSTANCE_FOLDER)#' "$(INSTANCE_FOLDER)/config.py"
@echo "********************************************************************************"
@echo "Setup complete!"
@echo "config is here: $(INSTANCE_FOLDER)/config.py"
@echo "You may edit it before first run, in particular SQLALCHEMY_DATABASE_URI"
@echo "Default database is sqlite file based: $(INSTANCE_FOLDER)/data.db"
@echo
@echo "you may now run:"
@echo "python manage.py initdb"
@echo "python manage.py run"
@echo "********************************************************************************"
#
# testing
#
test:
pytest -n auto --ff -x --tb=short src tests
test-with-coverage:
pytest --tb=short --durations 10 \
--cov $(PKG) \
--cov-config etc/coverage.rc \
--cov-report term-missing src tests
test-long:
RUN_SLOW_TESTS=True pytest -x src tests
vagrant-tests:
vagrant up
vagrant ssh -c /vagrant/deploy/vagrant_test.sh
# We could also do this:
#vagrant ssh -c 'cp -a /vagrant src && cd src && tox'
#
# Linting
#
lint: lint-js lint-py lint-less lint-doc lint-licenses
lint-js:
@echo "--> Linting JavaScript files"
yarn run eslint src/abilian/sbe/static/js
lint-less:
@echo "--> Linting Less files"
@echo "FIXME"
# yarn run stylelint abilian/sbe/static/less/**/*.less
lint-py:
@echo "--> Linting Python files"
@make lint-flake8
# @make lint-mypy
lint-flake8:
flake8 src tests
lint-mypy:
mypy src tests
lint-doc:
@echo "--> Linting .rst files"
rst-lint *.rst
lint-travis:
@echo "--> Linting .travis.yml"
travis lint --no-interactive
lint-licenses:
liccheck -s etc/liccheck.ini -r etc/requirements.txt
#
# Formatting
#
format: format-py format-js format-less
format-py:
black -t py38 src demo tests *.py
isort src demo tests *.py
format-js:
yarn run prettier --write src/abilian/sbe/static/js
format-less:
yarn run prettier --write --tab-width 2 src/abilian/sbe/static/less/
#
# running
#
run:
python manage.py runserver
run-uwsgi:
uwsgi --http 127.0.0.1:8080 --need-app --disable-logging \
--wsgi-file wsgi.py --processes 1 --threads 4
#
# Everything else
#
boot:
flask config init
flask initdb
flask createadmin admin@example.com admin
clean:
find . -name "*.pyc" -delete
find . -name .DS_Store -delete
find . -name __pycache__ -delete
find . -type d -empty -delete
rm -rf .mypy_cache .cache .eggs .pytest_cache .pyre
rm -rf instance/cache instance/tmp instance/webassets instance/whoosh
rm -f migration.log yarn-error.log
rm -rf build dist
rm -rf data tests/data tests/integration/data
rm -rf tmp tests/tmp tests/integration/tmp
rm -rf cache tests/cache tests/integration/cache
rm -rf *.egg-info *.egg .coverage
rm -rf whoosh tests/whoosh tests/integration/whoosh
rm -rf doc/_build
rm -rf static/gen static/.webassets-cache
rm -rf htmlcov ghostdriver.log coverage.xml junit*.xml
rm -rf tests.functional.test/
rm -rf pip-wheel-metadata/
tidy: clean delete-cache
rm -rf instance/data
rm -rf .tox .nox
# remove template cache
delete-cache:
@echo "--> Removing template cache"
rm -rf ./instance/webassets/compiled/*
rm -rf ./instance/webassets/cache/*
update-pot:
python setup.py extract_messages update_catalog compile_catalog
publish: clean
git push --tags
poetry build
twine upload dist/*
update-deps:
pip install -U pip setuptools wheel
poetry update
poetry export -o etc/requirements.txt