Browse Source

Apply openstack-dev cookiecutter template

CI Watch project started outside of OpenStack infrastructure.
This patch adds missing bits to enables infra testing, documentation
builds, and to make packaging easier if we'd like to do so.

Additional changes to accommodate the template:

 * ciwatch/__init__.py renamed to ciwatch/server.pp, and all related
   imports updated.
 * README.md converted into rst and split up into sections.

Partial-Bug: #1505834
Change-Id: I0aaabcfd1607609a337ce6ca2a71f9889b45de0a
changes/20/239120/2
Mikhail S Medvedev 4 years ago
parent
commit
fb75343650

+ 6
- 0
.coveragerc View File

@@ -0,0 +1,6 @@
1
+[run]
2
+branch = True
3
+source = ciwatch
4
+
5
+[report]
6
+ignore_errors = True

+ 54
- 0
.gitignore View File

@@ -0,0 +1,54 @@
1
+*.py[cod]
2
+
3
+# C extensions
4
+*.so
5
+
6
+# Packages
7
+*.egg
8
+*.egg-info
9
+dist
10
+build
11
+.eggs
12
+eggs
13
+parts
14
+bin
15
+var
16
+sdist
17
+develop-eggs
18
+.installed.cfg
19
+lib
20
+lib64
21
+
22
+# Installer logs
23
+pip-log.txt
24
+
25
+# Unit test / coverage reports
26
+.coverage
27
+.tox
28
+nosetests.xml
29
+.testrepository
30
+.venv
31
+
32
+# Translations
33
+*.mo
34
+
35
+# Mr Developer
36
+.mr.developer.cfg
37
+.project
38
+.pydevproject
39
+
40
+# Complexity
41
+output/*.html
42
+output/*/index.html
43
+
44
+# Sphinx
45
+doc/build
46
+
47
+# pbr generates these
48
+AUTHORS
49
+ChangeLog
50
+
51
+# Editors
52
+*~
53
+.*.swp
54
+.*sw?

+ 7
- 0
.testr.conf View File

@@ -0,0 +1,7 @@
1
+[DEFAULT]
2
+test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
3
+             OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
4
+             OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
5
+             ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
6
+test_id_option=--load-list $IDFILE
7
+test_list_option=--list

+ 17
- 0
CONTRIBUTING.rst View File

@@ -0,0 +1,17 @@
1
+If you would like to contribute to the development of OpenStack, you must
2
+follow the steps in this page:
3
+
4
+   http://docs.openstack.org/infra/manual/developers.html
5
+
6
+If you already have a good understanding of how the system works and your
7
+OpenStack accounts are set up, you can skip to the development workflow
8
+section of this documentation to learn how changes to OpenStack should be
9
+submitted for review via the Gerrit tool:
10
+
11
+   http://docs.openstack.org/infra/manual/developers.html#development-workflow
12
+
13
+Pull requests submitted through GitHub will be ignored.
14
+
15
+Bugs should be filed on Launchpad, not GitHub:
16
+
17
+   https://bugs.launchpad.net/ciwatch

+ 4
- 0
HACKING.rst View File

@@ -0,0 +1,4 @@
1
+ciwatch Style Commandments
2
+===============================================
3
+
4
+Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/

+ 6
- 0
MANIFEST.in View File

@@ -0,0 +1,6 @@
1
+include AUTHORS
2
+include ChangeLog
3
+exclude .gitignore
4
+exclude .gitreview
5
+
6
+global-exclude *.pyc

+ 0
- 53
README.md View File

