Clean up build and write a README

This commit is contained in:
Monty Taylor 2014-07-22 12:32:44 -07:00
parent ad90b40f9b
commit 77ae302213
9 changed files with 108 additions and 30 deletions

View File

@ -12,6 +12,6 @@ the workflow documented at:
Pull requests submitted through GitHub will be ignored.
Bugs should be filed on Launchpad, not GitHub:
Bugs should be filed on Storyboard, not GitHub:
https://bugs.launchpad.net/dox
https://storyboard.openstack.org

View File

@ -1,13 +1,71 @@
===============================
===
dox
===============================
===
dox runs tox descriptions in docker containers
dox is a tool for using docker containers to run local tests, inspired by
tox and virtualenv for python. There are two elements to its configuration:
* Free software: Apache license
* Documentation: http://docs.openstack.org/developer/dox
* What commands should be run?
Features
* In what image should they be run?
If there is a dox.yml file, you're set. You want a docker section to specify
what image to use and a testenv section to specify the commands to run. You
win.
You might either not be willing to commit to dox as a way of life yet, or you
may want to use dox in a project that similarly has not done so.
What commands should be run
---------------------------
dox.yml wins.
If there is a tox.ini file, the commands specified in the base [testenv]
will be used.
If there is a .travis.yml file, the script section will be used.
If there are none of those things, dox will do its best to infer what
should be done. Examining the directory can often provide hints if you
haven't been too clever. For instance, if you have a Gruntfile, you probably
want to run grunt. If you have a Makefile, then make && make test is probably
your bag. If you have a Makefile.am, you probably want to run autotools first.
If you have a setup.py file, python setup.py test is a likely choice (although
in that case, you probably haven't done it right because setuptools support
for this is quite awful.)
After all of that, if we still can't figure out what you want - it's probably
easiest to just edit a file called dox.yml and put in a section telling us
what to do.
In what image should they be run
--------------------------------
Again, dox.yml wins, and thanks for making things easy!
If there is a tox.ini file, and it contains a [docker] section, the value in
"image" will be used::
[docker]
image=ubuntu:trusty
If there is not an image key in the docker section but there is a Dockerfile
in the repo, an image will be built using the Dockerfile and the test
commands will be run inside of the image.
Additional information
----------------------
Regardless, dox will mount the current source dir as a volume at `/src` in
the container and will run commands in that context.
dox will attempt to reuse containers. Since the source is bind-mounted into
the container, things that might be expensive like copying source dirs or
re-installing the source into the system can be minimized.
Advanced
--------
* TODO
The dox.yml file can reference multiple images, such as if your test suite
needs things like a MySQL server. At least, that's the theory. This is not
yet implemented.

30
dox/cmd.py Normal file
View File

@ -0,0 +1,30 @@
import docker
import docker.unixconn
from docker.unixconn import unixconn
import requests
def _get_docker_api_version():
session = requests.Session()
session.mount(
"http+unix://",
docker.unixconn.unixconn.UnixAdapter(
"http+unix://var/run/docker.sock", 60))
response = session.get('/version')
try:
api_version = response.json()['ApiVersion']
except KeyError:
# For now, fall back to 1.10 as a safety net
api_version = '1.10'
return api_version
def _version_string_to_tuple(version):
return tuple([int(f) for f in version.split('.')])
class Dox(object):
def __init__(self):
self.client = docker.Client(version=_get_docker_api_version())

View File

@ -1,7 +0,0 @@
[DEFAULT]
# The list of modules to copy from oslo-incubator.git
module=install_venv_common
# The base module to hold the copy of openstack.common
base=dox

View File

@ -1,2 +1,3 @@
pbr>=0.5.21,<1.0
Babel>=0.9.6
docker-py

View File

@ -19,9 +19,9 @@ classifier =
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
[files]
packages =
dox
[entry_points]
console_scripts =
dox = dox.cmd:main
[build_sphinx]
source-dir = doc/source
@ -43,4 +43,4 @@ input_file = dox/locale/dox.pot
[extract_messages]
keywords = _ gettext ngettext l_ lazy_gettext
mapping_file = babel.cfg
output_file = dox/locale/dox.pot
output_file = dox/locale/dox.pot

View File

@ -18,5 +18,5 @@
import setuptools
setuptools.setup(
setup_requires=['pbr>=0.5.21,<1.0'],
pbr=True)
setup_requires=['pbr'],
pbr=True)

View File

@ -8,4 +8,4 @@ sphinx>=1.1.2
oslo.sphinx
testrepository>=0.0.17
testscenarios>=0.4,<0.5
testtools>=0.9.32
testtools>=0.9.32

View File

@ -25,10 +25,6 @@ commands = {posargs}
commands = python setup.py testr --coverage --testr-args='{posargs}'
[flake8]
# H803 skipped on purpose per list discussion.
# E123, E125 skipped as they are invalid PEP-8.
show-source = True
ignore = E123,E125,H803
builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build