Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test workin in Py2 and Py3 #88

Merged
merged 16 commits into from
Feb 15, 2022
Merged
12 changes: 10 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,26 @@ jobs:
matrix:
python-version:
- '2.7' # production
- '3.5'
- '3.8'
- '3.9'
mongodb-version:
- 2
name: Python ${{ matrix.python-version }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.7.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: test-rs
- name: Install dependencies
run: |
pip install https://files.pythonhosted.org/packages/3e/5c/2867e46f03d2fcc3d014a02eeb11ec55f3f8d9eddddcc5578ae8457f84f8/ERPpeek-1.7.1-py2.py3-none-any.whl
pip install pytest-cov pytest
./setup.py develop
- uses: BSFishy/pip-action@v1
with:
Expand All @@ -34,7 +42,7 @@ jobs:
git+https://github.com/som-energia/plantmeter.git@master
- name: Unit tests
run: |
coverage run --source generationkwh ./setup.py test
pytest
- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]
workflow_dispatch:
push:
tags:
- 'generationkwh-[0-9]+.[0-9]+.[0-9]+'

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

OpenERP module and library to manage [Som Energia]'s Generation kWh

[![Build Status](https://travis-ci.org/Som-Energia/somenergia-generationkwh.svg?branch=master)](https://travis-ci.org/Som-Energia/somenergia-generationkwh)

[![CI](https://github.com/Som-Energia/somenergia-generationkwh/actions/workflows/main.yml/badge.svg)](https://github.com/Som-Energia/somenergia-generationkwh/actions/workflows/main.yml)
[![CircleCI](https://circleci.com/gh/Som-Energia/somenergia-generationkwh.svg?style=svg)](https://circleci.com/gh/Som-Energia/somenergia-generationkwh)
[![Coverage Status](https://coveralls.io/repos/github/Som-Energia/somenergia-generationkwh/badge.svg)](https://coveralls.io/github/Som-Energia/somenergia-generationkwh)

Expand Down
12 changes: 12 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
[coverage:run]
relative_files = True
branch = True
omit =
**/*test.py
source: generationkwh

[tool:pytest]
addopts: --doctest-modules --cov=generationkwh
testpaths =
generationkwh

[nosetests]

verbosity=3
Expand Down
18 changes: 9 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import sys
readme = open("README.md").read()

py2 = sys.version_info<(3,)

setup(
name = "somenergia-generationkwh",
version = __version__,
Expand Down Expand Up @@ -32,24 +34,22 @@
install_requires=[
'setuptools>=20.4', # markdown readme
'yamlns>=0.6',
'tqdm',
'b2btest',
'lxml', # b2btest dependency, to remove
'wavefile', # b2btest dependency, to remove
'numpy',
'numpy<1.17' if py2 else 'numpy', # Py2
'decorator<5' if py2 else 'decorator', # Py2
'plantmeter',
'python-dateutil',
'decorator',
'python-dateutil',
'consolemsg>=0.3',
'somutils<1.7.1' if sys.version_info[0] < 3 else 'somutils', # gspread 4.0 not in Py2
'tqdm',
'mock<4', # TODO: remove indirect dependency for Py2
'rsa<4.6', # TODO: remove indirect dependency for Py2
'somutils',
'mock<4' if py2 else '', # TODO: remove indirect dependency for Py2
'pytest',
'pytest-cov<3' if py2 else 'pytest-cov', # Py2
# 'libfacturacioatr',
],
include_package_data = True,
test_suite = 'generationkwh',
# test_runner = 'colour_runner.runner.ColourTextTestRunner',
classifiers = [
'Programming Language :: Python',
'Programming Language :: Python :: 3',
Expand Down