From 8d9d1e43c5d204bd83dc21c34f6fc6ac354df4d5 Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 8 Jun 2021 00:12:14 +0200 Subject: [PATCH] Update CI to run api_clients pytest --- .github/scripts/python-pkg-install.sh | 3 +++ .github/scripts/python-pkg-test.sh | 8 +++----- python_apps/api_clients/Makefile | 16 ++++++++++++++++ python_apps/api_clients/requirements-dev.txt | 5 +++++ 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 python_apps/api_clients/Makefile create mode 100644 python_apps/api_clients/requirements-dev.txt diff --git a/.github/scripts/python-pkg-install.sh b/.github/scripts/python-pkg-install.sh index 89569b228..6f6c6744d 100755 --- a/.github/scripts/python-pkg-install.sh +++ b/.github/scripts/python-pkg-install.sh @@ -4,6 +4,9 @@ echo "::group::Install Python apps" pip3 install nose mock for app in $(ls python_apps); do + if [[ -f "python_apps/$app/requirements-dev.txt" ]]; then + pip3 install -r "python_apps/$app/requirements-dev.txt" + fi pip3 install -e python_apps/$app done echo "::endgroup::" diff --git a/.github/scripts/python-pkg-test.sh b/.github/scripts/python-pkg-test.sh index 8a19167f4..3b2b2875b 100755 --- a/.github/scripts/python-pkg-test.sh +++ b/.github/scripts/python-pkg-test.sh @@ -4,21 +4,19 @@ failed='f' # Starting at repo root echo "::group::Airtime Analyzer" -cd python_apps/airtime_analyzer +pushd python_apps/airtime_analyzer if ! nosetests . -x; then failed='t' fi +popd echo "::endgroup::" echo "::group::API Client" -cd ../api_clients -if ! nosetests . -x; then +if ! make -C python_apps/api_clients test; then failed='t' fi echo "::endgroup::" -# Reset to repo root -cd ../.. if [[ "$failed" = "t" ]]; then echo "Python tests failed" exit 1 diff --git a/python_apps/api_clients/Makefile b/python_apps/api_clients/Makefile new file mode 100644 index 000000000..267fb7986 --- /dev/null +++ b/python_apps/api_clients/Makefile @@ -0,0 +1,16 @@ +.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 diff --git a/python_apps/api_clients/requirements-dev.txt b/python_apps/api_clients/requirements-dev.txt new file mode 100644 index 000000000..df5ecde01 --- /dev/null +++ b/python_apps/api_clients/requirements-dev.txt @@ -0,0 +1,5 @@ +mock +pylint +pytest +pytest-cov +pytest-xdist