Enhance Makefile by changing some Make defaults (#54)

This commit is contained in:
Dave Gallant
2019-12-17 23:35:15 -05:00
committed by GitHub
parent 2e507c1bfb
commit 586b73c803
2 changed files with 46 additions and 22 deletions

2
.gitignore vendored
View File

@@ -88,3 +88,5 @@ venv.bak/
.mypy_cache/
.dmypy.json
dmypy.json
tmp/

View File

@@ -1,35 +1,57 @@
SRC:=rfd
SRC := rfd
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
.PHONY: build
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >
## build: Build a tar.gz of the python package
build:
rm -rf dist/
python setup.py sdist
.PHONY: push_test
push_test:
twine upload -r testpypi dist/*.tar.gz
.PHONY: push_prod
push_prod:
twine upload dist/*.tar.gz
> rm -rf dist/
> python setup.py sdist
.PHONY: build
## precommit: Run all pre-commit hooks
precommit:
> pre-commit run \
--all-files \
--show-diff-on-failure
.PHONY: precommit
precommit: ## Run pre-commit
pre-commit run \
--all-files \
--show-diff-on-failure
.PHONY: lint
## lint: Run static analysis on the code
lint:
pylint $(SRC)
> pylint $(SRC)
.PHONY: lint
## test: Run all unit tests
test: tmp/.tests-passed.sentinel
.PHONY: test
test:
pytest -v
.PHONY: pr
# Tests - re-ran if any file under src has been changed since tmp/.tests-passed.sentinel was last touched
tmp/.tests-passed.sentinel: $(shell find ${SRC} -type f)
> mkdir -p $(@D)
> pytest -v
> touch $@
## pr: Run pre-commit, lint and test
pr: precommit lint test
.PHONY: pr
.PHONY: ci
ci: lint test
.PHONY: ci
## help: Print this help message
help:
> @echo "Usage:"
> @echo
> @sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' | sort
> @echo
.PHONY: help