diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 64b0dddc5..4cb02a1c9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,31 +16,25 @@ code-quality: stage: test needs: [] script: - - python3 -m flake8 container plinth actions/* + - make check-code static-type-check: stage: test needs: [] - before_script: - - apt-get update - - apt-get install -y mypy script: - - mypy . + - make check-type unit-tests: stage: test needs: [] before_script: - - export DEBIAN_FRONTEND=noninteractive - - apt-get update - - apt-get build-dep -y . # Dependencies of the freedombox Debian package - - apt-get install -y $(./run --list-dependencies) # Module dependencies + - make provision-dev script: - adduser tester --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password - echo "tester:password" | chpasswd - cp -r . /home/tester/plinth - chown -R tester:tester /home/tester/plinth - - su -c "cd ~/plinth;PYTHONPATH='.' py.test-3 --cov=plinth --cov-report=html:/home/tester/plinth/htmlcov --cov-report=term" tester + - su -c "cd ~/plinth; make check-tests-cov" tester - cp -r /home/tester/plinth/htmlcov test-coverage-report coverage: '/^TOTAL\s+.*\s+(\d+\.\d+%)$/' artifacts: @@ -51,7 +45,7 @@ doc-tests: stage: test needs: [] script: - - doc/scripts/wikiparser.py + - make check-doc app-server-stable: variables: diff --git a/Makefile b/Makefile index 817b986b7..a6a5dc637 100644 --- a/Makefile +++ b/Makefile @@ -119,9 +119,29 @@ install: # Documentation $(MAKE) -C doc install -check: +check: check-type check-code check-doc check-tests + +# Run the main test suite +check-tests: $(PYTHON) -m pytest $(PYTEST_ARGS) +# Tests with coverage report +check-tests-cov: + $(PYTHON) -m pytest $(PYTEST_ARGS) --cov=plinth \ + --cov-report=html:./htmlcov --cov-report=term + +# Code quality checking using flake8 +check-code: + $(PYTHON) -m flake8 plinth actions/actions container + +# Static type checking using mypy +check-type: + $(PYTHON) -m mypy . + +# Use doctest for check the wikiparser in doc directory +check-doc: + $(PYTHON) -m doctest doc/scripts/wikiparser.py + clean: make -C doc clean rm -rf Plinth.egg-info @@ -158,4 +178,16 @@ provision-dev: DEBIAN_FRONTEND=noninteractive apt-get install --yes ncurses-term \ sshpass bash-completion -.PHONY: update-translations configure build install check clean provision +.PHONY: \ + build \ + check \ + check-code \ + check-doc \ + check-type \ + check-tests \ + check-tests-cov \ + clean \ + configure \ + install \ + provision \ + update-translations diff --git a/conftest.py b/conftest.py index 333e66fa7..244b98ade 100644 --- a/conftest.py +++ b/conftest.py @@ -7,7 +7,6 @@ import importlib import os import pathlib import sys -from unittest.mock import patch import pytest diff --git a/debian/control b/debian/control index 9da9f306e..1a4c3a4a1 100644 --- a/debian/control +++ b/debian/control @@ -37,6 +37,7 @@ Build-Depends: python3-flake8, python3-gi, python3-markupsafe, + python3-mypy, python3-openssl, python3-pampy, python3-paramiko, @@ -52,6 +53,7 @@ Build-Depends: python3-setuptools-git, # python3-tomli is not available in Bullseye python3-tomli | python3-coverage (<< 6.0), + python3-typeshed, python3-yaml, sshpass, xmlto, diff --git a/debian/rules b/debian/rules index 1bb50a3f8..ed6fa7582 100755 --- a/debian/rules +++ b/debian/rules @@ -7,7 +7,7 @@ export PYBUILD_CONFIGURE_ARGS=make configure export PYBUILD_BUILD_ARGS=make PYTHON={interpreter} build export PYBUILD_INSTALL_ARGS=make PYTHON={interpreter} DESTDIR={destdir} install export PYBUILD_CLEAN_ARGS=make clean -export PYBUILD_TEST_ARGS=make PYTHON={interpreter} check +export PYBUILD_TEST_ARGS=make PYTHON={interpreter} check-tests %: dh $@ --with python3 --buildsystem=pybuild