Skip to content

Commit

Permalink
Make Makefiles nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
matyaskuti committed Oct 20, 2023
1 parent 9771057 commit d02d19b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
29 changes: 17 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
POETRY ?= poetry
PIP ?= pip3

TESTS_DIR := tests

.PHONY: install_lint_requirements
install_lint_requirements:
poetry install --with lint
$(POETRY) install --with lint

.PHONY: lint
lint: install_lint_requirements
flake8 tests
black --check --diff tests
pylint tests
isort --check-only tests
mypy tests
flake8 $(TESTS_DIR)
black --check --diff $(TESTS_DIR)
pylint $(TESTS_DIR)
isort --check-only $(TESTS_DIR)
mypy $(TESTS_DIR)

.PHONY: install_test_requirements
install_test_requirements:
poetry install --with test
$(POETRY) install --with test

.PHONY: test
test: install_test_requirements
pytest tests
pytest $(TESTS_DIR)

.PHONY: clean
clean:
Expand All @@ -30,14 +35,14 @@ clean:

.PHONY: format
format:
black tests
isort tests
black $(TESTS_DIR)
isort $(TESTS_DIR)

.PHONY: install
install:
pip3 install .
$(PIP) install .

TARGET_DIR := .
TARGET_DIR ?= .

.PHONY: generate
generate: install
Expand Down
28 changes: 16 additions & 12 deletions {{cookiecutter.package_name}}/Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
POETRY ?= poetry

PACKAGE_NAME := {{cookiecutter.package_name}}
TESTS_DIR := tests
ALL_SOURCE := $(PACKAGE_NAME) $(TESTS_DIR)

.PHONY: install_lint_requirements
install_lint_requirements:
poetry install --with lint
$(POETRY) install --with lint

.PHONY: lint
lint: install_lint_requirements
flake8 $(PACKAGE_NAME) tests
black --check --diff $(PACKAGE_NAME) tests
pylint $(PACKAGE_NAME) tests
isort --check-only $(PACKAGE_NAME) tests
mypy --ignore-missing-imports $(PACKAGE_NAME) tests
flake8 $(ALL_SOURCE)
black --check --diff $(ALL_SOURCE)
pylint $(ALL_SOURCE)
isort --check-only $(ALL_SOURCE)
mypy --ignore-missing-imports $(ALL_SOURCE)

.PHONY: install_test_requirements
install_test_requirements:
poetry install --with test
$(POETRY) install --with test

.PHONY: test
test: install_test_requirements
pytest \
--cov=$(PACKAGE_NAME) \
--cov=tests \
--cov=$(TESTS_DIR) \
--cov-report=term-missing:skip-covered \
tests
$(TESTS_DIR)

.PHONY: clean
clean:
Expand All @@ -38,9 +42,9 @@ clean:

.PHONY: build
build:
poetry build
$(POETRY) build

.PHONY: format
format:
black $(PACKAGE_NAME) tests
isort $(PACKAGE_NAME) tests
black $(ALL_SOURCE)
isort $(ALL_SOURCE)

0 comments on commit d02d19b

Please sign in to comment.