From 586b73c80374abeb04a7bd18d0840ebce58fb78f Mon Sep 17 00:00:00 2001 From: Dave Gallant Date: Tue, 17 Dec 2019 23:35:15 -0500 Subject: [PATCH] Enhance Makefile by changing some Make defaults (#54) --- .gitignore | 2 ++ Makefile | 66 ++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 70abfab..ac8e57b 100644 --- a/.gitignore +++ b/.gitignore @@ -88,3 +88,5 @@ venv.bak/ .mypy_cache/ .dmypy.json dmypy.json + +tmp/ diff --git a/Makefile b/Makefile index 822562e..fe5e725 100644 --- a/Makefile +++ b/Makefile @@ -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