Skip to content

Commit 7add44f

Browse files
committed
Implemented TOX test environment added docs and unit tests
This is a huge commit where only test environment was meant to be added, but original functions needed to be changed because originals were hard to test and would require mocking a file. Since that would add complexity of otherwise simple plugin rewrite was easier. Adding also to travis.yml and renaming package to mlx.warnings instead of probably frequently used ci.
1 parent 002afa2 commit 7add44f

17 files changed

+460
-69
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ celerybeat-schedule
8181
# virtualenv
8282
venv/
8383
ENV/
84+
bin/
85+
include/
86+
local/
87+
pip-selfcheck.json
8488

8589
# Spyder project settings
8690
.spyderproject

.travis.yml

+53-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,57 @@
11
language: python
2+
sudo: false
3+
cache: pip
4+
env:
5+
global:
6+
- LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
7+
- SEGFAULT_SIGNALS=all
8+
matrix:
9+
- TOXENV=check
10+
- TOXENV=docs
11+
matrix:
12+
include:
13+
- python: '2.7'
14+
env:
15+
- TOXENV=py27,report,coveralls,codecov
16+
- python: '3.3'
17+
env:
18+
- TOXENV=py33,report,coveralls,codecov
19+
- python: '3.4'
20+
env:
21+
- TOXENV=py34,report,coveralls,codecov
22+
- python: '3.5'
23+
env:
24+
- TOXENV=py35,report,coveralls,codecov
25+
- python: '3.6'
26+
env:
27+
- TOXENV=py36,report,coveralls,codecov
28+
- python: 'pypy-5.4'
29+
env:
30+
- TOXENV=pypy,report,coveralls,codecov
231

