Skip to content

Commit 3ab4d34

Browse files
committed
[IMP] Add CI integration
* Add travis * Add coveragerc * Update Readme to RST * Switch setup for automation * Add basic zpl2 init tests
1 parent 50af251 commit 3ab4d34

10 files changed

Lines changed: 308 additions & 20 deletions

File tree

.codeclimate.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
languages:
2+
Python: true

.coveragerc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[run]
2+
3+
branch = True
4+
5+
[report]
6+
7+
exclude_lines =
8+
pragma: no cover
9+
def __repr__
10+
if self.debug:
11+
raise NotImplementedError
12+
if __name__ == .__main__.:
13+
14+
ignore_errors = True
15+
16+
include =
17+
*/zpl2/*
18+
19+
omit =
20+
*/virtualenv/*
21+
*/tests/*
22+
setup.py
23+
*/__init__.py
24+
tests.py
25+
26+
[xml]
27+
28+
output = coverage.xml

.gitignore

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
48+
# Translations
49+
*.mo
50+
*.pot
51+
52+
# Django stuff:
53+
*.log
54+
local_settings.py
55+
56+
# Flask stuff:
57+
instance/
58+
.webassets-cache
59+
60+
# Scrapy stuff:
61+
.scrapy
62+
63+
# Sphinx documentation
64+
docs/_build/
65+
66+
# PyBuilder
67+
target/
68+
69+
# IPython Notebook
70+
.ipynb_checkpoints
71+
72+
# pyenv
73+
.python-version
74+
75+
# celery beat schedule file
76+
celerybeat-schedule
77+
78+
# dotenv
79+
.env
80+
81+
# virtualenv
82+
venv/
83+
ENV/
84+
85+
# Spyder project settings
86+
.spyderproject
87+
88+
# Rope project settings
89+
.ropeproject

.travis.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
addons:
2+
apt:
3+
packages:
4+
- expect-dev
5+
6+
language: python
7+
8+
python:
9+
- "2.7"
10+
11+
virtualenv:
12+
system_site_packages: true
13+
14+
env:
15+
global:
16+
- PROJECT="zpl2"
17+
- VERSION="1.0.0"
18+
- RELEASE="1.0.0"
19+
- AUTHOR_NAME="Sylvain Garancher"
20+
- PYPI_USER="syleam"
21+
# Generate the below per repo with the following:
22+
# travis encrypt 'PYPI_PASSWORD="$PYPI_PASSWORD"' -r LasLabs/repo-name
23+
# - secure: "$PYPI_TOKEN"
24+
# Generate the below per repo with the following:
25+
# travis encrypt 'GH_TOKEN="$GITHUB_TOKEN"' -r LasLabs/repo-name
26+
# - secure: "$GH_TOKEN"
27+
matrix:
28+
- TESTS="1"
29+
- LINT_CHECK="1"
30+
# - PYPI="1"
31+
# - DOCS="1"
32+
33+
install:
34+
- git clone --depth=1 https://github.com/LasLabs/python-quality-tools.git ${HOME}/python-quality-tools
35+
- export PATH=${HOME}/python-quality-tools/travis:${PATH}
36+
- travis_install
37+
38+
script:
39+
- travis_run
40+
41+
after_success:
42+
- travis_after_success

README.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
|License MIT| | |Build Status| | |Coveralls Status| | |Codecov Status| | |Code Climate|
2+
3+
======
4+
ZPL II
5+
======
6+
7+
This library allows you to generate ZPL II labels.
8+
9+
Usage
10+
=====
11+
12+
* `Read The API Documentation <https://syleam.github.io/python-zpl2>`_
13+
14+
Known Issues / Road Map
15+
=======================
16+
17+
- Add usage instructions
18+
19+
Credits
20+
=======
21+
22+
Contributors
23+
------------
24+
25+
* Sylvain Garancher <sylvain.garancher@syleam.fr>
26+
* Dave Lasley <dave@laslabs.com>
27+
28+
.. |Build Status| image:: https://api.travis-ci.org/syleam/python-zpl2.svg?branch=master
29+
:target: https://travis-ci.org/syleam/python-zpl2
30+
.. |Coveralls Status| image:: https://coveralls.io/repos/syleam/python-zpl2/badge.svg?branch=master
31+
:target: https://coveralls.io/r/syleam/python-zpl2?branch=master
32+
.. |Codecov Status| image:: https://codecov.io/gh/syleam/python-zpl2/branch/master/graph/badge.svg
33+
:target: https://codecov.io/gh/syleam/python-zpl2
34+
.. |Code Climate| image:: https://codeclimate.com/github/syleam/python-zpl2/badges/gpa.svg
35+
:target: https://codeclimate.com/github/syleam/python-zpl2
36+
.. |License AGPL-3| image:: https://img.shields.io/badge/license-AGPL--3-blue.svg
37+
:target: https://www.gnu.org/licenses/agpl-3.0
38+
:alt: License: AGPL-3