@@ -1,53 +0,0 @@
1
-# CI Watch
2
-
3
-## Configuration
4
-
5
-Configuration is stored in the `ci-watch.conf` file. Importantly, you can
6
-specify a directory to store the `third-party-ci.log` file (data\_dir) as well
7
-as the database to connect to. Look at `ci-watch.conf.sample` for an example.
8
-
9
-Other settings should be self explanatory based on the provided configuration
10
-file.
11
-
12
-## Installation
13
-
14
-From this folder, run the following commands.
15
-
16
-```
17
-pip install -r requirements.txt
18
-# Note that this step requires the `ci-watch.conf` file.
19
-pip install -e .
20
-```
21
-
22
-These instructions are for development and testing installations.
23
-
24
-## Usage
25
-
26
-At the moment, this package provides three commands.
27
-
28
-`ci-watch-server`.
29
-Launch a development server.
30
-
31
-`ci-watch-stream-events`.
32
-Stream events from Gerrit and append valid events to `third-party-ci.log`.
33
-
34
-`ci-watch-populate-database`.
35
-Add all entries from `third-party-ci.log` to the database.
36
-
37
-## State of the project
38
-
39
-This project is a work in progress and the code is pretty rough in some places.
40
-
41
-## TODO
42
-
43
-* Add tests.
44
-* Use a different cache other than SimpleCache. It is not threadsafe. We
45
-  should use something like redis instead.
46
-
47
-These items are far from the only work needed for this project.
48
-
49
-
50
-## Acknowledgements
51
-
52
-This code was originally forked from John Griffith's sos-ci project. Some of it
53
-can still be found in the code and configuration file.

+ 33
- 0
README.rst View File

@@ -0,0 +1,33 @@
1
+========
2
+CI Watch
3
+========
4
+
5
+CI Watch is a CI monitoring dashboard that shows voting history for existing
6
+CIs and more.
7
+
8
+* Free software: Apache license
9
+* Documentation: http://docs.openstack.org/infra/ciwatch
10
+* Source: http://git.openstack.org/cgit/openstack-infra/ciwatch
11
+* Bugs: http://bugs.launchpad.net/ciwatch
12
+
13
+
14
+State of the project
15
+--------------------
16
+
17
+This project is a work in progress and the code is pretty rough in some
18
+places.
19
+
20
+TODO
21
+----
22
+
23
+-  Add tests.
24
+-  Use a different cache other than SimpleCache. It is not threadsafe.
25
+   We should use something like redis instead.
26
+
27
+These items are far from the only work needed for this project.
28
+
29
+Acknowledgements
30
+----------------
31
+
32
+This code was originally forked from John Griffith's sos-ci project.
33
+Some of it can still be found in the code and configuration file.

+ 1
- 1
ciwatch.wsgi View File

@@ -14,4 +14,4 @@
14 14
 
15 15
 import sys
16 16
 sys.path.insert(0, "/var/www/ciwatch")
17
-from ciwatch import app as application
17
+from ciwatch.server import app as application

+ 14
- 26
ciwatch/__init__.py View File

@@ -1,31 +1,19 @@
1
-# Copyright (c) 2015 Tintri. All rights reserved.
2
-#
3
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
-#    not use this file except in compliance with the License. You may obtain
5
-#    a copy of the License at
1
+# -*- coding: utf-8 -*-
2
+
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6 6
 #
7
-#         http://www.apache.org/licenses/LICENSE-2.0
7
+#      http://www.apache.org/licenses/LICENSE-2.0
8 8
 #
9
-#    Unless required by applicable law or agreed to in writing, software
10
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
-#    License for the specific language governing permissions and limitations
13
-#    under the License.
14
-
15
-from flask import Flask
16
-
17
-app = Flask(__name__)
18
-
19
-from ciwatch import views  # noqa
20
-from ciwatch import filters  # noqa
21
-
22
-
23
-__version__ = "0.0.1"
24
-
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
25 14
 
26
-def main():
27
-    app.run(debug=True, host='0.0.0.0')
15
+import pbr.version
28 16
 
29 17
 
30
-if __name__ == '__main__':
31
-    main()
18
+__version__ = pbr.version.VersionInfo(
19
+    'ciwatch').version_string()

+ 0
- 0
ciwatch/cmd/__init__.py View File


+ 1
- 1
ciwatch/filters.py View File

@@ -16,7 +16,7 @@ import re
16 16
 
17 17
 from jinja2 import evalcontextfilter, Markup, escape
18 18
 
19
-from ciwatch import app
19
+from ciwatch.server import app
20 20
 
21 21
 
22 22
 _paragraph_re = re.compile(r'(?:\r\n|\r|\n){2,}')

+ 31
- 0
ciwatch/server.py View File

