forked from curveresearch/curvesim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
134 lines (118 loc) Β· 3.46 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
.DEFAULT_GOAL := help
# ANSI escape codes
BOLD := \033[1m
RESET := \033[0m
REVERSE := \033[7m
RED := \033[0;31m
.PHONY: help
help:
@echo ""
@echo "venv create python virtual env"
@echo "requirements generate requirements file from base requirements"
@echo ""
@echo "changelog_entry create changelog entry"
@echo "changelog_update update changelog from recent entries"
@echo ""
@echo "hooks install Git hooks"
@echo ""
@echo "lint linting checks through flake8 and pylint"
@echo "flake8 lint using flake8"
@echo "pylint lint using pylint"
@echo "format formatting checks through black and isort"
@echo "black format using black and isort"
@echo ""
@echo "release upload new pypi release using twine"
@echo ""
@echo "coverage run tests generating coverage data"
@echo "coverage_html spinup HTML view of coverage report"
@echo ""
VENV_PATH := $(PWD)/env
.PHONY: venv
venv:
python3 -m venv $(VENV_PATH)
$(VENV_PATH)/bin/pip install -r requirements.txt
.PHONY: requirements
requirements:
@echo "Generating requirements.txt from core and dev dependencies ..."
python3 -m venv temp_venv
temp_venv/bin/pip install --upgrade pip
temp_venv/bin/pip install -r requirements_base.txt -r requirements_dev.txt
echo '# generated via "make requirements"' > requirements.txt
temp_venv/bin/pip freeze -r requirements_base.txt -r requirements_dev.txt >> requirements.txt
rm -rf temp_venv
@echo "requirements.txt has been updated π"
.PHONY: hooks
hooks:
@echo "Installing git hooks..."
cp ./git_hooks/{commit-msg,pre-commit*} .git/hooks/
chmod +x .git/hooks/*
@echo "Hooks installed"
.PHONY: changelog_entry
changelog_entry:
scriv create
.PHONY: changelog_update
changelog_update:
@VERSION=`python -c "from curvesim import __version__; print(__version__)"`; \
scriv collect --version=$${VERSION}
# deprecated now that we have the pypi workflow
.PHONY: release
release:
pip install build twine
python -m build
twine upload dist/*
rm -fr dist curvesim.egg-info
# Use this for formatting checks. Will not modify files.
.PHONY: format
format:
@echo ""
@echo "$(REVERSE)Running$(RESET) $(BOLD)black$(RESET)..."
@black --version
@black . --check
@echo "$(REVERSE)Running$(RESET) $(BOLD)isort$(RESET)..."
@isort --version-number
@isort curvesim --check
@echo ""
@echo "Formatting checks passed π"
# Use this to change files to proper format.
.PHONY: black
black:
@echo "$(REVERSE)Running$(RESET) $(BOLD)black$(RESET)..."
@black --version
@black .
@echo "$(REVERSE)Running$(RESET) $(BOLD)isort$(RESET)..."
@isort --version-number
@isort curvesim
.PHONY: lint
lint:
@echo ""
@make flake8
@echo ""
@make pylint
@echo ""
@echo "Linting checks passed π"
.PHONY: flake8
flake8:
@echo "$(REVERSE)Running$(RESET) $(BOLD)flake8$(RESET)..."
@flake8 --version
@if ! flake8 .; then \
echo "$(BOLD)flake8$(RESET): $(RED)FAILED$(RESET) checks" ;\
exit 1 ;\
fi
@echo "flake8 passed π"
.PHONY: pylint
pylint:
@echo "$(REVERSE)Running$(RESET) $(BOLD)pylint$(RESET)..."
@echo ""
@./check_pylint_score.py curvesim
@echo ""
@echo "pylint passed βοΈ"
.PHONY: coverage
coverage:
pytest --cov -n auto --cov-report=
coverage run -m test.simple_ci --generate
coverage combine --append
coverage report
.PHONY: coverage_html
coverage_html:
coverage html
python -m http.server --directory htmlcov