README.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

setup.py

Lines changed: 87 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,88 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2016 SYLEAM (<http://www.syleam.fr>)
3-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4-
5-
from distutils.core import setup
6-
7-
setup(
8-
name='zpl2',
9-
version='1.0',
10-
author='Sylvain Garancher',
11-
author_email='sylvain.garancher@syleam.fr',
12-
py_modules=['zpl2'],
13-
license='LICENSE.txt',
14-
description='Python library that generates ZPL II labels',
15-
long_description=open('README.txt').read(),
16-
)
2+
# Copyright 2016-TODAY LasLabs Inc.
3+
# License MIT (https://opensource.org/licenses/MIT).
4+
5+
from setuptools import Command, setup
6+
from setuptools import find_packages
7+
from unittest import TestLoader, TextTestRunner
8+
9+
from os import environ, path
10+
11+
12+
PROJECT = 'python-zpl2'
13+
SHORT_DESC = 'Python library that generates ZPL II labels'
14+
README_FILE = 'README.rst'
15+
16+
CLASSIFIERS = [
17+
'Development Status :: 4 - Beta',
18+
'Environment :: Console',
19+
'Intended Audience :: Developers',
20+
'License :: OSI Approved :: AGPL-3 License',
21+
'Programming Language :: Python',
22+
'Topic :: Software Development :: Libraries :: Python Modules',
23+
]
24+
25+
version = environ.get('RELEASE') or environ.get('VERSION') or '0.0.0'
26+
27+
if environ.get('TRAVIS_BUILD_NUMBER'):
28+
version += 'b%s' % environ.get('TRAVIS_BUILD_NUMBER')
29+
30+
31+
setup_vals = {
32+
'name': PROJECT,
33+
'author': 'Sylvain Garancher',
34+
'author_email': 'sylvain.garancher@syleam.fr',
35+
'description': SHORT_DESC,
36+
'url': 'https://laslabs.github.io/%s' % PROJECT,
37+
'download_url': 'https://github.com/LasLabs/%s' % PROJECT,
38+
'license': 'MIT',
39+
'classifiers': CLASSIFIERS,
40+
'version': version,
41+
}
42+
43+
44+
if path.exists(README_FILE):
45+
with open(README_FILE) as fh:
46+
setup_vals['long_description'] = fh.read()
47+
48+
49+
install_requires = []
50+
if path.exists('requirements.txt'):
51+
with open('requirements.txt') as fh:
52+
install_requires = fh.read().splitlines()
53+
54+
55+
class FailTestException(Exception):
56+
""" It provides a failing build """
57+
pass
58+
59+
60+
class Tests(Command):
61+
62+
user_options = [] # < For Command API compatibility
63+
64+
def initialize_options(self, ):
65+
pass
66+
67+
def finalize_options(self, ):
68+
pass
69+
70+
def run(self, ):
71+
loader = TestLoader()
72+
tests = loader.discover('.', 'test_*.py')
73+
t = TextTestRunner(verbosity=1)
74+
res = t.run(tests)
75+
if not res.wasSuccessful():
76+
raise FailTestException()
77+
78+
79+
if __name__ == "__main__":
80+
setup(
81+
packages=find_packages(exclude=('tests')),
82+
cmdclass={'test': Tests},
83+
tests_require=[
84+
'mock',
85+
],
86+
install_requires=install_requires,
87+
**setup_vals
88+
)
File renamed without changes.

zpl2/tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# -*- coding: utf-8 -*-

zpl2/tests/test_zpl2.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2017 LasLabs Inc.
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
import unittest
6+
7+
from zpl2 import Zpl2
8+
9+
10+
class TestZpl2(unittest.TestCase):
11+
12+
def setUp(self):
13+
self.zpl = Zpl2()
14+
15+
def test_init_encoding(self):
16+
""" It should set encoding """
17+
self.assertEqual(self.zpl.encoding, 'utf-8')
18+
19+
def test_init_buffer(self):
20+
""" It should set the buffer. """
21+
self.assertEqual(self.zpl._buffer, [])

0 commit comments

Comments
 (0)