From 5133ca0d4c99eb79a6237a3305d81049284f07d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Katja=20Su=CC=88ss?= Date: Mon, 21 Aug 2023 12:34:15 +0200 Subject: [PATCH] Add make lint and make format with plone/code-quality --- Makefile | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 35b61e7..988bdf8 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,15 @@ ADDONFOLDER=${ADDONBASE}src/ VENV_FOLDER=./venv PYBIN=${VENV_FOLDER}/bin/ +# See https://github.com/plone/code-quality +# Our configuration is in pyproject.toml. +CODE_QUALITY_VERSION=2.0.0 +CURRENT_USER=$$(whoami) +USER_INFO=$$(id -u ${CURRENT_USER}):$$(id -g ${CURRENT_USER}) +LINT=docker run --user="${USER_INFO}" --rm -v "$(PWD)":/github/workspace plone/code-quality:${CODE_QUALITY_VERSION} check +FORMAT=docker run --user="$(id -u $(whoami)):$(getent group $(whoami)|cut -d: -f3)" --rm -v "$(PWD)":/github/workspace plone/code-quality:${CODE_QUALITY_VERSION} format + + all: build # Add the following 'help' target to your Makefile @@ -23,18 +32,15 @@ all: build help: ## This help message @grep -E '^[a-zA-Z0-9._-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' - venv: python$(version) -m venv venv venv/bin/python -m pip install pip==23.0.1 venv/bin/pip install -U pip wheel mxdev - requirements-mxdev.txt: venv # pip venv/bin/mxdev -c mx.ini venv/bin/pip install -r requirements-mxdev.txt - .PHONY: build build: requirements-mxdev.txt ## Build Plone venv/bin/cookiecutter -f --no-input --config-file instance.yml https://github.com/plone/cookiecutter-zope-instance @@ -48,7 +54,16 @@ pip: ## Update Python venv test: ## Test venv/bin/pytest - .PHONY: test_quiet test_quiet: ## Run tests removing deprecation warnings venv/bin/pytest --disable-warnings + +.PHONY: lint +lint: ## validate with isort, black, flake8, pyroma, zpretty + @echo USER_INFO: $(USER_INFO) + $(LINT) + +.PHONY: format +format: ## Format the codebase according to our standards + @echo USER_INFO: $(USER_INFO) + $(FORMAT)