Merge pull request #1339 from jooola/feat/ci_start_linting
Start linting 🎉 !
This commit is contained in:
commit
56f5a84146
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"severity": "error",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^([^:]+):(\\d+):(\\d+): (E\\d+): \\033\\[[\\d;]+m([^\\033]+).*$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"code": 4,
|
||||||
|
"message": 5
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"owner": "pylint-error"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"severity": "warning",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^([^:]+):(\\d+):(\\d+): ([A-DF-Z]\\d+): \\033\\[[\\d;]+m([^\\033]+).*$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"code": 4,
|
||||||
|
"message": 5
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"owner": "pylint-warning"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -91,13 +91,42 @@ jobs:
|
||||||
make test
|
make test
|
||||||
working-directory: airtime_mvc
|
working-directory: airtime_mvc
|
||||||
|
|
||||||
|
# Start lint the code without failing the entire workflow, should be merged
|
||||||
|
# into 'test' when the entire matrix succeeds.
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: ghcr.io/libretime/libretime-dev:buster
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-
|
||||||
|
|
||||||
|
- name: Add annotations matchers
|
||||||
|
run: |
|
||||||
|
echo "::add-matcher::.github/annotations/pylint.json"
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
run: |
|
||||||
|
make -C api lint
|
||||||
|
make -C python_apps/airtime_analyzer lint
|
||||||
|
make -C python_apps/airtime-celery lint
|
||||||
|
make -C python_apps/api_clients lint
|
||||||
|
make -C python_apps/pypo lint
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
release: [bionic, buster]
|
|
||||||
context: [python_apps/airtime_analyzer, python_apps/api_clients]
|
context: [python_apps/airtime_analyzer, python_apps/api_clients]
|
||||||
|
release: [bionic, buster]
|
||||||
|
|
||||||
container: ghcr.io/libretime/libretime-dev:${{ matrix.release }}
|
container: ghcr.io/libretime/libretime-dev:${{ matrix.release }}
|
||||||
defaults:
|
defaults:
|
||||||
|
@ -110,20 +139,10 @@ jobs:
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
key: ${{ runner.os }}-pip-${{ matrix.context }}-${{ hashFiles('**/setup.py', '**/requirements-dev.txt') }}
|
key: ${{ runner.os }}-pip-${{ matrix.context }}-${{ hashFiles('**/setup.py') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pip-${{ matrix.context }}
|
${{ runner.os }}-pip-${{ matrix.context }}
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python3 -m venv venv && source venv/bin/activate
|
|
||||||
pip install --upgrade pip setuptools wheel
|
|
||||||
pip install -r requirements-dev.txt
|
|
||||||
pip install -e .
|
|
||||||
working-directory: ${{ matrix.context }}
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: make test
|
||||||
source venv/bin/activate
|
|
||||||
make test
|
|
||||||
working-directory: ${{ matrix.context }}
|
working-directory: ${{ matrix.context }}
|
||||||
|
|
|
@ -46,11 +46,6 @@ repos:
|
||||||
- id: isort
|
- id: isort
|
||||||
args: ["--profile", "black", "--filter-files"]
|
args: ["--profile", "black", "--filter-files"]
|
||||||
|
|
||||||
# - repo: https://github.com/pre-commit/mirrors-pylint
|
|
||||||
# rev: v3.0.0a3
|
|
||||||
# hooks:
|
|
||||||
# - id: pylint
|
|
||||||
|
|
||||||
- repo: https://github.com/codespell-project/codespell
|
- repo: https://github.com/codespell-project/codespell
|
||||||
rev: v2.1.0
|
rev: v2.1.0
|
||||||
hooks:
|
hooks:
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
all: lint
|
||||||
|
|
||||||
|
include ../tools/python.mk
|
||||||
|
|
||||||
|
PIP_INSTALL := --editable .[dev]
|
||||||
|
PYLINT_ARG := libretimeapi
|
||||||
|
MYPY_ARG := libretimeapi
|
||||||
|
|
||||||
|
lint: .pylint .mypy
|
||||||
|
clean: .clean
|
14
api/setup.py
14
api/setup.py
|
@ -20,13 +20,23 @@ setup(
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
scripts=["bin/libretime-api"],
|
scripts=["bin/libretime-api"],
|
||||||
|
python_requires=">=3.6",
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"coreapi",
|
"coreapi",
|
||||||
"Django~=3.0",
|
"django~=3.0",
|
||||||
"djangorestframework",
|
"djangorestframework",
|
||||||
"django-url-filter",
|
"django-url-filter",
|
||||||
"markdown",
|
"markdown",
|
||||||
"model_bakery",
|
"model_bakery",
|
||||||
"psycopg2",
|
|
||||||
],
|
],
|
||||||
|
extras_require={
|
||||||
|
"prod": [
|
||||||
|
"psycopg2",
|
||||||
|
],
|
||||||
|
"dev": [
|
||||||
|
"psycopg2-binary",
|
||||||
|
"mypy",
|
||||||
|
"pylint",
|
||||||
|
],
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
all: lint
|
||||||
|
|
||||||
|
include ../../tools/python.mk
|
||||||
|
|
||||||
|
PIP_INSTALL := --editable .[dev]
|
||||||
|
PYLINT_ARG := airtime-celery
|
||||||
|
MYPY_ARG := airtime-celery
|
||||||
|
|
||||||
|
lint: .pylint .mypy
|
||||||
|
clean: .clean
|
|
@ -18,10 +18,18 @@ setup(
|
||||||
},
|
},
|
||||||
license="MIT",
|
license="MIT",
|
||||||
packages=["airtime-celery"],
|
packages=["airtime-celery"],
|
||||||
|
python_requires=">=3.6",
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"celery==4.4.7",
|
"celery==4.4.7",
|
||||||
"kombu==4.6.10",
|
"kombu==4.6.10",
|
||||||
"configobj",
|
"configobj",
|
||||||
],
|
],
|
||||||
|
extras_require={
|
||||||
|
"prod": [],
|
||||||
|
"dev": [
|
||||||
|
"mypy",
|
||||||
|
"pylint",
|
||||||
|
],
|
||||||
|
},
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
.PHONY: lint test
|
all: lint test
|
||||||
|
|
||||||
SHELL := bash
|
include ../../tools/python.mk
|
||||||
CPU_CORES := $(shell nproc)
|
|
||||||
|
|
||||||
MODULE_APP := airtime_analyzer
|
PIP_INSTALL := --editable .[dev]
|
||||||
MODULE_TESTS := tests
|
PYLINT_ARG := airtime_analyzer tests
|
||||||
|
MYPY_ARG := airtime_analyzer tests
|
||||||
|
PYTEST_ARG := --cov=airtime_analyzer tests
|
||||||
|
|
||||||
lint:
|
lint: .pylint .mypy
|
||||||
pylint ${MODULE_APP}
|
|
||||||
pylint ${MODULE_TESTS}
|
|
||||||
|
|
||||||
fixtures:
|
fixtures:
|
||||||
bash tests/fixtures/generate.sh
|
bash tests/fixtures/generate.sh
|
||||||
|
|
||||||
test: fixtures
|
test: fixtures .pytest
|
||||||
pytest -n ${CPU_CORES} --color=yes -v --cov=${MODULE_APP} ${MODULE_TESTS}
|
clean: .clean
|
||||||
|
|
||||||
all: lint test
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
distro
|
|
||||||
pylint
|
|
||||||
pytest
|
|
||||||
pytest-cov
|
|
||||||
pytest-xdist
|
|
|
@ -23,6 +23,7 @@ setup(
|
||||||
"libretime-analyzer=airtime_analyzer.cli:main",
|
"libretime-analyzer=airtime_analyzer.cli:main",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
python_requires=">=3.6",
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"mutagen>=1.31.0",
|
"mutagen>=1.31.0",
|
||||||
"pika>=1.0.0",
|
"pika>=1.0.0",
|
||||||
|
@ -33,5 +34,16 @@ setup(
|
||||||
# If this version is changed, it needs changing in the install script too
|
# If this version is changed, it needs changing in the install script too
|
||||||
"pycairo==1.19.1",
|
"pycairo==1.19.1",
|
||||||
],
|
],
|
||||||
|
extras_require={
|
||||||
|
"prod": [],
|
||||||
|
"dev": [
|
||||||
|
"distro",
|
||||||
|
"mypy",
|
||||||
|
"pylint",
|
||||||
|
"pytest",
|
||||||
|
"pytest-cov",
|
||||||
|
"pytest-xdist",
|
||||||
|
],
|
||||||
|
},
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
.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
|
all: lint test
|
||||||
|
|
||||||
|
include ../../tools/python.mk
|
||||||
|
|
||||||
|
PIP_INSTALL := --editable .[dev]
|
||||||
|
PYLINT_ARG := api_clients tests
|
||||||
|
MYPY_ARG := api_clients tests
|
||||||
|
PYTEST_ARG := --cov=api_clients tests
|
||||||
|
|
||||||
|
lint: .pylint .mypy
|
||||||
|
test: .pytest
|
||||||
|
clean: .clean
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
pylint
|
|
||||||
pytest
|
|
||||||
pytest-cov
|
|
||||||
pytest-xdist
|
|
|
@ -18,10 +18,21 @@ setup(
|
||||||
},
|
},
|
||||||
license="AGPLv3",
|
license="AGPLv3",
|
||||||
packages=["api_clients"],
|
packages=["api_clients"],
|
||||||
|
python_requires=">=3.6",
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"configobj",
|
"configobj",
|
||||||
"python-dateutil>=2.7.0",
|
"python-dateutil>=2.7.0",
|
||||||
"requests",
|
"requests",
|
||||||
],
|
],
|
||||||
|
extras_require={
|
||||||
|
"prod": [],
|
||||||
|
"dev": [
|
||||||
|
"mypy",
|
||||||
|
"pylint",
|
||||||
|
"pytest",
|
||||||
|
"pytest-cov",
|
||||||
|
"pytest-xdist",
|
||||||
|
],
|
||||||
|
},
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
all: lint
|
||||||
|
|
||||||
|
include ../../tools/python.mk
|
||||||
|
|
||||||
|
PIP_INSTALL := --editable .[dev]
|
||||||
|
PYLINT_ARG := liquidsoap pypo
|
||||||
|
MYPY_ARG := liquidsoap pypo
|
||||||
|
|
||||||
|
lint: .pylint .mypy
|
||||||
|
clean: .clean
|
|
@ -27,6 +27,7 @@ setup(
|
||||||
"bin/airtime-liquidsoap",
|
"bin/airtime-liquidsoap",
|
||||||
"bin/pyponotify",
|
"bin/pyponotify",
|
||||||
],
|
],
|
||||||
|
python_requires=">=3.6",
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"amqplib",
|
"amqplib",
|
||||||
"configobj",
|
"configobj",
|
||||||
|
@ -37,5 +38,12 @@ setup(
|
||||||
"pytz",
|
"pytz",
|
||||||
"requests",
|
"requests",
|
||||||
],
|
],
|
||||||
|
extras_require={
|
||||||
|
"prod": [],
|
||||||
|
"dev": [
|
||||||
|
"mypy",
|
||||||
|
"pylint",
|
||||||
|
],
|
||||||
|
},
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,23 +1,12 @@
|
||||||
.PHONY: lint test
|
|
||||||
.ONESHELL:
|
|
||||||
|
|
||||||
SHELL := bash
|
|
||||||
CPU_CORES := $(shell nproc)
|
|
||||||
|
|
||||||
all: lint test
|
all: lint test
|
||||||
|
|
||||||
venv:
|
include python.mk
|
||||||
python3 -m venv venv
|
|
||||||
source venv/bin/activate
|
|
||||||
pip install -r requirements-dev.txt
|
|
||||||
|
|
||||||
lint: venv
|
PIP_INSTALL := -r requirements-dev.txt
|
||||||
source venv/bin/activate
|
PYLINT_ARG := tools
|
||||||
pylint tools
|
MYPY_ARG := .
|
||||||
|
PYTEST_ARG := .
|
||||||
|
|
||||||
test: venv
|
lint: .pylint .mypy
|
||||||
source venv/bin/activate
|
test: .pytest
|
||||||
pytest -n ${CPU_CORES} --color=yes -v .
|
clean: .clean
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -Rf venv
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
.ONESHELL:
|
||||||
|
|
||||||
|
SHELL := bash
|
||||||
|
CPU_CORES := $(shell nproc)
|
||||||
|
|
||||||
|
# PIP_INSTALL := --editable .[dev]
|
||||||
|
# PYLINT_ARG :=
|
||||||
|
# MYPY_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: .mypy
|
||||||
|
.mypy: $(VENV)
|
||||||
|
source $(VENV)/bin/activate
|
||||||
|
mypy $(MYPY_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)
|
|
@ -1,3 +1,4 @@
|
||||||
|
mypy
|
||||||
pylint
|
pylint
|
||||||
pytest
|
pytest
|
||||||
pytest-xdist
|
pytest-xdist
|
||||||
|
|
Loading…
Reference in New Issue