-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Makefile to use default target rule, improve messaging and P…
…HONY targets (#57)
- Loading branch information
Showing
1 changed file
with
35 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,58 @@ | ||
.PHONY: clean-pyc | ||
.DEFAULT_GOAL := help | ||
|
||
PYTHON ?= $(shell which python) | ||
|
||
|
||
default: test | ||
.PHONY: help | ||
help: ## Prints help for available target rule | ||
$(info Available target rules:) | ||
@echo | ||
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | ||
|
||
|
||
.PHONY: clean-pyc | ||
clean-pyc: | ||
$(info Cleaning Python files..) | ||
@find . -iname '*.py[co]' -delete | ||
@find . -iname '__pycache__' -delete | ||
@find . -iname '.coverage' -delete | ||
@rm -rf htmlcov/ | ||
|
||
|
||
.PHONY: clean-dist | ||
clean-dist: | ||
$(info Cleaning Python distribution files..) | ||
@rm -rf dist/ | ||
@rm -rf build/ | ||
@rm -rf *.egg-info | ||
|
||
clean: clean-pyc clean-dist | ||
|
||
test: | ||
.PHONY: clean | ||
clean: clean-pyc clean-dist ## Cleans project building and caching files | ||
|
||
|
||
.PHONY: test | ||
test: ## Runs project tests using Pytest | ||
$(info Running project tests..) | ||
py.test -vvv --cov=simple_rest_client tests | ||
|
||
|
||
.PHONY: dist | ||
dist: clean | ||
python setup.py sdist | ||
python setup.py bdist_wheel | ||
$(info Building Python distribution..) | ||
$(PYTHON) setup.py sdist | ||
$(PYTHON) setup.py bdist_wheel | ||
|
||
release: dist | ||
|
||
.PHONY: release | ||
release: dist ## Generates a new project release | ||
$(info Generating a new project release..) | ||
git tag `python setup.py -q version` | ||
git push origin `python setup.py -q version` | ||
twine upload dist/* | ||
|
||
lint: | ||
|
||
.PHONY: lint | ||
lint: ## Runs Python lint on the source code | ||
$(info Running lint against project..) | ||
SKIP=no-commit-to-branch pre-commit run -a -v |