Skip to content

Commit

Permalink
Refactor Makefile to use default target rule, improve messaging and P…
Browse files Browse the repository at this point in the history
…HONY targets (#57)
  • Loading branch information
pantuza committed Oct 2, 2023
1 parent 5a8fb5d commit 142c352
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions Makefile
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

0 comments on commit 142c352

Please sign in to comment.