Makefile: Move various tests into build system

- This allows those tests to be invoked on console and not just in CI pipelines.

Tests:

- Running make check works.

- CI pipeline succeeds.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
[jvalleroy: Remove phony test target]
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2024-02-01 10:48:38 -08:00 committed by James Valleroy
parent ba55d8fe2e
commit 2788d6810d
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
5 changed files with 42 additions and 15 deletions

View File

@ -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:

View File

@ -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

View File

@ -7,7 +7,6 @@ import importlib
import os
import pathlib
import sys
from unittest.mock import patch
import pytest

2
debian/control vendored
View File

@ -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,

2
debian/rules vendored
View File

@ -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