diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..3f1df76 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,36 @@ +name: Coverage +on: + pull_request: + push: + branches: + - 'master' +jobs: + check_coverage: + runs-on: ubuntu-latest + name: Check coverage + permissions: + pull-requests: write + contents: write + steps: + - uses: actions/checkout@v3 + - name: Set up Python + id: setup-python + uses: actions/setup-python@v4 + with: + python-version: 3.9 + - name: Install deps + run: | + python -m pip install --upgrade pip + python -m pip install .[tests] + - name: Launch tests & generate report + run: pytest + - name: Coverage comment + id: coverage_comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ github.token }} + - name: Store Pull Request comment to be posted + uses: actions/upload-artifact@v3 + with: + name: python-coverage-comment-action + path: python-coverage-comment-action.txt diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..31cb133 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,33 @@ +# This workflow will install Python dependencies, and run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Lint +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] +jobs: + lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install .[tests] + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 src tests --count --exit-zero --max-complexity=10 --statistics diff --git a/.gitignore b/.gitignore index 3d08b2f..e37a7e7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ /.idea/ /dist/ /.eggs/ -/tests/ /docs/_build/ __pycache__ /build/ diff --git a/LICENSE b/LICENSE index 8864d4a..b1de87f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,29 @@ -MIT License +BSD 3-Clause License -Copyright (c) 2017 +Copyright (c) 2019, Cédric Dumay +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.rst b/README.rst index 391caff..1c41c04 100644 --- a/README.rst +++ b/README.rst @@ -7,7 +7,6 @@ :target: https://travis-ci.org/cdumay/kser :alt: Latest version - .. image:: https://readthedocs.org/projects/kser/badge/?version=latest :target: http://kser.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status @@ -15,6 +14,10 @@ .. image:: https://img.shields.io/badge/license-MIT-blue.svg :target: https://github.com/cdumay/kser/blob/master/LICENSE +.. image:: https://raw.githubusercontent.com/cdumay/kser/python-coverage-comment-action-data/badge.svg + :target: https://htmlpreview.github.io/?https://github.com/cdumay/kser/blob/python-coverage-comment-action-data/htmlcov/index.html + :alt: Coverage badge + ============================== Kafka serialize python library ============================== @@ -154,4 +157,4 @@ Other links License ======= -Licensed under MIT license (`LICENSE <./LICENSE>`_ or http://opensource.org/licenses/MIT) +Licensed under `BSD 3-Clause License <./LICENSE>`_ or https://opensource.org/licenses/BSD-3-Clause. \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..63a265b --- /dev/null +++ b/setup.cfg @@ -0,0 +1,12 @@ +[tool:pytest] +addopts = + --cov=src --cov-report term-missing --cov-branch --cov-report xml --cov-report term + --cov=codebase.code -vv --strict-markers -rfE + +pythonpath = src + +testpaths = + tests + +[coverage:run] +relative_files = true \ No newline at end of file diff --git a/setup.py b/setup.py index 6511e23..eadfddd 100755 --- a/setup.py +++ b/setup.py @@ -28,6 +28,11 @@ 'http': ['cdumay-rest-client>=0.1'], 'pykafka': ['kafka-python'], 'prometheus': ['prometheus_client'], + "tests": [ + "flake8", + "pytest", + "pytest-cov", + ] }, entry_points=""" """, diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..a0f7a3a --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,8 @@ +# !/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +.. codeauthor:: Cédric Dumay + + +""" diff --git a/tests/kser/__init__.py b/tests/kser/__init__.py new file mode 100644 index 0000000..b143d98 --- /dev/null +++ b/tests/kser/__init__.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +.. codeauthor:: Cédric Dumay + + +""" diff --git a/tests/kser/test_install.py b/tests/kser/test_install.py new file mode 100644 index 0000000..f9dc810 --- /dev/null +++ b/tests/kser/test_install.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +.. codeauthor:: Cédric Dumay + + +""" + +import unittest + +import pkg_resources + + +class InstallTest(unittest.TestCase): + """Test install""" + + def test_install(self): + """Test module is installed""" + self.assertIn('kser', [x.key for x in pkg_resources.working_set])