-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
156 lines (108 loc) · 3.17 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
# PN - Project Name
PN := airflow_declarative
# PN - Project Version
PV := `python setup.py -q --version`
PYTHON_VENV := python3
PYTHON := python
SHELL := /bin/sh
LINT_TARGET := setup.py src/ tests/
SPHINXOPTS ?= -n -W
.PHONY: all
all: help
.PHONY: check
# target: check - Run all checks: linters and tests (with coverage)
check: lint test check-docs
@${PYTHON} setup.py check
.PHONY: check-docs
# target: check-docs - Run Sphinx but don't actually generate the docs
check-docs:
@# Doesn't generate any output but prints out errors and warnings.
@sphinx-build -M dummy src/docs build/docs $(SPHINXOPTS)
.PHONY: clean
# target: clean - Remove intermediate and generated files
clean:
@${PYTHON} setup.py clean
@find . -type f -name '*.py[co]' -delete
@find . -type d -name '__pycache__' -delete
@rm -rf {build,htmlcov,cover,coverage,dist,.coverage,.hypothesis}
@rm -rf src/*.egg-info
@rm -f VERSION
.PHONY: develop
# target: develop - Install package in editable mode with `develop` extras
develop:
@${PYTHON} -m pip install --upgrade pip setuptools wheel
@${PYTHON} -m pip install --upgrade 'apache-airflow<1.11,>=1.10'
@${PYTHON} -m pip install -e '.[develop]'
.PHONY: dist
# target: dist - Build all artifacts
dist: dist-sdist dist-wheel
.PHONY: dist-sdist
# target: dist-sdist - Build sdist artifact
dist-sdist:
@${PYTHON} setup.py sdist
.PHONY: dist-wheel
# target: dist-wheel - Build wheel artifact
dist-wheel:
@${PYTHON} setup.py bdist_wheel
.PHONY: docs
# target: docs - Build Sphinx docs
docs:
@sphinx-build -M html src/docs build/docs $(SPHINXOPTS)
.PHONY: format
# target: format - Format the code according to the coding styles
format: format-black format-isort
.PHONY: format-black
format-black:
@black ${LINT_TARGET}
.PHONY: format-isort
format-isort:
@isort -rc ${LINT_TARGET}
.PHONY: help
# target: help - Print this help
help:
@egrep "^# target: " Makefile \
| sed -e 's/^# target: //g' \
| sort -h \
| awk '{printf(" %-16s", $$1); $$1=$$2=""; print "-" $$0}'
.PHONY: install
# target: install - Install the project
install:
@pip install .
.PHONY: lint
# target: lint - Check source code with linters
lint: lint-isort lint-black lint-flake8 lint-pylint
.PHONY: lint-black
lint-black:
@${PYTHON} -m black --check --diff ${LINT_TARGET}
.PHONY: lint-flake8
lint-flake8:
@${PYTHON} -m flake8 --statistics ${LINT_TARGET}
.PHONY: lint-isort
lint-isort:
@${PYTHON} -m isort.main -df -c -rc ${LINT_TARGET}
.PHONY: lint-pylint
lint-pylint:
@${PYTHON} -m pylint --rcfile=.pylintrc --errors-only ${LINT_TARGET}
.PHONY: report-coverage
# target: report-coverage - Print coverage report
report-coverage:
@${PYTHON} -m coverage report
.PHONY: report-pylint
# target: report-pylint - Generate pylint report
report-pylint:
@${PYTHON} -m pylint ${LINT_TARGET}
.PHONY: test
# target: test - Run tests with coverage
test:
@${PYTHON} -m coverage run -m py.test
@${PYTHON} -m coverage report
# `venv` target is intentionally not PHONY.
# target: venv - Creates virtual environment
venv:
@${PYTHON_VENV} -m venv venv
.PHONY: version
# target: version - Generate and print project version in PEP-440 format
version: VERSION
@cat VERSION
VERSION:
@echo ${PV} > $@