diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..e1402f1 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,6 @@ +[run] +branch = True +source = ciwatch + +[report] +ignore_errors = True diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e625780 --- /dev/null +++ b/.gitignore @@ -0,0 +1,54 @@ +*.py[cod] + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +.eggs +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml +.testrepository +.venv + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Complexity +output/*.html +output/*/index.html + +# Sphinx +doc/build + +# pbr generates these +AUTHORS +ChangeLog + +# Editors +*~ +.*.swp +.*sw? diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..6d83b3c --- /dev/null +++ b/.testr.conf @@ -0,0 +1,7 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ + ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..73cfbd7 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,17 @@ +If you would like to contribute to the development of OpenStack, you must +follow the steps in this page: + + http://docs.openstack.org/infra/manual/developers.html + +If you already have a good understanding of how the system works and your +OpenStack accounts are set up, you can skip to the development workflow +section of this documentation to learn how changes to OpenStack should be +submitted for review via the Gerrit tool: + + http://docs.openstack.org/infra/manual/developers.html#development-workflow + +Pull requests submitted through GitHub will be ignored. + +Bugs should be filed on Launchpad, not GitHub: + + https://bugs.launchpad.net/ciwatch diff --git a/HACKING.rst b/HACKING.rst new file mode 100644 index 0000000..c778098 --- /dev/null +++ b/HACKING.rst @@ -0,0 +1,4 @@ +ciwatch Style Commandments +=============================================== + +Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..c978a52 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include AUTHORS +include ChangeLog +exclude .gitignore +exclude .gitreview + +global-exclude *.pyc diff --git a/README.md b/README.md deleted file mode 100644 index cb9f9e6..0000000 --- a/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# CI Watch - -## Configuration - -Configuration is stored in the `ci-watch.conf` file. Importantly, you can -specify a directory to store the `third-party-ci.log` file (data\_dir) as well -as the database to connect to. Look at `ci-watch.conf.sample` for an example. - -Other settings should be self explanatory based on the provided configuration -file. - -## Installation - -From this folder, run the following commands. - -``` -pip install -r requirements.txt -# Note that this step requires the `ci-watch.conf` file. -pip install -e . -``` - -These instructions are for development and testing installations. - -## Usage - -At the moment, this package provides three commands. - -`ci-watch-server`. -Launch a development server. - -`ci-watch-stream-events`. -Stream events from Gerrit and append valid events to `third-party-ci.log`. - -`ci-watch-populate-database`. -Add all entries from `third-party-ci.log` to the database. - -## State of the project - -This project is a work in progress and the code is pretty rough in some places. - -## TODO - -* Add tests. -* Use a different cache other than SimpleCache. It is not threadsafe. We - should use something like redis instead. - -These items are far from the only work needed for this project. - - -## Acknowledgements - -This code was originally forked from John Griffith's sos-ci project. Some of it -can still be found in the code and configuration file. diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..9ddf7e9 --- /dev/null +++ b/README.rst @@ -0,0 +1,33 @@ +======== +CI Watch +======== + +CI Watch is a CI monitoring dashboard that shows voting history for existing +CIs and more. + +* Free software: Apache license +* Documentation: http://docs.openstack.org/infra/ciwatch +* Source: http://git.openstack.org/cgit/openstack-infra/ciwatch +* Bugs: http://bugs.launchpad.net/ciwatch + + +State of the project +-------------------- + +This project is a work in progress and the code is pretty rough in some +places. + +TODO +---- + +- Add tests. +- Use a different cache other than SimpleCache. It is not threadsafe. + We should use something like redis instead. + +These items are far from the only work needed for this project. + +Acknowledgements +---------------- + +This code was originally forked from John Griffith's sos-ci project. +Some of it can still be found in the code and configuration file. diff --git a/ciwatch.wsgi b/ciwatch.wsgi index 7d9ae44..dced290 100644 --- a/ciwatch.wsgi +++ b/ciwatch.wsgi @@ -14,4 +14,4 @@ import sys sys.path.insert(0, "/var/www/ciwatch") -from ciwatch import app as application +from ciwatch.server import app as application diff --git a/ciwatch/__init__.py b/ciwatch/__init__.py index 58ac9fb..e690e0f 100644 --- a/ciwatch/__init__.py +++ b/ciwatch/__init__.py @@ -1,31 +1,19 @@ -# Copyright (c) 2015 Tintri. All rights reserved. +# -*- coding: utf-8 -*- + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at # -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. -from flask import Flask - -app = Flask(__name__) - -from ciwatch import views # noqa -from ciwatch import filters # noqa +import pbr.version -__version__ = "0.0.1" - - -def main(): - app.run(debug=True, host='0.0.0.0') - - -if __name__ == '__main__': - main() +__version__ = pbr.version.VersionInfo( + 'ciwatch').version_string() diff --git a/ciwatch/cmd/__init__.py b/ciwatch/cmd/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ciwatch/filters.py b/ciwatch/filters.py index 088e895..2f25623 100644 --- a/ciwatch/filters.py +++ b/ciwatch/filters.py @@ -16,7 +16,7 @@ import re from jinja2 import evalcontextfilter, Markup, escape -from ciwatch import app +from ciwatch.server import app _paragraph_re = re.compile(r'(?:\r\n|\r|\n){2,}') diff --git a/ciwatch/server.py b/ciwatch/server.py new file mode 100644 index 0000000..58ac9fb --- /dev/null +++ b/ciwatch/server.py @@ -0,0 +1,31 @@ +# Copyright (c) 2015 Tintri. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from flask import Flask + +app = Flask(__name__) + +from ciwatch import views # noqa +from ciwatch import filters # noqa + + +__version__ = "0.0.1" + + +def main(): + app.run(debug=True, host='0.0.0.0') + + +if __name__ == '__main__': + main() diff --git a/ciwatch/tests/__init__.py b/ciwatch/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ciwatch/tests/base.py b/ciwatch/tests/base.py new file mode 100644 index 0000000..1c30cdb --- /dev/null +++ b/ciwatch/tests/base.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +# Copyright 2010-2011 OpenStack Foundation +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslotest import base + + +class TestCase(base.BaseTestCase): + + """Test case base class for all unit tests.""" diff --git a/ciwatch/tests/test_ciwatch.py b/ciwatch/tests/test_ciwatch.py new file mode 100644 index 0000000..3099377 --- /dev/null +++ b/ciwatch/tests/test_ciwatch.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +""" +test_ciwatch +---------------------------------- + +Tests for `ciwatch` module. +""" + +from ciwatch.tests import base + + +class TestCiwatch(base.TestCase): + + def test_something(self): + pass diff --git a/ciwatch/views.py b/ciwatch/views.py index 31a5430..6b17429 100644 --- a/ciwatch/views.py +++ b/ciwatch/views.py @@ -16,7 +16,7 @@ from flask import render_template from sqlalchemy.orm.exc import NoResultFound from werkzeug.exceptions import abort -from ciwatch import app +from ciwatch.server import app from ciwatch.api import get_context from ciwatch.api import get_projects from ciwatch.cache import cached diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100755 index 0000000..3e48a80 --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +sys.path.insert(0, os.path.abspath('../..')) +# -- General configuration ---------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ + 'sphinx.ext.autodoc', + # 'sphinx.ext.intersphinx', + 'oslosphinx' +] + +# autodoc generation is a bit aggressive and a nuisance when doing heavy +# text edit cycles. +# execute "export SPHINX_DEBUG=1" in your terminal to disable + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'ciwatch' +copyright = u'2013, OpenStack Foundation' + +# If true, '()' will be appended to :func: etc. cross-reference text. +add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +# html_theme_path = ["."] +# html_theme = '_theme' +# html_static_path = ['static'] + +# Output file base name for HTML help builder. +htmlhelp_basename = '%sdoc' % project + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto/manual]). +latex_documents = [ + ('index', + '%s.tex' % project, + u'%s Documentation' % project, + u'OpenStack Foundation', 'manual'), +] + +# Example configuration for intersphinx: refer to the Python standard library. +# intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/doc/source/contributing.rst b/doc/source/contributing.rst new file mode 100644 index 0000000..1728a61 --- /dev/null +++ b/doc/source/contributing.rst @@ -0,0 +1,4 @@ +============ +Contributing +============ +.. include:: ../../CONTRIBUTING.rst diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000..9d939ce --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,25 @@ +.. ciwatch documentation master file, created by + sphinx-quickstart on Tue Jul 9 22:26:36 2013. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +CI Watch - CI Monitoring Dashboard +================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + readme + installation + usage + contributing + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/doc/source/installation.rst b/doc/source/installation.rst new file mode 100644 index 0000000..8a7b513 --- /dev/null +++ b/doc/source/installation.rst @@ -0,0 +1,21 @@ +============ +Installation +============ + +At the command line:: + + $ pip install . + +Or, if you have virtualenvwrapper installed:: + + $ mkvirtualenv ciwatchenv + $ pip install . + + +Configuration is stored in the ``ci-watch.conf`` file. Importantly, you can +specify a directory to store the ``third-party-ci.log`` file (data\_dir) as +well as the database to connect to. Look at ``ci-watch.conf.sample`` for an +example. + +Other settings should be self explanatory based on the provided configuration +file. diff --git a/doc/source/readme.rst b/doc/source/readme.rst new file mode 100644 index 0000000..a6210d3 --- /dev/null +++ b/doc/source/readme.rst @@ -0,0 +1 @@ +.. include:: ../../README.rst diff --git a/doc/source/usage.rst b/doc/source/usage.rst new file mode 100644 index 0000000..aef0509 --- /dev/null +++ b/doc/source/usage.rst @@ -0,0 +1,13 @@ +======== +Usage +======== + +At the moment, this package provides three commands. + +``ci-watch-server``. Launch a development server. + +``ci-watch-stream-events``. Stream events from Gerrit and append valid +events to ``third-party-ci.log``. + +``ci-watch-populate-database``. Add all entries from +``third-party-ci.log`` to the database. diff --git a/requirements.txt b/requirements.txt index 157ff9a..a37220b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,9 @@ -flask -sqlalchemy -iniparse -paramiko +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. + +pbr>=1.6 +flask>=0.10 +sqlalchemy>=1.0 +iniparse>=0.4 +paramiko>=1.15 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..06f8645 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,37 @@ +[metadata] +name = ciwatch +summary = CI Watch is a CI monitoring dashboard that shows voting history for existing CIs and more. +description-file = + README.rst +author = OpenStack +author-email = openstack-dev@lists.openstack.org +home-page = http://www.openstack.org/ +classifier = + Intended Audience :: Information Technology + Intended Audience :: System Administrators + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.3 + Programming Language :: Python :: 3.4 + +[files] +packages = + ciwatch + +[entry_points] +console_scripts = + ci-watch-server = ciwatch.server:main + ci-watch-populate-database = ciwatch.populate:main + ci-watch-stream-events = ciwatch.events:main + +[build_sphinx] +source-dir = doc/source +build-dir = doc/build +all_files = 1 + +[upload_sphinx] +upload-dir = doc/build/html diff --git a/setup.py b/setup.py index 84ae731..8aef17c 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - # Copyright (c) 2015 Tintri. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -14,28 +12,16 @@ # License for the specific language governing permissions and limitations # under the License. -from os.path import join, dirname +import setuptools -from setuptools import setup +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass -import ciwatch - - -setup( - name='ci-watch', - version=ciwatch.__version__, - long_description=open(join(dirname(__file__), 'README.md')).read(), - entry_points={ - 'console_scripts': [ - 'ci-watch-server = ciwatch:main', - 'ci-watch-populate-database = ciwatch.populate:main', - 'ci-watch-stream-events = ciwatch.events:main', - ], - }, - install_requires=[ - "flask", - "sqlalchemy", - "iniparse", - "paramiko", - ] -) +setuptools.setup( + setup_requires=['pbr'], + pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..ea1d673 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,20 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. + +hacking<0.11,>=0.10.0 + +coverage>=3.6 +discover +python-subunit>=0.0.18 +sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 +oslosphinx>=2.5.0 # Apache-2.0 +oslotest>=1.10.0 # Apache-2.0 +testrepository>=0.0.18 +testscenarios>=0.4 +testtools>=1.4.0 + +flask>=0.10 +sqlalchemy>=1.0 +iniparse>=0.4 +paramiko>=1.15 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..2bb8425 --- /dev/null +++ b/tox.ini @@ -0,0 +1,35 @@ +[tox] +minversion = 1.6 +envlist = py34,py27,pypy,pep8 +skipsdist = True + +[testenv] +usedevelop = True +install_command = pip install -U {opts} {packages} +setenv = + VIRTUAL_ENV={envdir} +deps = -r{toxinidir}/test-requirements.txt +commands = python setup.py test --slowest --testr-args='{posargs}' + +[testenv:pep8] +commands = flake8 + +[testenv:venv] +commands = {posargs} + +[testenv:cover] +commands = python setup.py test --coverage --testr-args='{posargs}' + +[testenv:docs] +commands = python setup.py build_sphinx + +[testenv:debug] +commands = oslo_debug_helper {posargs} + +[flake8] +# E123, E125 skipped as they are invalid PEP-8. + +show-source = True +ignore = E123,E125 +builtins = _ +exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build