diff --git a/.gitignore b/.gitignore index b987a36..7db6ea9 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ nosetests.xml coverage.xml *,cover .hypothesis/ +reports/ # Translations *.mo diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b5676ed..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -dist: trusty -sudo: required -language: python -python: - - 3 -install: pip install -r requirements.txt -script: python manage.py test diff --git a/README.md b/README.md deleted file mode 100644 index 557c77a..0000000 --- a/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# ara django - -## requirements - -python3 - -## install - -create virtual env - - ./scripts/createvenv.sh - -## start - -run test server - - ./scripts/runserver.sh - -then visit [http://127.0.0.1:8000/api/v1/](http://127.0.0.1:8000/api/v1/) - -## tests - - ./scripts/test.sh diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..d2831f6 --- /dev/null +++ b/README.rst @@ -0,0 +1,69 @@ +ara-django +========== + +.. image:: doc/source/_static/screenshot.png + +An experiment with Django at the core of the ARA 1.0 backend. +This is not stable or production-ready. + +If you are looking for ARA Records Ansible, the Ansible callback plugin and +reporting interface, you will find the repository here_. + +We are prototyping outside the main repository due to the vast changes +involved and will merge back as appropriate. + +.. _here: https://github.com/openstack/ara + +Documentation +============= + +*Work in progress* + +This is python3 only right now. + +**TL;DR**: Using tox is convenient for the time being:: + + # Use the source Luke + git clone https://github.com/dmsimard/ara-django + cd ara-django + + # Install tox + pip install tox # (or the tox python library from your distro packages) + + # Run test server -> http://127.0.0.1:8000/api/v1/ + tox -e runserver + + # Run actual tests or get coverage + tox -e pep8 + tox -e py35 + tox -e cover + + # Build docs + tox -e docs + +Contributors +============ + +See contributors on GitHub_. + +.. _GitHub: https://github.com/dmsimard/ara-django/graphs/contributors + +Copyright +========= + +:: + + Copyright (c) 2018 Red Hat, Inc. + + ARA is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ARA is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ARA. If not, see . diff --git a/doc/source/_static/screenshot.png b/doc/source/_static/screenshot.png new file mode 100644 index 0000000..99aa976 Binary files /dev/null and b/doc/source/_static/screenshot.png differ diff --git a/requirements.txt b/requirements.txt index 8eafddb..f6d052c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ +pbr!=2.1.0,>=2.0.0 # Apache-2.0 + Django<2 djangorestframework envparse diff --git a/scripts/createvenv.sh b/scripts/createvenv.sh deleted file mode 100755 index 26113bc..0000000 --- a/scripts/createvenv.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -RED='\033[0;31m' -NOCOLOR='\033[0m' - -if [ ! -f requirements.txt ]; then - echo -e "${RED}You seems to be in the wrong directory" - echo -e "Execute this script from the root of ara with ./scripts/${0##*/}${NOCOLOR}" - exit 1 -fi - -[ -d "venv" ] && rm -rf venv -python3 -m venv venv -source venv/bin/activate -pip install -r requirements.txt -pip install -r test-requirements.txt -deactivate diff --git a/scripts/runserver.sh b/scripts/runserver.sh deleted file mode 100755 index 9ae7117..0000000 --- a/scripts/runserver.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -RED='\033[0;31m' -NOCOLOR='\033[0m' - -if [ ! -f requirements.txt ]; then - echo -e "${RED}You seems to be in the wrong directory" - echo -e "Execute this script from the root of ara with ./scripts/${0##*/}${NOCOLOR}" - exit 1 -fi - -source venv/bin/activate - -python manage.py migrate -python manage.py collectstatic --clear --no-input -DJANGO_DEBUG=1 python manage.py runserver - -deactivate diff --git a/scripts/test.sh b/scripts/test.sh deleted file mode 100755 index aec7d1d..0000000 --- a/scripts/test.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -RED='\033[0;31m' -NOCOLOR='\033[0m' - -if [ ! -f requirements.txt ]; then - echo -e "${RED}You seems to be in the wrong directory" - echo -e "Execute this script from the root of ara with ./scripts/${0##*/}${NOCOLOR}" - exit 1 -fi - -source venv/bin/activate - -python manage.py test - -deactivate diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..632a2f3 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,59 @@ +[metadata] +name = ara-backend +summary = ARA Records Ansible backend +description-file = + README.rst +author = OpenStack Community +author-email = openstack-dev@lists.openstack.org +home-page = https://github.com/openstack/ara-backend +classifier = + Environment :: OpenStack + Intended Audience :: Information Technology + Intended Audience :: System Administrators + Intended Audience :: Developers + Topic :: Utilities + License :: OSI Approved :: GNU General Public License v3 (GPLv3) + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.5 + Development Status :: 4 - Beta + +[global] +setup-hooks = + pbr.hooks.setup_hook + +[files] +packages = + ara-backend + +[build_sphinx] +source-dir = doc/source +build-dir = doc/build +all_files = 1 + +[upload_sphinx] +upload-dir = docs/html + +[coverage:report] +ignore_errors = True +include = + ara/* + api/* +omit = + /usr* + setup.py + *egg* + .venv/* + +[coverage:html] +directory = reports + +[wheel] +universal = 1 + +[pbr] +skip_authors = True +skip_changelog = True diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..bda9dc3 --- /dev/null +++ b/setup.py @@ -0,0 +1,22 @@ +# Copyright (c) 2018 Red Hat, Inc. +# +# This file is part of ARA: Ansible Run Analysis. +# +# ARA is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ARA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ARA. If not, see . + +import setuptools + +setuptools.setup( + setup_requires=['pbr'], + pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt index fe9d594..9f82842 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +1,6 @@ factory-boy +bandit>=1.1.0 # Apache-2.0 +coverage +flake8 +sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 +sphinx-rtd-theme diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..7ad72e6 --- /dev/null +++ b/tox.ini @@ -0,0 +1,52 @@ +[tox] +minversion = 2.0 +envlist = py35,pep8 +skipdist = True + +[testenv] +basepython = python3 +sitepackages = False +usedevelop = True +install_command = pip install -U {opts} {packages} -c{env:CONSTRAINTS_FILE:/dev/null} +setenv = VIRTUAL_ENV={envdir} +deps = -r{toxinidir}/test-requirements.txt + +[testenv:venv] +commands = {posargs} + +[testenv:docs] +commands = sphinx-build -W -b html doc/source doc/build/html + +[testenv:pep8] +commands = + flake8 ara api + bandit -r ara api + +[testenv:py35] +commands = python manage.py test + +[testenv:runserver] +commands = + python manage.py migrate + python manage.py collectstatic --clear --no-input + python manage.py runserver +setenv = + DJANGO_DEBUG=1 + +[testenv:cover] +commands = + coverage erase + coverage run {toxinidir}/manage.py test ara + coverage run -a {toxinidir}/manage.py test api + coverage html + +[flake8] +# E123, E125 skipped as they are invalid PEP-8. +# E741, short ambiguous variable names +# H106 Don’t put vim configuration in source files +# H203 Use assertIs(Not)None to check for None +max-line-length = 120 +ignore = E123,E125,E741 +enable-extensions=H106,H203 +show-source = True +exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build