From ed3d527c09d17111365215d956e05c976ab6afb9 Mon Sep 17 00:00:00 2001 From: jo Date: Mon, 7 Jun 2021 23:58:16 +0200 Subject: [PATCH] Update CI to run pytest --- .github/scripts/python-pkg-install.sh | 4 +--- .github/scripts/python-pkg-test.sh | 17 +++++++---------- python_apps/airtime_analyzer/Makefile | 16 ++++++++++++++++ .../{requirements.txt => requirements-dev.txt} | 0 4 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 python_apps/airtime_analyzer/Makefile rename python_apps/airtime_analyzer/{requirements.txt => requirements-dev.txt} (100%) diff --git a/.github/scripts/python-pkg-install.sh b/.github/scripts/python-pkg-install.sh index 6f6c6744d..5bcade24a 100755 --- a/.github/scripts/python-pkg-install.sh +++ b/.github/scripts/python-pkg-install.sh @@ -1,12 +1,10 @@ #!/usr/bin/env bash 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 + 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 3b2b2875b..f0add173f 100755 --- a/.github/scripts/python-pkg-test.sh +++ b/.github/scripts/python-pkg-test.sh @@ -1,24 +1,21 @@ #!/usr/bin/env bash -failed='f' -# Starting at repo root +failed="false" echo "::group::Airtime Analyzer" -pushd python_apps/airtime_analyzer -if ! nosetests . -x; then - failed='t' +if ! make -C python_apps/airtime_analyzer test; then + failed="true" fi -popd echo "::endgroup::" echo "::group::API Client" if ! make -C python_apps/api_clients test; then - failed='t' + failed="true" fi echo "::endgroup::" -if [[ "$failed" = "t" ]]; then - echo "Python tests failed" - exit 1 +if [[ "$failed" = "true" ]]; then + echo "Python tests failed" + exit 1 fi echo "Python tests passed!" diff --git a/python_apps/airtime_analyzer/Makefile b/python_apps/airtime_analyzer/Makefile new file mode 100644 index 000000000..3e7580b48 --- /dev/null +++ b/python_apps/airtime_analyzer/Makefile @@ -0,0 +1,16 @@ +.PHONY: lint test + +SHELL := bash +CPU_CORES := $(shell nproc) + +MODULE_APP := airtime_analyzer +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/airtime_analyzer/requirements.txt b/python_apps/airtime_analyzer/requirements-dev.txt similarity index 100% rename from python_apps/airtime_analyzer/requirements.txt rename to python_apps/airtime_analyzer/requirements-dev.txt