Use shared python makefile and start linting

Always update setuptools/wheel/pip

Never fail while linting

We use github annotations to impove the code incrementally.
This commit is contained in:
jo 2021-09-10 13:46:47 +02:00
parent 0d88d17f7c
commit ceb40ee216
7 changed files with 81 additions and 46 deletions

9
api/Makefile Normal file
View File

@ -0,0 +1,9 @@
all: lint
include ../tools/python.mk
PIP_INSTALL := --editable .[dev]
PYLINT_ARG := libretimeapi
lint: .pylint
clean: .clean

View File

@ -0,0 +1,9 @@
all: lint
include ../../tools/python.mk
PIP_INSTALL := --editable .[dev]
PYLINT_ARG := airtime-celery
lint: .pylint
clean: .clean

View File

@ -1,19 +1,15 @@
.PHONY: lint test
all: lint test
SHELL := bash
CPU_CORES := $(shell nproc)
include ../../tools/python.mk
MODULE_APP := airtime_analyzer
MODULE_TESTS := tests
PIP_INSTALL := --editable .[dev]
PYLINT_ARG := airtime_analyzer tests
PYTEST_ARG := --cov=airtime_analyzer tests
lint:
pylint ${MODULE_APP}
pylint ${MODULE_TESTS}
lint: .pylint
fixtures:
bash tests/fixtures/generate.sh
test: fixtures
pytest -n ${CPU_CORES} --color=yes -v --cov=${MODULE_APP} ${MODULE_TESTS}
all: lint test
test: fixtures .pytest
clean: .clean

View File

@ -1,16 +1,11 @@
.PHONY: lint test
SHELL := bash
CPU_CORES := $(shell nproc)
MODULE_APP := api_clients
MODULE_TESTS := tests
lint:
pylint ${MODULE_APP}
pylint ${MODULE_TESTS}
test:
pytest -n ${CPU_CORES} --color=yes -v --cov=${MODULE_APP} ${MODULE_TESTS}
all: lint test
include ../../tools/python.mk
PIP_INSTALL := --editable .[dev]
PYLINT_ARG := api_clients tests
PYTEST_ARG := --cov=api_clients tests
lint: .pylint
test: .pytest
clean: .clean

View File

@ -0,0 +1,9 @@
all: lint
include ../../tools/python.mk
PIP_INSTALL := --editable .[dev]
PYLINT_ARG := liquidsoap pypo
lint: .pylint
clean: .clean

View File

@ -1,23 +1,11 @@
.PHONY: lint test
.ONESHELL:
SHELL := bash
CPU_CORES := $(shell nproc)
all: lint test
venv:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements-dev.txt
include python.mk
lint: venv
source venv/bin/activate
pylint tools
PIP_INSTALL := -r requirements-dev.txt
PYLINT_ARG := tools
PYTEST_ARG := .
test: venv
source venv/bin/activate
pytest -n ${CPU_CORES} --color=yes -v .
clean:
rm -Rf venv
lint: .pylint
test: .pytest
clean: .clean

29
tools/python.mk Normal file
View File

@ -0,0 +1,29 @@
.ONESHELL:
SHELL := bash
CPU_CORES := $(shell nproc)
# PIP_INSTALL := --editable .[dev]
# PYLINT_ARG :=
# PYTEST_ARG :=
VENV := venv
$(VENV):
python3 -m venv $(VENV)
source $(VENV)/bin/activate
pip install --upgrade pip setuptools wheel
pip install $(PIP_INSTALL)
.PHONY: .pylint
.pylint: $(VENV)
source $(VENV)/bin/activate
pylint --output-format=colorized $(PYLINT_ARG) || true
.PHONY: .pytest
.pytest: $(VENV)
source venv/bin/activate
pytest -n $(CPU_CORES) --color=yes -v $(PYTEST_ARG)
.PHONY: .clean
.clean:
rm -Rf $(VENV)