-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
154 lines (118 loc) · 3.9 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
all: audits tests
# --- ENVIRONMENT MANAGEMENT ---
.PHONY: clean
clean:
git clean -fdX
# poetry returns a non-zero exit status if the virtualenv doesn't exist so we ignore
# errors.
-poetry env remove 3.6
-poetry env remove 3.7
-poetry env remove 3.8
-poetry env remove 3.9
.PHONY: clean _venv _venv_3.6 _venv_3.7 _venv_3.8 _venv_3.9 venvs
venvs: _venv_3.6 _venv_3.7 _venv_3.8 _venv_3.9
_venv:
poetry env use ${PYTHON_VERSION}
poetry install
_venv_3.6:
PYTHON_VERSION=3.6 $(MAKE) _venv
_venv_3.7:
PYTHON_VERSION=3.7 $(MAKE) _venv
_venv_3.8:
PYTHON_VERSION=3.8 $(MAKE) _venv
_venv_3.9:
PYTHON_VERSION=3.9 $(MAKE) _venv
# --- AUDITS ---
.PHONY: audits black flake8 isort markflow
# Runs all of our audits regardless of if any fail so we can get all relevant issues
audits:
@status=0; \
for target in black flake8 isort markflow; do \
$(MAKE) $${target}; \
status=$$(($$status + $$?)); \
echo ""; \
done; \
if [ $$status -eq 0 ]; then \
echo "All Audits Succeeded!"; \
else \
echo "Some audits failed. :("; \
fi; \
exit $$status
black: _venv_3.8
@echo Running $@ audit...
git ls-files | egrep '.*\.pyi?$$' | xargs poetry run black --check
@echo Success!
# pyi files provide type stubbing and can look weird to flake8, so we filter them out
flake8: _venv_3.8
@echo Running $@ audit...
git ls-files | egrep '.*\.py$$' | xargs poetry run flake8
@echo Success!
isort: _venv_3.8
@echo Running $@ audit...
git ls-files | egrep '.*\.pyi?$$' | xargs poetry run isort --profile=black --check
@echo Success!
markflow: _venv_3.8
@echo Running $@ audit...
git ls-files | egrep ".md$$" | grep -v "tests/" | xargs poetry run markflow --check
@echo Success!
# --- TESTS ---
.PHONY: tests tests_3.6 tests_3.7 tests_3.8 tests_3.9
tests: utests mypy ensure_deps
tests_3.6: utests_3.6 ensure_deps_3.6
tests_3.7: utests_3.7 ensure_deps_3.7
tests_3.8: utests_3.8 mypy ensure_deps_3.8
tests_3.9: utests_3.9 ensure_deps_3.9
# Ensure dependencies are properly specified
.PHONY: ensure_deps _ensure_deps ensure_deps_3.6 ensure_deps_3.7 ensure_deps_3.8 ensure_deps_3.9
ensure_deps: ensure_deps_3.6 ensure_deps_3.7 ensure_deps_3.8 ensure_deps_3.9
_ensure_deps:
# Ensure dependencies markflow needs didn't sneak into dev dependencies
poetry env use ${PYTHON_VERSION}
poetry install --no-dev
echo -e "Hello\n--" | poetry run markflow
ensure_deps_3.6:
PYTHON_VERSION=3.6 $(MAKE) _ensure_deps
ensure_deps_3.7:
PYTHON_VERSION=3.7 $(MAKE) _ensure_deps
ensure_deps_3.8:
PYTHON_VERSION=3.8 $(MAKE) _ensure_deps
ensure_deps_3.9:
PYTHON_VERSION=3.9 $(MAKE) _ensure_deps
# MyPy
.PHONY: mypy mypy_lib mypy_tests
mypy: mypy_lib mypy_tests
mypy_lib: _venv_3.8
# --implicity-reexport means that we don't have to explicitly tell mypy about our
# modules' members via a `__all__`
poetry env use 3.8
MYPYPATH=$(CURDIR)/stubs poetry run mypy --strict --implicit-reexport markflow
mypy_tests: _venv_3.8
# --implicity-reexport means that we don't have to explicitly tell mypy about our
# modules' members via a `__all__`
poetry env use 3.8
MYPYPATH=$(CURDIR)/stubs poetry run mypy --strict --implicit-reexport tests
# Unit Tests
# Bit of a misnomer since `test_files.py` is more of a system/integration test
.PHONY: utests _utests utests_3.6 utests_3.7 utests_3.8 utests_3.9
utests: utests_3.6 utests_3.7 utests_3.8 utests_3.9
_utests:
poetry env use ${PYTHON_VERSION}
cd $(CURDIR)/tests && poetry run pytest --cov=markflow --cov-report=term \
--cov-report=html --junit-xml=junit.xml
@echo For more detailed information, see $(CURDIR)/tests/htmlcov/index.html
utests_3.6: _venv_3.6
PYTHON_VERSION=3.6 $(MAKE) _utests
utests_3.7: _venv_3.7
PYTHON_VERSION=3.7 $(MAKE) _utests
utests_3.8: _venv_3.8
PYTHON_VERSION=3.8 $(MAKE) _utests
utests_3.9: _venv_3.9
PYTHON_VERSION=3.9 $(MAKE) _utests
# --- EXPORTING ---
.PHONY: package
package:
poetry build
# --- CI CONTAINER ---
.PHONY: container
container:
docker build . -t markflow_builder