-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (122 loc) · 3.48 KB
/
Makefile
File metadata and controls
148 lines (122 loc) · 3.48 KB
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
.ONESHELL:
ENV_PREFIX=$(shell python -c "if __import__('pathlib').Path('.venv/bin/pip').exists(): print('.venv/bin/')")
.PHONY: help
help: ## Show the help.
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@fgrep "##" Makefile | fgrep -v fgrep
.PHONY: show
show: ## Show the current environment.
@echo "Current environment:"
@echo "Running using $(ENV_PREFIX)"
@$(ENV_PREFIX)python -V
@$(ENV_PREFIX)python -m site
.PHONY: install
install: ## Install the project in dev mode.
@echo "Don't forget to run 'make virtualenv' if you got errors."
$(ENV_PREFIX)pip install -e .[test]
.PHONY: remove
remove: ## Remove the project.
$(ENV_PREFIX)pip uninstall -y brel
.PHONY: fmt
fmt: ## Format code using black & isort.
$(ENV_PREFIX)black brel/
$(ENV_PREFIX)black tests/
.PHONY: black-src
black-src:
$(ENV_PREFIX)black --check brel/
.PHONY: black-test
black-test:
$(ENV_PREFIX)black --check tests/
.PHONY: black
black: ## Run pep8, black, mypy linters.
make black-src
make black-test
.PHONY: mypy-src
mypy-src:
$(ENV_PREFIX)mypy --ignore-missing-imports brel/
.PHONY: mypy-test
mypy-test:
$(ENV_PREFIX)mypy --ignore-missing-imports tests/
.PHONY: mypy
mypy:
make mypy-src
make mypy-test
.PHONY: lint-src
lint-src:
make black-src
make mypy-src
.PHONY: lint-test
lint-test:
make black-test
make mypy-test
.PHONY: lint
lint:
make lint-src
make lint-test
.PHONY: test
test: ## Run tests.
$(ENV_PREFIX)pytest -v --cov=brel -l --tb=short
$(ENV_PREFIX)coverage xml
$(ENV_PREFIX)coverage html
.PHONY: test-ci
test-ci:
$(ENV_PREFIX)pytest --cov=brel --tb=line --disable-warnings --maxfail=1
.PHONY: ci
ci:
make install
make lint
make test-ci
make remove
.PHONY: watch
watch: ## Run tests on every change.
ls **/**.py | entr $(ENV_PREFIX)pytest -s -vvv -l --tb=long --maxfail=1 tests/
.PHONY: clean
clean: ## Clean unused files.
@find ./ -name '*.pyc' -exec rm -f {} \;
@find ./ -name '__pycache__' -exec rm -rf {} \;
@find ./ -name 'Thumbs.db' -exec rm -f {} \;
@find ./ -name '*~' -exec rm -f {} \;
@rm -rf .cache
@rm -rf .pytest_cache
@rm -rf .mypy_cache
@rm -rf build
@rm -rf dist
@rm -rf *.egg-info
@rm -rf htmlcov
@rm -rf .tox/
@rm -rf docs/_build
.PHONY: virtualenv
virtualenv: ## Create a virtual environment.
@echo "creating virtualenv ..."
@rm -rf .venv
@python3 -m venv .venv
@./.venv/bin/pip install -U pip
@./.venv/bin/pip install -e .[test]
@echo
@echo "!!! Please run 'source .venv/bin/activate' to enable the environment !!!"
.PHONY: release
release: ## Create a new tag for release.
@echo "WARNING: This operation will create s version tag and push to github"
@read -p "Version? (provide the next x.y.z semver) : " TAG
@echo "$${TAG}" > brel/VERSION
@$(ENV_PREFIX)gitchangelog > HISTORY.md
@git add brel/VERSION HISTORY.md
@git commit -m "release: version $${TAG} 🚀"
@echo "creating git tag : $${TAG}"
@git tag $${TAG}
@git push -u origin HEAD --tags
@echo "Github Actions will detect the new tag and release the new version."
.PHONY: docs
docs: ## Build the documentation.
@echo "building documentation ..."
@$(ENV_PREFIX)pydoc-markdown
@$(ENV_PREFIX)mkdocs build -f docs/mkdocs.yml -d ../site
.PHONY: docs-deploy
docs-deploy: ## Serve the documentation.
make docs
@$(ENV_PREFIX)mkdocs gh-deploy -f docs/mkdocs.yml -d ../site
.PHONY: init
init: ## Initialize the project based on an application template.
@./.github/init.sh