@@ -0,0 +1,31 @@
1
+# Copyright (c) 2015 Tintri. All rights reserved.
2
+#
3
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+#    not use this file except in compliance with the License. You may obtain
5
+#    a copy of the License at
6
+#
7
+#         http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+#    Unless required by applicable law or agreed to in writing, software
10
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+#    License for the specific language governing permissions and limitations
13
+#    under the License.
14
+
15
+from flask import Flask
16
+
17
+app = Flask(__name__)
18
+
19
+from ciwatch import views  # noqa
20
+from ciwatch import filters  # noqa
21
+
22
+
23
+__version__ = "0.0.1"
24
+
25
+
26
+def main():
27
+    app.run(debug=True, host='0.0.0.0')
28
+
29
+
30
+if __name__ == '__main__':
31
+    main()

+ 0
- 0
ciwatch/tests/__init__.py View File


+ 23
- 0
ciwatch/tests/base.py View File

@@ -0,0 +1,23 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+# Copyright 2010-2011 OpenStack Foundation
4
+# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+# not use this file except in compliance with the License. You may obtain
8
+# a copy of the License at
9
+#
10
+#      http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+# License for the specific language governing permissions and limitations
16
+# under the License.
17
+
18
+from oslotest import base
19
+
20
+
21
+class TestCase(base.BaseTestCase):
22
+
23
+    """Test case base class for all unit tests."""

+ 28
- 0
ciwatch/tests/test_ciwatch.py View File

