This repository has been archived by the owner on May 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
109 lines (88 loc) · 2.53 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
PYTHON ?= python3
PIP ?= pip
# TODO: check examples with some linters (no mypy?)
SOURCES = jarpc examples setup.py
# TODO: this is hardcoded examples list, but it should be dynamic.
# the reason for this is that some examples run forever currently.
EXAMPLES = examples/response_iterator.py examples/custom_encoder.py
.PHONY: create-env
create-env:
rm -rf env
$(PYTHON) -m pip install --user virtualenv
$(PYTHON) -m venv env
source env/bin/activate
.PHONY: install
install:
$(PIP) install --upgrade pip
$(PIP) install .
$(PIP) install -r requirements/dev.txt
.PHONY: test
test: .pytest-version
pytest tests/unit -v
.PHONY: open-report
open-report: .clean-cov .pytest-version
pytest --cov=jarpc --cov-report=term-missing --cov-report=html
open file://`pwd`/htmlcov/index.html
.clean-cov:
@echo 'cleaning coverage files ...'
rm -rf .coverage coverage.xml htmlcov/
.PHONY: clean
clean: .clean-cov
rm -rf docs/_build
rm -rf build dist jarpc.egg-info
rm -rf .mypy_cache
rm -rf .pytest_cache
.PHONY: examples
examples: $(EXAMPLES)
.PHONY: $(EXAMPLES)
$(EXAMPLES):
$(PYTHON) $@
.PHONY: ci-test
ci-test: .pytest-version
pytest --cov --cov-report=xml -v
.PHONY: dist
dist: .twine-version
$(PYTHON) setup.py check -ms
$(PYTHON) setup.py sdist bdist_wheel
twine check dist/*
.PHONY: flake8
flake8: .flake8-version
flake8 $(SOURCES)
.PHONY: black
black: .black-version
black $(SOURCES)
.PHONY: black-check
black-check: .black-version
black $(SOURCES) --check
.PHONY: mypy
mypy: .mypy-version
mypy $(SOURCES)
.PHONY: isort
isort: .isort-version
isort $(SOURCES) -rc
.PHONY: .isort-check
isort-check: .isort-version
isort $(SOURCES) -rc --check-only
.PHONY: lint
lint: flake8 black-check mypy isort-check
$(PYTHON) setup.py check -ms
.%-version:
@echo
$* --version
@echo
.PHONY: help
help:
@echo 'Existing make targets:'
@echo ' black runs black'
@echo ' black-check runs black (no formatting)'
@echo ' ci-test intended for Travis. runs tests and coverage'
@echo ' clean cleans working directory'
@echo ' create-env creates a virtualenv'
@echo ' dist builds dist wheels and runs twine check'
@echo ' examples runs examples'
@echo ' install installs all pre-requisites to run tests and coverage'
@echo ' isort runs isort'
@echo ' isort-check runs isort (no formatting)'
@echo ' lint runs flake8, black, mypy, & isort (no formatting)'
@echo ' test checks coverage and opens html report'
@echo ' open-report checks code coverage of all Python files'