diff --git a/Makefile b/Makefile index c1ff653..5a2d79c 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,12 @@ venv_dev: requirements/dev.txt ################################### test: - RESULTS=$(RESULTS) ./manage.py jenkins --enable-coverage --noinput --output-dir $(RESULTS) \ - --settings="repoapi.settings.test" + RESULTS=$(RESULTS) pytest-3 --junitxml=$(RESULTS)/junit.xml \ + --cov=. --cov-report=xml:$(RESULTS)/coverage.xml --pep8 + +test_pylint: + RESULTS=$(RESULTS) pytest-3 --junitxml=$(RESULTS)/junit.xml \ + --pylint --pylint-rcfile=pylint.cfg --pylint-jobs=4 ################################### diff --git a/repoapi/settings/common.py b/repoapi/settings/common.py index dc48d16..076b4b4 100644 --- a/repoapi/settings/common.py +++ b/repoapi/settings/common.py @@ -19,16 +19,6 @@ from os.path import dirname BASE_DIR = dirname(dirname(dirname(os.path.abspath(__file__)))) -# Application definition -# django-jenkins -PROJECT_APPS = [ - "repoapi", - "hotfix", - "panel", - "release_dashboard", - "build", -] - INSTALLED_APPS = [ "object_tools", "django.contrib.admin", @@ -46,6 +36,11 @@ INSTALLED_APPS = [ "django_filters", "jsonify", "export", + "repoapi", + "hotfix", + "panel", + "release_dashboard", + "build", ] MIDDLEWARE_CLASSES = ( diff --git a/repoapi/settings/prod.py b/repoapi/settings/prod.py index 1d1cff0..861d0d1 100644 --- a/repoapi/settings/prod.py +++ b/repoapi/settings/prod.py @@ -44,8 +44,6 @@ DEBUG = False ALLOWED_HOSTS = [".mgm.sipwise.com"] -INSTALLED_APPS.extend(PROJECT_APPS) # noqa - LOGGING["loggers"]["repoapi"]["level"] = os.getenv( # noqa "DJANGO_LOG_LEVEL", "INFO" ) # noqa diff --git a/repoapi/settings/test.py b/repoapi/settings/test.py index 9570d7b..acae1d0 100644 --- a/repoapi/settings/test.py +++ b/repoapi/settings/test.py @@ -37,12 +37,6 @@ DEBUG = True ALLOWED_HOSTS = [] -TESTING_APPS = [ - "django_jenkins", -] -INSTALLED_APPS.extend(TESTING_APPS) # noqa -INSTALLED_APPS.extend(PROJECT_APPS) # noqa - # Database # https://docs.djangoproject.com/en/1.8/ref/settings/#databases @@ -53,13 +47,6 @@ DATABASES = { } } -# django-jenkins -JENKINS_TASKS = ( - "django_jenkins.tasks.run_pylint", - "django_jenkins.tasks.run_flake8", -) -PYLINT_RCFILE = "pylint.cfg" - DJANGO_LOG_LEVEL = "DEBUG" JENKINS_URL = "http://localhost" diff --git a/requirements/test.txt b/requirements/test.txt index 6fcdad9..9510461 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,9 +1,2 @@ -r common.txt -# django-jenkins is not maintained right now -# this has some comunity fixes applied --e git://github.com/linuxmaniac/django-jenkins.git#egg=django-jenkins -flake8 -pep8 -pylint -coverage mock diff --git a/t/Dockerfile b/t/Dockerfile index 56d2463..99d46b1 100644 --- a/t/Dockerfile +++ b/t/Dockerfile @@ -5,10 +5,18 @@ FROM docker.mgm.sipwise.com/sipwise-buster:latest # is updated with the current date. It will force refresh of all # of the base images and things like `apt-get update` won't be using # old cached versions when the Dockerfile is built. -ENV REFRESHED_AT 2020-03-06 +ENV REFRESHED_AT 2020-03-20 + +# test execution; we need the backport of python3-junitxml from our own +# repository since it's not part of Debian/buster +# files that get-code generates +COPY t/sources.list.d/builddeps.list /etc/apt/sources.list.d/ +COPY t/sources.list.d/preferences /etc/apt/preferences.d/ RUN apt-get update RUN apt-get install --assume-yes python3 python3-dev \ + python3-pytest python3-pytest-django python3-pytest-pep8 \ + python3-pytest-pylint python3-pytest-cov python3-junitxml \ python3-pip python3-virtualenv virtualenv sqlite3 git tmux # Get pip to download and install requirements: diff --git a/t/sources.list.d/builddeps.list b/t/sources.list.d/builddeps.list new file mode 100644 index 0000000..e69de29 diff --git a/t/sources.list.d/preferences b/t/sources.list.d/preferences new file mode 100644 index 0000000..e69de29 diff --git a/tmux.sh b/tmux.sh index 383dd17..6295263 100755 --- a/tmux.sh +++ b/tmux.sh @@ -1,7 +1,10 @@ #!/bin/bash +repoapi_tag=${1:-latest} +repoapi_image=docker.mgm.sipwise.com/repoapi-buster:${repoapi_tag} + docker run -d --rm \ --hostname repoapi-rabbit --name repoapi-rabbit rabbitmq:3 -docker pull docker.mgm.sipwise.com/repoapi-buster:latest +docker pull "${repoapi_image}" docker run --rm -i -t --env=VAR_DIR=/code --link repoapi-rabbit:rabbit \ - -v "$(pwd)":/code:rw docker.mgm.sipwise.com/repoapi-buster:latest tmux + -v "$(pwd)":/code:rw "${repoapi_image}" tmux docker stop repoapi-rabbit diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..c2444ef --- /dev/null +++ b/tox.ini @@ -0,0 +1,7 @@ +[pytest] +DJANGO_SETTINGS_MODULE = repoapi.settings.test +# -- recommended but optional: +python_files = tests.py test_*.py *_tests.py + +[coverage:run] +data_file = ${RESULTS}/.coverage