@@ -0,0 +1,28 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+#      http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+"""
16
+test_ciwatch
17
+----------------------------------
18
+
19
+Tests for `ciwatch` module.
20
+"""
21
+
22
+from ciwatch.tests import base
23
+
24
+
25
+class TestCiwatch(base.TestCase):
26
+
27
+    def test_something(self):
28
+        pass

+ 1
- 1
ciwatch/views.py View File

@@ -16,7 +16,7 @@ from flask import render_template
16 16
 from sqlalchemy.orm.exc import NoResultFound
17 17
 from werkzeug.exceptions import abort
18 18
 
19
-from ciwatch import app
19
+from ciwatch.server import app
20 20
 from ciwatch.api import get_context
21 21
 from ciwatch.api import get_projects
22 22
 from ciwatch.cache import cached

+ 75
- 0
doc/source/conf.py View File

@@ -0,0 +1,75 @@
1
+# -*- coding: utf-8 -*-
2
+# Licensed under the Apache License, Version 2.0 (the "License");
3
+# you may not use this file except in compliance with the License.
4
+# You may obtain a copy of the License at
5
+#
6
+#    http://www.apache.org/licenses/LICENSE-2.0
7
+#
8
+# Unless required by applicable law or agreed to in writing, software
9
+# distributed under the License is distributed on an "AS IS" BASIS,
10
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11
+# implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+import os
16
+import sys
17
+
18
+sys.path.insert(0, os.path.abspath('../..'))
19
+# -- General configuration ----------------------------------------------------
20
+
21
+# Add any Sphinx extension module names here, as strings. They can be
22
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
23
+extensions = [
24
+    'sphinx.ext.autodoc',
25
+    # 'sphinx.ext.intersphinx',
26
+    'oslosphinx'
27
+]
28
+
29
+# autodoc generation is a bit aggressive and a nuisance when doing heavy
30
+# text edit cycles.
31
+# execute "export SPHINX_DEBUG=1" in your terminal to disable
32
+
33
+# The suffix of source filenames.
34
+source_suffix = '.rst'
35
+
36
+# The master toctree document.
37
+master_doc = 'index'
38
+
39
+# General information about the project.
40
+project = u'ciwatch'
41
+copyright = u'2013, OpenStack Foundation'
42
+
43
+# If true, '()' will be appended to :func: etc. cross-reference text.
44
+add_function_parentheses = True
45
+
46
+# If true, the current module name will be prepended to all description
47
+# unit titles (such as .. function::).
48
+add_module_names = True
49
+
50
+# The name of the Pygments (syntax highlighting) style to use.
51
+pygments_style = 'sphinx'
52
+
53
+# -- Options for HTML output --------------------------------------------------
54
+
55
+# The theme to use for HTML and HTML Help pages.  Major themes that come with
56
+# Sphinx are currently 'default' and 'sphinxdoc'.
57
+# html_theme_path = ["."]
58
+# html_theme = '_theme'
59
+# html_static_path = ['static']
60
+
61
+# Output file base name for HTML help builder.
62
+htmlhelp_basename = '%sdoc' % project
63
+
64
+# Grouping the document tree into LaTeX files. List of tuples
65
+# (source start file, target name, title, author, documentclass
66
+# [howto/manual]).
67
+latex_documents = [
68
+    ('index',
69
+     '%s.tex' % project,
70
+     u'%s Documentation' % project,
71
+     u'OpenStack Foundation', 'manual'),
72
+]
73
+
74
+# Example configuration for intersphinx: refer to the Python standard library.
75
+# intersphinx_mapping = {'http://docs.python.org/': None}

+ 4
- 0
doc/source/contributing.rst View File

@@ -0,0 +1,4 @@
1
+============
2
+Contributing
3
+============
4
+.. include:: ../../CONTRIBUTING.rst

+ 25
- 0
doc/source/index.rst View File

@@ -0,0 +1,25 @@
1
+.. ciwatch documentation master file, created by
2
+   sphinx-quickstart on Tue Jul  9 22:26:36 2013.
3
+   You can adapt this file completely to your liking, but it should at least
4
+   contain the root `toctree` directive.
5
+
6
+CI Watch - CI Monitoring Dashboard
7
+==================================
8
+
9
+Contents:
10
+
11
+.. toctree::
12
+   :maxdepth: 2
13
+
14
+   readme
15
+   installation
16
+   usage
17
+   contributing
18
+
19
+Indices and tables
20
+==================
21
+
22
+* :ref:`genindex`
23
+* :ref:`modindex`
24
+* :ref:`search`
25
+

+ 21
- 0
doc/source/installation.rst View File

@@ -0,0 +1,21 @@
1
+============
2
+Installation
3
+============
4
+
5
+At the command line::
6
+
7
+    $ pip install .
8
+
9
+Or, if you have virtualenvwrapper installed::
10
+
11
+    $ mkvirtualenv ciwatchenv
12
+    $ pip install .
13
+
14
+
15
+Configuration is stored in the ``ci-watch.conf`` file. Importantly, you can
16
+specify a directory to store the ``third-party-ci.log`` file (data\_dir) as
17
+well as the database to connect to. Look at ``ci-watch.conf.sample`` for an
18
+example.
19
+
20
+Other settings should be self explanatory based on the provided configuration
21
+file.

+ 1
- 0
doc/source/readme.rst View File

@@ -0,0 +1 @@
1
+.. include:: ../../README.rst

+ 13
- 0
doc/source/usage.rst View File

@@ -0,0 +1,13 @@
1
+========
2
+Usage
3
+========
4
+
5
+At the moment, this package provides three commands.
6
+
7
+``ci-watch-server``. Launch a development server.
8
+
9
+``ci-watch-stream-events``. Stream events from Gerrit and append valid
10
+events to ``third-party-ci.log``.
11
+
12
+``ci-watch-populate-database``. Add all entries from
13
+``third-party-ci.log`` to the database.

+ 9
- 4
requirements.txt View File

@@ -1,4 +1,9 @@
1
-flask
2
-sqlalchemy
3
-iniparse
4
-paramiko
1
+# The order of packages is significant, because pip processes them in the order
2
+# of appearance. Changing the order has an impact on the overall integration
3
+# process, which may cause wedges in the gate later.
4
+
5
+pbr>=1.6
6
+flask>=0.10
7
+sqlalchemy>=1.0
8
+iniparse>=0.4
9
+paramiko>=1.15

+ 37
- 0
setup.cfg View File

@@ -0,0 +1,37 @@
1
+[metadata]
2
+name = ciwatch
3
+summary = CI Watch is a CI monitoring dashboard that shows voting history for existing CIs and more.
4
+description-file =
5
+    README.rst
6
+author = OpenStack
7
+author-email = openstack-dev@lists.openstack.org
8
+home-page = http://www.openstack.org/
9
+classifier =
10
+    Intended Audience :: Information Technology
11
+    Intended Audience :: System Administrators
12
+    License :: OSI Approved :: Apache Software License
13
+    Operating System :: POSIX :: Linux
14
+    Programming Language :: Python
15
+    Programming Language :: Python :: 2
16
+    Programming Language :: Python :: 2.7
17
+    Programming Language :: Python :: 3
18
+    Programming Language :: Python :: 3.3
19
+    Programming Language :: Python :: 3.4
20
+
21
+[files]
22
+packages =
23
+    ciwatch
24
+
25
+[entry_points]
26
+console_scripts =
27
+    ci-watch-server = ciwatch.server:main
28
+    ci-watch-populate-database = ciwatch.populate:main
29
+    ci-watch-stream-events = ciwatch.events:main
30
+
31
+[build_sphinx]
32
+source-dir = doc/source
33
+build-dir = doc/build
34
+all_files = 1
35
+
36
+[upload_sphinx]
37
+upload-dir = doc/build/html

+ 11
- 25
setup.py View File

@@ -1,5 +1,3 @@
1
-#!/usr/bin/env python
2
-
3 1
 # Copyright (c) 2015 Tintri. All rights reserved.
4 2
 #
5 3
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -14,28 +12,16 @@
14 12
 #    License for the specific language governing permissions and limitations
15 13
 #    under the License.
16 14
 
17
-from os.path import join, dirname
18
-
19
-from setuptools import setup
20
-
21
-import ciwatch
15
+import setuptools
22 16
 
17
+# In python < 2.7.4, a lazy loading of package `pbr` will break
18
+# setuptools if some other modules registered functions in `atexit`.
19
+# solution from: http://bugs.python.org/issue15881#msg170215
20
+try:
21
+    import multiprocessing  # noqa
22
+except ImportError:
23
+    pass
23 24
 
24
-setup(
25
-    name='ci-watch',
26
-    version=ciwatch.__version__,
27
-    long_description=open(join(dirname(__file__), 'README.md')).read(),
28
-    entry_points={
29
-        'console_scripts': [
30
-            'ci-watch-server = ciwatch:main',
31
-            'ci-watch-populate-database = ciwatch.populate:main',
32
-            'ci-watch-stream-events = ciwatch.events:main',
33
-            ],
34
-        },
35
-    install_requires=[
36
-        "flask",
37
-        "sqlalchemy",
38
-        "iniparse",
39
-        "paramiko",
40
-    ]
41
-)
25
+setuptools.setup(
26
+    setup_requires=['pbr'],
27
+    pbr=True)

+ 20
- 0
test-requirements.txt View File

@@ -0,0 +1,20 @@
1
+# The order of packages is significant, because pip processes them in the order
2
+# of appearance. Changing the order has an impact on the overall integration
3
+# process, which may cause wedges in the gate later.
4
+
5
+hacking<0.11,>=0.10.0
6
+
7
+coverage>=3.6
8
+discover
9
+python-subunit>=0.0.18
10
+sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
11
+oslosphinx>=2.5.0 # Apache-2.0
12
+oslotest>=1.10.0 # Apache-2.0
13
+testrepository>=0.0.18
14
+testscenarios>=0.4
15
+testtools>=1.4.0
16
+
17
+flask>=0.10
18
+sqlalchemy>=1.0
19
+iniparse>=0.4
20
+paramiko>=1.15

+ 35
- 0
tox.ini View File

@@ -0,0 +1,35 @@
1
+[tox]
2
+minversion = 1.6
3
+envlist = py34,py27,pypy,pep8
4
+skipsdist = True
5
+
6
+[testenv]
7
+usedevelop = True
8
+install_command = pip install -U {opts} {packages}
9
+setenv =
10
+   VIRTUAL_ENV={envdir}
11
+deps = -r{toxinidir}/test-requirements.txt
12
+commands = python setup.py test --slowest --testr-args='{posargs}'
13
+
14
+[testenv:pep8]
15
+commands = flake8
16
+
17
+[testenv:venv]
18
+commands = {posargs}
19
+
20
+[testenv:cover]
21
+commands = python setup.py test --coverage --testr-args='{posargs}'
22
+
23
+[testenv:docs]
24
+commands = python setup.py build_sphinx
25
+
26
+[testenv:debug]
27
+commands = oslo_debug_helper {posargs}
28
+
29
+[flake8]
30
+# E123, E125 skipped as they are invalid PEP-8.
31
+
32
+show-source = True
33
+ignore = E123,E125
34
+builtins = _
35
+exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build

Loading…
Cancel
Save