-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
134 lines (110 loc) · 4.42 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
PROJECT_NAME := $(shell python setup.py --name)
PROJECT_VERSION := $(shell python setup.py --version)
BOLD := \033[1m
RESET := \033[0m
default: help
.PHONY : help
help: ## Show this help
@echo "$(BOLD)Isshub Makefile$(RESET)"
@echo "Please use 'make $(BOLD)target$(RESET)' where $(BOLD)target$(RESET) is one of:"
@grep -h ':\s\+##' Makefile | column -tn -s# | awk -F ":" '{ print " $(BOLD)" $$1 "$(RESET)" $$2 }'
.PHONY: install
install: ## Install the project in the current environment, with its dependencies
@echo "$(BOLD)Installing $(PROJECT_NAME) $(PROJECT_VERSION)$(RESET)"
@pip install .
.PHONY: dev
dev: ## Install the project in the current environment, with its dependencies, including the ones needed in a development environment
@echo "$(BOLD)Installing (or upgrading) $(PROJECT_NAME) $(PROJECT_VERSION) in dev mode (with all dependencies)$(RESET)"
@pip install --upgrade pip setuptools
@pip install --upgrade -e .[dev,tests,lint,docs]
@$(MAKE) full-clean
.PHONY: dist
dist: ## Build the package
dist: clean
@echo "$(BOLD)Building package$(RESET)"
@python setup.py sdist bdist_wheel
.PHONY: clean
clean: ## Clean python build related directories and files
@echo "$(BOLD)Cleaning$(RESET)"
@rm -rf build dist $(PROJECT_NAME).egg-info
.PHONY: full-clean
full-clean: ## Like "clean" but with clean-doc and will clean some other generated directories or files
full-clean: clean
@echo "$(BOLD)Full cleaning$(RESET)"
find ./ -type d \( -name '__pycache__' -or -name '.pytest_cache' -or -name '.mypy_cache' \) -print0 | xargs -tr0 rm -r
-$(MAKE) clean-doc
.PHONY: doc docs
doc / docs: ## Build the documentation
docs: doc # we allow "doc" and "docs"
doc: clean-doc
@echo "$(BOLD)Building documentation$(RESET)"
@cd docs && $(MAKE) html
.PHONY: doc-strict docs-strict
doc-strict / docs-strict: ## Build the documentation but fail if a warning
docs-strict: doc-strict # we allow "doc-strict" and "docs-strict"
doc-strict: clean-doc
@echo "$(BOLD)Building documentation (strict)$(RESET)"
@cd docs && sphinx-build -W -b html . _build
.PHONY: clean-doc clean-docs
clean-doc / clean-docs: ## Clean the documentation directories
clean-docs: clean-doc # we allow "clean-doc" and "clean-docs"
clean-doc:
@echo "$(BOLD)Cleaning documentation directories$(RESET)"
@rm -rf docs/source docs/git docs/bdd
@cd docs && $(MAKE) clean
.PHONY: tests test
test / tests: ## Run tests for the isshub project.
test: tests # we allow "test" and "tests"
tests:
@echo "$(BOLD)Running tests$(RESET)"
@## we ignore error 5 from pytest meaning there is no test to run
@pytest || ( ERR=$$?; if [ $${ERR} -eq 5 ]; then (exit 0); else (exit $${ERR}); fi )
.PHONY: tests-nocov
test-nocov / tests-nocov: ## Run tests for the isshub project without coverage.
test-nocov: tests-nocov # we allow "test-nocov" and "tests-nocov"
tests-nocov:
@echo "$(BOLD)Running tests (without coverage)$(RESET)"
@## we ignore error 5 from pytest meaning there is no test to run
@pytest --no-cov || ( ERR=$$?; if [ $${ERR} -eq 5 ]; then (exit 0); else (exit $${ERR}); fi )
.PHONY: lint
lint: ## Run all linters (check-isort, check-black, mypy, flake8, pylint)
lint: check-isort check-black flake8 pylint mypy
.PHONY: check checks
check / checks: ## Run all checkers (lint, tests)
check: checks
checks: lint tests check-commit
.PHONY: mypy
mypy: ## Run the mypy tool
@echo "$(BOLD)Running mypy$(RESET)"
@mypy .
.PHONY: check-isort
check-isort: ## Run the isort tool in check mode only (won't modify files)
@echo "$(BOLD)Checking isort(RESET)"
@isort . --check-only 2>&1
.PHONY: check-black
check-black: ## Run the black tool in check mode only (won't modify files)
@echo "$(BOLD)Checking black$(RESET)"
@black --target-version py38 --check . 2>&1
.PHONY: flake8
flake8: ## Run the flake8 tool
@echo "$(BOLD)Running flake8$(RESET)"
@flake8 --format=abspath
.PHONY: pylint
pylint: ## Run the pylint tool
@echo "$(BOLD)Running pylint$(RESET)"
@pylint isshub
.PHONY: pretty
pretty: ## Run all code beautifiers (isort, black)
pretty: isort black
.PHONY: isort
isort: ## Run the isort tool and update files that need to
@echo "$(BOLD)Running isort$(RESET)"
@isort . --atomic
.PHONY: black
black: ## Run the black tool and update files that need to
@echo "$(BOLD)Running black$(RESET)"
@black --target-version py38 .
.PHONY: check-commit
check-commit: ## Check the validaity of the last commit message
@echo "$(BOLD)Checking last commit message$(RESET)"
@ci/check_commit_message.py -vl