3-
script: ls
32+
before_install:
33+
- python --version
34+
- uname -a
35+
- lsb_release -a
36+
37+
install:
38+
- pip install tox
39+
- virtualenv --version
40+
- easy_install --version
41+
- pip --version
42+
- tox --version
43+
44+
script:
45+
- tox -v
46+
47+
after_failure:
48+
- more .tox/log/* | cat
49+
- more .tox/*/log/* | cat
50+
51+
notifications:
52+
email:
53+
on_success: never
54+
on_failure: always
455

556
deploy:
657
# test pypi
@@ -21,4 +72,4 @@ deploy:
2172
secure: cKCBgEUOSUnlPbOxHCrXENlVgdMGnjNC+7nnutp/1xF8VEDF3aj9Br4u5LKrAYs0sm0AvnCyjhPvfKGPwyRDdfGBjoG06G+L+1hcfpgBlItmdSBqB8RxMm2B76si1ZlVI9gC58hlk/agFr2vik/mLXsH23rafB/2UwfB3ItTTx2J14xC5jlaqYR/srMJUi8YO5z6mGGLokfcz0KhYUHegOna38UcARM8rkAC2Je0xrPKZMlCoTI84dqwnFPW4zn3g/B5s3s18gmZu4fE4+J1g0PNMvxhbDP1TIBzPSWXLBv+YPSKrIT6+Q4R/kfDJFzLn3SmDDnNOpD/OC8ssqVJOcQL3HhKQ7EAcxX9W+/Rt7mIpdJdDXohiPrBl9EdRYbhB+KiPeo/dekAV6loUP/8cHuEgjcW/gE8t+HIqWsa5SO9yK7Sz8Ym+0ENdzS1df0iPOj2ebR3kb1iwINdFi7zIG6Utvlf7w1A2Qtx1xfI2+woPU+GOgQrpwdw64Wl1uo4l0kqTpFkytIG7BEVWC+zPPzqddi+3Ulf9AkWSjNDTqYafxZ9oqBJ5q7WPH8zyPQHotcHbnziTAnv7qRa+CTFLeME/KXNT8egToLK75G367lANTFIhMm8eSDS7wAxFWHacq8j68wNb38Yj1Rv1WMHQh14sxOkzQ4hVEV0xYY7Bj8=
2273
on:
2374
branch: master
24-
tags: true
75+
tags: true

MANIFEST.in

+15
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1+
graft docs
2+
graft src
3+
graft tests
4+
15
# Include the readme file
26
include README.rst
7+
include LICENSE
8+
9+
include tox.ini .travis.yml
10+
11+
global-exclude *.py[cod] __pycache__ *.so *.dylib
12+
13+
# added by check_manifest.py
14+
include NOTICE
15+
16+
# added by check_manifest.py
17+
recursive-include ci *.py

ci/__init__.py

-1
This file was deleted.

ci/bootstrap.py

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
from __future__ import absolute_import, print_function, unicode_literals
4+
5+
import os
6+
import sys
7+
from os.path import abspath
8+
from os.path import dirname
9+
from os.path import exists
10+
from os.path import join
11+
12+
13+
if __name__ == "__main__":
14+
base_path = dirname(dirname(abspath(__file__)))
15+
print("Project path: {0}".format(base_path))
16+
env_path = join(base_path, ".tox", "bootstrap")
17+
if sys.platform == "win32":
18+
bin_path = join(env_path, "Scripts")
19+
else:
20+
bin_path = join(env_path, "bin")
21+
if not exists(env_path):
22+
import subprocess
23+
24+
print("Making bootstrap env in: {0} ...".format(env_path))
25+
try:
26+
subprocess.check_call(["virtualenv", env_path])
27+
except subprocess.CalledProcessError:
28+
subprocess.check_call([sys.executable, "-m", "virtualenv", env_path])
29+
print("Installing `jinja2` into bootstrap environment...")
30+
subprocess.check_call([join(bin_path, "pip"), "install", "jinja2"])
31+
activate = join(bin_path, "activate_this.py")
32+
# noinspection PyCompatibility
33+
exec(compile(open(activate, "rb").read(), activate, "exec"), dict(__file__=activate))
34+
35+
import jinja2
36+
37+
import subprocess
38+
39+
jinja = jinja2.Environment(
40+
loader=jinja2.FileSystemLoader(join(base_path, "ci", "templates")),
41+
trim_blocks=True,
42+
lstrip_blocks=True,
43+
keep_trailing_newline=True
44+
)
45+
46+
tox_environments = [
47+
line.strip()
48+
# WARNING: 'tox' must be installed globally or in the project's virtualenv
49+
for line in subprocess.check_output(['tox', '--listenvs'], universal_newlines=True).splitlines()
50+
]
51+
tox_environments = [line for line in tox_environments if line not in ['clean', 'report', 'docs', 'check']]
52+
53+
for name in os.listdir(join("ci", "templates")):
54+
with open(join(base_path, name), "w") as fh:
55+
fh.write(jinja.get_template(name).render(tox_environments=tox_environments))
56+
print("Wrote {}".format(name))
57+
print("DONE.")

ci/warnings.py

-60
This file was deleted.

docs/conf.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
import os
5+
6+
7+
extensions = [
8+
'sphinx.ext.autodoc',
9+
'sphinx.ext.autosummary',
10+
'sphinx.ext.coverage',
11+
'sphinx.ext.doctest',
12+
'sphinx.ext.extlinks',
13+
'sphinx.ext.ifconfig',
14+
'sphinx.ext.napoleon',
15+
'sphinx.ext.todo',
16+
'sphinx.ext.viewcode',
17+
]
18+
if os.getenv('SPELLCHECK'):
19+
extensions += 'sphinxcontrib.spelling',
20+
spelling_show_suggestions = True
21+
spelling_lang = 'en_US'
22+
23+
source_suffix = '.rst'
24+
master_doc = 'index'
25+
project = 'warning-plugin'
26+
year = '2017'
27+
author = 'Bavo Van Achte'
28+
copyright = '{0}, {1}'.format(year, author)
29+
version = release = '0.1.0'
30+
31+
pygments_style = 'trac'
32+
templates_path = ['.']
33+
extlinks = {
34+
'issue': ('https://github.com/melexis/warnings-plugin/issues/%s', '#'),
35+
'pr': ('https://github.com/melexis/warnings-plugin/pull/%s', 'PR #'),
36+
}
37+
import sphinx_py3doc_enhanced_theme
38+
html_theme = "sphinx_py3doc_enhanced_theme"
39+
html_theme_path = [sphinx_py3doc_enhanced_theme.get_html_theme_path()]
40+
html_theme_options = {
41+
'githuburl': 'https://github.com/melexis/warnings-plugin'
42+
}
43+
44+
html_use_smartypants = True
45+
html_last_updated_fmt = '%b %d, %Y'
46+
html_split_index = False
47+
html_sidebars = {
48+
'**': ['searchbox.html', 'globaltoc.html', 'sourcelink.html'],
49+
}
50+
html_short_title = '%s-%s' % (project, version)
51+
52+
napoleon_use_ivar = True
53+
napoleon_use_rtype = False
54+
napoleon_use_param = False

docs/index.rst

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
========
2+
Contents
3+
========
4+
5+
.. toctree::
6+
:maxdepth: 2
7+
8+
readme
9+
installation
10+
usage
11+
reference/index
12+
contributing
13+
authors
14+
changelog
15+
16+
Indices and tables
17+
==================
18+
19+
* :ref:`genindex`
20+
* :ref:`modindex`
21+
* :ref:`search`

docs/readme.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. include:: ../README.rst
2+

docs/requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sphinx>=1.3
2+
sphinx-py3doc-enhanced-theme
3+
-e .

setup.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ description-file = README.rst
33

44
[bdist_wheel]
55
universal=1
6+
7+
[tool:pytest]
8+
norecursedirs= .tox

setup.py

+42-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
from setuptools import setup, find_packages
1+
import io
2+
from glob import glob
3+
from os.path import basename, dirname, join, splitext
4+
5+
from setuptools import find_packages, setup
26

37
PROJECT_URL = 'https://github.com/melexis/warnings-plugin'
48
VERSION = '0.0.2'
59

10+
11+
def read(*names, **kwargs):
12+
return io.open(
13+
join(dirname(__file__), *names),
14+
encoding=kwargs.get('encoding', 'utf8')
15+
).read()
16+
17+
618
setup(
7-
name='warnings-plugin',
19+
name='warnings',
820
version=VERSION,
921
url=PROJECT_URL,
1022
download_url=PROJECT_URL + '/tarball/' + VERSION,
@@ -14,11 +26,35 @@
1426
description='Command-line alternative for https://github.com/jenkinsci/warnings-plugin. Useable with plugin-less CI systems.',
1527
long_description=open("README.rst").read(),
1628
zip_safe=False,
17-
classifiers=[],
1829
platforms='any',
19-
packages=find_packages(),
30+
packages=find_packages('src'),
31+
package_dir={'': 'src'},
32+
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
2033
include_package_data=True,
2134
install_requires=None,
22-
namespace_packages=['ci'],
23-
keywords = ['Gitlab CI', 'warnings','CI'],
35+
namespace_packages=['mlx'],
36+
classifiers=[
37+
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
38+
'Development Status :: 5 - Production/Stable',
39+
'Intended Audience :: Developers',
40+
'License :: OSI Approved :: Apache2 License',
41+
'Operating System :: Unix',
42+
'Operating System :: POSIX',
43+
'Operating System :: Microsoft :: Windows',
44+
'Programming Language :: Python',
45+
'Programming Language :: Python :: 2.7',
46+
'Programming Language :: Python :: 3',
47+
'Programming Language :: Python :: 3.3',
48+
'Programming Language :: Python :: 3.4',
49+
'Programming Language :: Python :: 3.5',
50+
'Programming Language :: Python :: 3.6',
51+
# 'Programming Language :: Python :: Implementation :: CPython',
52+
# 'Programming Language :: Python :: Implementation :: PyPy',
53+
# uncomment if you test on these interpreters:
54+
# 'Programming Language :: Python :: Implementation :: IronPython',
55+
# 'Programming Language :: Python :: Implementation :: Jython',
56+
# 'Programming Language :: Python :: Implementation :: Stackless',
57+
'Topic :: Utilities',
58+
],
59+
keywords = ['Gitlab CI', 'warnings', 'CI'],
2460
)

src/mlx/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__import__('pkg_resources').declare_namespace(__name__)
2+

src/mlx/__main__.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""
2+
Entrypoint module, in case you use `python -mnameless`.
3+
4+
5+
Why does this file exist, and why __main__? For more info, read:
6+
7+
- https://www.python.org/dev/peps/pep-0338/
8+
- https://docs.python.org/2/using/cmdline.html#cmdoption-m
9+
- https://docs.python.org/3/using/cmdline.html#cmdoption-m
10+
"""
11+
from mlx.warnings import main
12+
13+
if __name__ == "__main__":
14+
main()

0 commit comments

Comments
 (0)