Skip to content

Commit

Permalink
[IMP] Add CI integration
Browse files Browse the repository at this point in the history
* Add travis
* Add coveragerc
* Update Readme to RST
* Switch setup for automation
* Add basic zpl2 init tests
  • Loading branch information
lasley committed Feb 18, 2017
1 parent 50af251 commit d3e4d57
Show file tree
Hide file tree
Showing 10 changed files with 308 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
languages:
Python: true
28 changes: 28 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -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
89 changes: 89 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://syleam.github.io/python-zpl2>`_

Known Issues / Road Map
=======================

- Add usage instructions

Credits
=======

Contributors
------------

* Sylvain Garancher <[email protected]>
* Dave Lasley <[email protected]>

.. |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
5 changes: 0 additions & 5 deletions README.txt

This file was deleted.

102 changes: 87 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,88 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2016 SYLEAM (<http://www.syleam.fr>)
# 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='[email protected]',
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': '[email protected]',
'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
)
File renamed without changes.
1 change: 1 addition & 0 deletions zpl2/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
21 changes: 21 additions & 0 deletions zpl2/tests/test_zpl2.py
Original file line number Diff line number Diff line change
@@ -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, [])

0 comments on commit d3e4d57

Please sign in to comment.