-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
140 lines (111 loc) · 4.59 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
.PHONY: clean-pyc clean-build docs clean dist upload-pypi
help:
@echo "clean - remove all build, test, coverage and Python artifacts"
@echo "clean-build - remove build artifacts"
@echo "clean-pyc - remove Python file artifacts"
@echo "clean-test - remove test and coverage artifacts"
@echo "-"
@echo "lint - run all checks (style, mypy, etc.)"
@echo "mypy - check types with mypy (coverage in progress)"
@echo "mypy-all - Run mypy without filters and report remaining issue count"
@echo "format - run isort and black"
@echo "isort - use isort to fix import order"
@echo "black - reformat code with black"
@echo "test - run tests quickly with the default Python"
@echo "coverage - check code coverage quickly with the default Python"
@echo "-"
@echo "install - install Raiden and runtime requirements into the active virtualenv"
@echo "install-dev - install Raiden in editable mode and development dependencies into the active virtualenv"
@echo "-"
@echo "docs - generate Sphinx HTML documentation, including API docs"
clean: clean-build clean-pyc clean-test
clean-build:
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
clean-test:
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
# CircleCI always reports 36 CPUs, force tools to use the actual number
JOBS_ARG=
ifdef CIRCLECI
JOBS_ARG=--jobs=8
endif
LINT_PATHS = raiden_common/ tools/ setup.py conftest.py
ISORT_PARAMS = --ignore-whitespace --settings-path ./ --skip-glob '*/node_modules/*' $(LINT_PATHS)
lint: ISORT_CHECK_PARAMS := --diff --check-only
lint: BLACK_CHECK_PARAMS := --check --diff
lint: format flake8 mypy pylint shellcheck check-pre-commit
mypy:
mypy raiden_common tools
mypy-all:
# Be aware, that we currently ignore all mypy errors in `raiden.tests.*` through `setup.cfg`.
# Remaining errors in tests:
mypy --config-file /dev/null raiden_common --ignore-missing-imports | grep error | wc -l
flake8:
flake8 $(JOBS_ARG) $(LINT_PATHS)
pylint:
pylint $(JOBS_ARG) $(LINT_PATHS)
isort:
isort $(JOBS_ARG) $(ISORT_PARAMS) $(ISORT_CHECK_PARAMS)
black:
black $(BLACK_CHECK_PARAMS) $(LINT_PATHS)
shellcheck:
ifeq (, $(shell command -v shellcheck 2> /dev/null))
@echo "Shellcheck isn't installed. Shell scripts won't be linted!"
else
find tools/ .circleci/ -name "*.sh" -print0 | xargs -0 shellcheck -x
shellcheck requirements/deps
endif
check-pre-commit:
python tools/pre-commit/pre-commit-check-versions.py
format: isort black
test:
pytest -n auto -v raiden_common/tests
coverage:
coverage run --source raiden -m pytest -v raiden_common/tests
coverage report -m
coverage html
docs:
rm -f docs/raiden.rst
rm -f docs/modules.rst
# sphinx-apidoc -o docs/ raiden
$(MAKE) -C docs clean
$(MAKE) -C docs html
install: check-pip-tools clean-pyc
cd requirements; pip-sync requirements.txt _raiden.txt
install-dev: check-pip-tools clean-pyc osx-detect-proper-python
# Remove extras from requirements to produce a valid constraints file.
# See: https://github.com/pypa/pip/issues/9209
@sed -e 's/\[[^]]*\]//g' requirements/requirements-dev.txt > requirements/constraints-dev.txt
@touch requirements/requirements-local.txt
cd requirements; pip-sync requirements-dev.txt _raiden-dev.txt
pip install -c requirements/constraints-dev.txt -r requirements/requirements-local.txt
@rm requirements/constraints-dev.txt
osx-detect-proper-python:
ifeq ($(shell uname -s),Darwin)
@python -c 'import time; time.clock_gettime_ns(time.CLOCK_MONOTONIC_RAW)' > /dev/null 2>&1 || (echo "Not supported python version. Read https://raiden-network.readthedocs.io/en/latest/macos_install_guide.html#macos-development-setup for details."; exit 1)
endif
GITHUB_ACCESS_TOKEN_ARG=
ifdef GITHUB_ACCESS_TOKEN
GITHUB_ACCESS_TOKEN_ARG=--build-arg GITHUB_ACCESS_TOKEN_FRAGMENT=$(GITHUB_ACCESS_TOKEN)@
endif
check-venv:
@python3 -c 'import sys; sys.exit(not (hasattr(sys, "real_prefix") or sys.base_prefix != sys.prefix))' \
|| (echo "It appears you're not working inside a venv / virtualenv\nIt's strongly recommended to install raiden into a virtual environment.\nSee the documentation for more details."; exit 1)
# Ensure pip-tools is installed
check-pip-tools: check-venv
@command -v pip-compile > /dev/null 2>&1 || (echo "pip-tools is required. Installing." && python3 -m pip install $(shell grep pip-tools== requirements/requirements-dev.txt))
dist:
python setup.py sdist
python setup.py bdist_wheel
upload-pypi: dist
@command -v twine || pip install twine
twine upload dist/*