From d3e4d57eab8dfddeffd9911b72100bdef6fde205 Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Fri, 17 Feb 2017 14:56:36 -0800 Subject: [PATCH 1/2] [IMP] Add CI integration * Add travis * Add coveragerc * Update Readme to RST * Switch setup for automation * Add basic zpl2 init tests --- .codeclimate.yml | 2 + .coveragerc | 28 ++++++++++ .gitignore | 89 +++++++++++++++++++++++++++++++ .travis.yml | 42 +++++++++++++++ README.rst | 38 ++++++++++++++ README.txt | 5 -- setup.py | 102 ++++++++++++++++++++++++++++++------ zpl2.py => zpl2/__init__.py | 0 zpl2/tests/__init__.py | 1 + zpl2/tests/test_zpl2.py | 21 ++++++++ 10 files changed, 308 insertions(+), 20 deletions(-) create mode 100755 .codeclimate.yml create mode 100644 .coveragerc create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 README.rst delete mode 100644 README.txt rename zpl2.py => zpl2/__init__.py (100%) create mode 100644 zpl2/tests/__init__.py create mode 100644 zpl2/tests/test_zpl2.py diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100755 index 0000000..ad81546 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,2 @@ +languages: + Python: true diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..2a132aa --- /dev/null +++ b/.coveragerc @@ -0,0 +1,28 @@ +[run] + +branch = True + +[report] + +exclude_lines = + pragma: no cover + def __repr__ + if self.debug: + raise NotImplementedError + if __name__ == .__main__.: + +ignore_errors = True + +include = + */zpl2/* + +omit = + */virtualenv/* + */tests/* + setup.py + */__init__.py + tests.py + +[xml] + +output = coverage.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72364f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,89 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# IPython Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# dotenv +.env + +# virtualenv +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..345d58a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +addons: + apt: + packages: + - expect-dev + +language: python + +python: + - "2.7" + +virtualenv: + system_site_packages: true + +env: + global: + - PROJECT="zpl2" + - VERSION="1.0.0" + - RELEASE="1.0.0" + - AUTHOR_NAME="Sylvain Garancher" + - PYPI_USER="syleam" + # Generate the below per repo with the following: + # travis encrypt 'PYPI_PASSWORD="$PYPI_PASSWORD"' -r LasLabs/repo-name + # - secure: "$PYPI_TOKEN" + # Generate the below per repo with the following: + # travis encrypt 'GH_TOKEN="$GITHUB_TOKEN"' -r LasLabs/repo-name + # - secure: "$GH_TOKEN" + matrix: + - TESTS="1" + - LINT_CHECK="1" + # - PYPI="1" + # - DOCS="1" + +install: + - git clone --depth=1 https://github.com/LasLabs/python-quality-tools.git ${HOME}/python-quality-tools + - export PATH=${HOME}/python-quality-tools/travis:${PATH} + - travis_install + +script: + - travis_run + +after_success: + - travis_after_success diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..5c32300 --- /dev/null +++ b/README.rst @@ -0,0 +1,38 @@ +|License MIT| | |Build Status| | |Coveralls Status| | |Codecov Status| | |Code Climate| + +====== +ZPL II +====== + +This library allows you to generate ZPL II labels. + +Usage +===== + +* `Read The API Documentation `_ + +Known Issues / Road Map +======================= + +- Add usage instructions + +Credits +======= + +Contributors +------------ + +* Sylvain Garancher +* Dave Lasley + +.. |Build Status| image:: https://api.travis-ci.org/syleam/python-zpl2.svg?branch=master + :target: https://travis-ci.org/syleam/python-zpl2 +.. |Coveralls Status| image:: https://coveralls.io/repos/syleam/python-zpl2/badge.svg?branch=master + :target: https://coveralls.io/r/syleam/python-zpl2?branch=master +.. |Codecov Status| image:: https://codecov.io/gh/syleam/python-zpl2/branch/master/graph/badge.svg + :target: https://codecov.io/gh/syleam/python-zpl2 +.. |Code Climate| image:: https://codeclimate.com/github/syleam/python-zpl2/badges/gpa.svg + :target: https://codeclimate.com/github/syleam/python-zpl2 +.. |License AGPL-3| image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0 + :alt: License: AGPL-3 diff --git a/README.txt b/README.txt deleted file mode 100644 index 0984c87..0000000 --- a/README.txt +++ /dev/null @@ -1,5 +0,0 @@ -====== -ZPL II -====== - -This library allows you to generate ZPL II labels. diff --git a/setup.py b/setup.py index 99b759a..3d906e1 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,88 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2016 SYLEAM () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from distutils.core import setup - -setup( - name='zpl2', - version='1.0', - author='Sylvain Garancher', - author_email='sylvain.garancher@syleam.fr', - py_modules=['zpl2'], - license='LICENSE.txt', - description='Python library that generates ZPL II labels', - long_description=open('README.txt').read(), -) +# Copyright 2016-TODAY LasLabs Inc. +# License MIT (https://opensource.org/licenses/MIT). + +from setuptools import Command, setup +from setuptools import find_packages +from unittest import TestLoader, TextTestRunner + +from os import environ, path + + +PROJECT = 'python-zpl2' +SHORT_DESC = 'Python library that generates ZPL II labels' +README_FILE = 'README.rst' + +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: AGPL-3 License', + 'Programming Language :: Python', + 'Topic :: Software Development :: Libraries :: Python Modules', +] + +version = environ.get('RELEASE') or environ.get('VERSION') or '0.0.0' + +if environ.get('TRAVIS_BUILD_NUMBER'): + version += 'b%s' % environ.get('TRAVIS_BUILD_NUMBER') + + +setup_vals = { + 'name': PROJECT, + 'author': 'Sylvain Garancher', + 'author_email': 'sylvain.garancher@syleam.fr', + 'description': SHORT_DESC, + 'url': 'https://syleam.github.io/%s' % PROJECT, + 'download_url': 'https://github.com/syleam/%s' % PROJECT, + 'license': 'AGPL-3', + 'classifiers': CLASSIFIERS, + 'version': version, +} + + +if path.exists(README_FILE): + with open(README_FILE) as fh: + setup_vals['long_description'] = fh.read() + + +install_requires = [] +if path.exists('requirements.txt'): + with open('requirements.txt') as fh: + install_requires = fh.read().splitlines() + + +class FailTestException(Exception): + """ It provides a failing build """ + pass + + +class Tests(Command): + + user_options = [] # < For Command API compatibility + + def initialize_options(self, ): + pass + + def finalize_options(self, ): + pass + + def run(self, ): + loader = TestLoader() + tests = loader.discover('.', 'test_*.py') + t = TextTestRunner(verbosity=1) + res = t.run(tests) + if not res.wasSuccessful(): + raise FailTestException() + + +if __name__ == "__main__": + setup( + packages=find_packages(exclude=('tests')), + cmdclass={'test': Tests}, + tests_require=[ + 'mock', + ], + install_requires=install_requires, + **setup_vals + ) diff --git a/zpl2.py b/zpl2/__init__.py similarity index 100% rename from zpl2.py rename to zpl2/__init__.py diff --git a/zpl2/tests/__init__.py b/zpl2/tests/__init__.py new file mode 100644 index 0000000..40a96af --- /dev/null +++ b/zpl2/tests/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/zpl2/tests/test_zpl2.py b/zpl2/tests/test_zpl2.py new file mode 100644 index 0000000..26ad2ff --- /dev/null +++ b/zpl2/tests/test_zpl2.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import unittest + +from zpl2 import Zpl2 + + +class TestZpl2(unittest.TestCase): + + def setUp(self): + self.zpl = Zpl2() + + def test_init_encoding(self): + """ It should set encoding """ + self.assertEqual(self.zpl.encoding, 'utf-8') + + def test_init_buffer(self): + """ It should set the buffer. """ + self.assertEqual(self.zpl._buffer, []) From e6e88f51b107ae0a35a37369f94ddd269d3f999a Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Wed, 13 Sep 2017 08:38:18 -0700 Subject: [PATCH 2/2] Remove PyPi & Unnecessary from coveragerc --- .coveragerc | 9 --------- .travis.yml | 7 +------ 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/.coveragerc b/.coveragerc index 2a132aa..30e31a2 100644 --- a/.coveragerc +++ b/.coveragerc @@ -7,9 +7,6 @@ branch = True exclude_lines = pragma: no cover def __repr__ - if self.debug: - raise NotImplementedError - if __name__ == .__main__.: ignore_errors = True @@ -17,12 +14,6 @@ include = */zpl2/* omit = - */virtualenv/* */tests/* setup.py - */__init__.py tests.py - -[xml] - -output = coverage.xml diff --git a/.travis.yml b/.travis.yml index 345d58a..067d165 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,18 +16,13 @@ env: - PROJECT="zpl2" - VERSION="1.0.0" - RELEASE="1.0.0" - - AUTHOR_NAME="Sylvain Garancher" - - PYPI_USER="syleam" - # Generate the below per repo with the following: - # travis encrypt 'PYPI_PASSWORD="$PYPI_PASSWORD"' -r LasLabs/repo-name - # - secure: "$PYPI_TOKEN" + - AUTHOR_NAME="SYLEAM" # Generate the below per repo with the following: # travis encrypt 'GH_TOKEN="$GITHUB_TOKEN"' -r LasLabs/repo-name # - secure: "$GH_TOKEN" matrix: - TESTS="1" - LINT_CHECK="1" - # - PYPI="1" # - DOCS="1" install: