Generate setup.py from generate-setup nankit and add tox and Jenkisfile

This commit is contained in:
Raimon Esteve 2020-05-19 09:25:53 +02:00
parent 5d2b170b19
commit 85d2e8b990
3 changed files with 126 additions and 51 deletions

50
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,50 @@
pipeline {
agent {
docker {
image 'python:3.7'
args '--user 0:0'
}
}
stages {
stage('setup') {
steps {
sh 'pip install tox coverage'
}
}
stage('test'){
steps {
sh 'tox'
}
}
stage("Extract test results") {
steps{
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', conditionalCoverageTargets: '70, 0, 0', enableNewApi: true, failUnhealthy: false, failUnstable: false, lineCoverageTargets: '80, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '80, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
}
}
}
post {
changed {
emailext subject: '$DEFAULT_SUBJECT',
body: '$DEFAULT_CONTENT',
recipientProviders: [
[$class: 'CulpritsRecipientProvider'],
[$class: 'DevelopersRecipientProvider'],
[$class: 'RequesterRecipientProvider']
],
replyTo: '$DEFAULT_REPLYTO',
to: '$DEFAULT_RECIPIENTS'
}
failure {
emailext subject: '$DEFAULT_SUBJECT',
body: '$DEFAULT_CONTENT',
recipientProviders: [
[$class: 'CulpritsRecipientProvider'],
[$class: 'DevelopersRecipientProvider'],
[$class: 'RequesterRecipientProvider']
],
replyTo: '$DEFAULT_REPLYTO',
to: '$DEFAULT_RECIPIENTS'
}
}
}

110
setup.py
View File

@ -1,7 +1,5 @@
#!/usr/bin/env python
# This file is part account_invoice_line_origin module for Tryton.
# The COPYRIGHT file at the top level of this repository contains
# the full copyright notices and license terms.
# encoding: utf-8
from setuptools import setup
import re
@ -9,7 +7,13 @@ import os
import io
from configparser import ConfigParser
MODULE = 'account_invoice_line_origin'
PREFIX = 'nantic'
MODULE2PREFIX = {}
OWNER = {
'nantic':'NaN-tic',
'trytonzz':'nanticzz',
}
def read(fname):
@ -17,6 +21,7 @@ def read(fname):
os.path.join(os.path.dirname(__file__), fname),
'r', encoding='utf-8').read()
def get_require_version(name):
if minor_version % 2:
require = '%s >= %s.%s.dev0, < %s.%s'
@ -26,51 +31,82 @@ def get_require_version(name):
major_version, minor_version + 1)
return require
def get_requires(depends='depends'):
requires = []
for dep in info.get(depends, []):
if not re.match(r'(ir|res)(\W|$)', dep):
prefix = MODULE2PREFIX.get(dep, 'trytond')
owner = OWNER.get(prefix, prefix)
if prefix == 'trytond':
requires.append(get_require_version('%s_%s' % (prefix, dep)))
else:
requires.append(
'%(prefix)s-%(dep)s@git+https://github.com/%(owner)s/'
'trytond-%(dep)s.git@%(branch)s'
'#egg=%(prefix)s-%(dep)s-%(series)s'%{
'prefix': prefix,
'owner': owner,
'dep':dep,
'branch': branch,
'series': series,})
return requires
config = ConfigParser()
config.readfp(open('tryton.cfg'))
info = dict(config.items('tryton'))
for key in ('depends', 'extras_depend', 'xml'):
if key in info:
info[key] = info[key].strip().splitlines()
version = info.get('version', '0.0.1')
major_version, minor_version, _ = version.split('.', 2)
major_version = int(major_version)
minor_version = int(minor_version)
name = 'trytonzz_account_invoice_line_origin'
download_url = 'https://bitbucket.org/zikzakmedia/trytond-account_invoice_line_origin'
requires = []
for dep in info.get('depends', []):
if not re.match(r'(ir|res)(\W|$)', dep):
prefix = MODULE2PREFIX.get(dep, 'trytond')
requires.append(get_require_version('%s_%s' % (prefix, dep)))
requires.append(get_require_version('trytond'))
tests_require = []
series = '%s.%s' % (major_version, minor_version)
if minor_version % 2:
branch = 'master'
else:
branch = series
requires += get_requires('depends')
tests_require = [
get_require_version('proteus'),
]
tests_require += get_requires('extras_depend')
requires += [get_require_version('trytond_account_invoice')]
dependency_links = []
if minor_version % 2:
# Add development index for testing with proteus
dependency_links.append('https://trydevpi.tryton.org/')
setup(name=name,
setup(name='%s_%s' % (PREFIX, MODULE),
version=version,
description='Tryton Account Invoice Origin Reference Module',
description='',
long_description=read('README'),
author='Zikzakmedia SL',
author_email='zikzak@zikzakmedia.com',
url='https://bitbucket.org/zikzakmedia/',
download_url=download_url,
keywords='',
package_dir={'trytond.modules.account_invoice_line_origin': '.'},
author='NaN-tic',
url='http://www.nan-tic.com/',
download_url='https://github.com:NaN-tic/trytond-account_invoice_line_origin.git',
package_dir={'trytond.modules.%s' % MODULE: '.'},
packages=[
'trytond.modules.account_invoice_line_origin',
'trytond.modules.account_invoice_line_origin.tests',
'trytond.modules.%s' % MODULE,
'trytond.modules.%s.tests' % MODULE,
],
package_data={
'trytond.modules.account_invoice_line_origin': (info.get('xml', [])
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.odt',
'icons/*.svg', 'tests/*.rst']),
'trytond.modules.%s' % MODULE: (info.get('xml', [])
+ ['tryton.cfg', 'locale/*.po', 'tests/*.rst', 'view/*.xml',
'icons/*.svg']),
},
project_urls = {
"Source Code": 'https://github.com:NaN-tic/trytond-account_invoice_line_origin.git'
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Plugins',
@ -79,26 +115,12 @@ setup(name=name,
'Intended Audience :: Financial and Insurance Industry',
'Intended Audience :: Legal Industry',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Natural Language :: Bulgarian',
'Natural Language :: Catalan',
'Natural Language :: Czech',
'Natural Language :: Dutch',
'Natural Language :: English',
'Natural Language :: French',
'Natural Language :: German',
'Natural Language :: Hungarian',
'Natural Language :: Italian',
'Natural Language :: Portuguese (Brazilian)',
'Natural Language :: Russian',
'Natural Language :: Slovenian',
'Natural Language :: Spanish',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Office/Business',
],
license='GPL-3',
@ -107,10 +129,10 @@ setup(name=name,
zip_safe=False,
entry_points="""
[trytond.modules]
account_invoice_line_origin = trytond.modules.account_invoice_line_origin
""",
%s = trytond.modules.%s
""" % (MODULE, MODULE),
test_suite='tests',
test_loader='trytond.test_loader:Loader',
tests_require=tests_require,
use_2to3=True,
)
)

17
tox.ini
View File

@ -1,15 +1,18 @@
[tox]
envlist = {py35,py36,py37}-{sqlite,postgresql},pypy3-{sqlite,postgresql}
envlist = py37-sqlite, stats
[testenv]
commands = {envpython} setup.py test
basepython=python3.7
commands = coverage run setup.py test
deps =
{py35,py36,py37}-postgresql: psycopg2 >= 2.5
pypy3-postgresql: psycopg2cffi >= 2.5
{py35,py36}-sqlite: sqlitebck
sqlite: sqlitebck
coverage
setenv =
sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}
postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://}
sqlite: DB_NAME={env:SQLITE_NAME::memory:}
postgresql: DB_NAME={env:POSTGRESQL_NAME:test}
install_command = pip install --pre --find-links https://trydevpi.tryton.org/ {opts} {packages}
[testenv:stats]
basepython=python3.7
commands =
coverage xml --omit=.tox/*,.eggs/*