Commit 2aee0d8a authored by Tulio Ruiz's avatar Tulio Ruiz
Browse files

[IMP] Group deprecation warnings and allow to ignore

[FIX] Pip is using p3 but default is p2

[FIX] ALLOW_DEPRECATED is not required as an env var

[FIX] Show deprecation count

[FIX] Remove debug message

[FIX] Do not count deprecation as general warnings

[IMP] Better log format and add debug information
parent c965df74
Pipeline #70530 passed with stage
in 18 seconds
......@@ -9,7 +9,7 @@ test_install:
- lint
script:
- pip install twine wheel
- python setup.py sdist bdist_wheel
- python3 setup.py sdist bdist_wheel
release:
image: quay.io/vauxoo/dockerv:latest
......@@ -20,6 +20,6 @@ release:
- tags
script:
- pip install twine wheel
- python setup.py sdist bdist_wheel
- python3 setup.py sdist bdist_wheel
- twine upload dist/* -u "$PYPIUSER" -p "$PYPIPW"
when: on_success
......@@ -44,6 +44,8 @@ signal.signal(signal.SIGINT, common.reciveSignal)
@click.option('--image_repo_url', default=environ.get('IMAGE_REPO_URL', "quay.io/vauxoo"),
help=("The URL where the image repository is located."
" Env var: IMAGE_REPO_URL."))
@click.option('--allow_deprecated', is_flag=True,
help="Don't fail if a deprecated method is found")
def test_image(**kwargs):
config = common.prepare(**kwargs)
......
......@@ -46,9 +46,10 @@ signal.signal(signal.SIGINT, common.reciveSignal)
" Env var: IMAGE_REPO_URL."))
@click.option('--push_image', is_flag=True,
help="If set it will push the image when on the main branch after the tests")
@click.option('--allow_deprecated', is_flag=True,
help="Don't fail if a deprecated method is found")
def test_images(**kwargs):
config = common.prepare(**kwargs)
if config.get('push_image', False):
if not config.get('orchest_registry', False) or not config.get('orchest_token', False):
_logger.error('To push the image you need to set ORCHEST_REGISTRY and ORCHEST_TOKEN env vars')
......
......@@ -34,7 +34,7 @@ def pull_images(images):
def check_env_vars(*args, **kwargs):
missing = []
not_required = ['psql_image', 'push_image', 'install']
not_required = ['psql_image', 'push_image', 'install', 'allow_deprecated']
for key in args:
if key not in not_required and not (key.upper() in environ and environ[key.upper()]):
missing.append(key.upper())
......@@ -209,7 +209,6 @@ def get_config(**kwargs):
res.update({
'main_app': get_main_app(res)
})
print(res.get('main_app'))
return res
......@@ -443,30 +442,36 @@ def install_module(config):
_logger.info('\nInstalling %s with demo', module)
_logger.debug('Command : %s', install_wdemo)
wdemo_res = exec_cmd(config['container_name'], install_wdemo, 'odoo', stream=True)
wdemo_log = resume_log(wdemo_res)
wdemo_log = resume_log(wdemo_res, config['allow_deprecated'])
_logger.info('\nInstalling %s without demo', module)
_logger.debug('Command : %s', install_wodemo)
wodemo_res = exec_cmd(config['container_name'], install_wodemo, 'odoo', stream=True)
wodemo_log = resume_log(wodemo_res)
show_log(wdemo_log[1], 'Installation with demo')
show_log(wodemo_log[1], 'Installation without demo')
wodemo_log = resume_log(wodemo_res, config['allow_deprecated'])
show_log(wdemo_log[1], 'Installation with demo', config)
show_log(wodemo_log[1], 'Installation without demo', config)
_logger.debug('Installation wdemo res: %s', wdemo_log[0])
_logger.debug('Installation wodemo res: %s', wodemo_log[0])
if not wdemo_log[0] or not wodemo_log[0]:
return False
return True
def show_log(log, title):
_logger.info('\n%s', title)
_logger.info('='*20)
def show_log(log, title, config):
_logger.info('='*50)
_logger.info('%s', title)
if config['allow_deprecated']:
_logger.warning('+++ Deprecated methods allowed')
_logger.info('='*50)
_logger.info('+-- Critical errors %s', len(log.get('critical')))
_logger.info('+-- Errors %s', len(log.get('errors')))
_logger.info('+-- Import errors %s', len(log.get('import_errors')))
_logger.info('+-- Deprecation Warnings %s', len(log.get('warnings_deprecated')))
_logger.info('+-- Warnings %s', len(log.get('warnings')))
_logger.info('+-- Translation Warnings %s', len(log.get('warnings_trans')))
_logger.info('='*20)
_logger.info('*'*50)
def resume_log(log_lines):
def resume_log(log_lines, allow_deprecated=False):
"""Gets the log lines from -u (modules or all) and parse them to get the totals
according to the filters dict
......@@ -486,19 +491,27 @@ def resume_log(log_lines):
r'.*\d\sWARNING\s.*no translation for language.*')
return criteria.match(line)
def warnings_deprecated(line):
criteria = re.compile(
r'.*\d\sWARNING\s.*Deprecated method.*')
return criteria.match(line)
def import_errors(line):
criteria = re.compile(r'^ImportError.*')
return criteria.match(line)
def warnings(line):
criteria = re.compile(r'.*\d\sWARNING\s.*')
return criteria.match(line) and 'no translation for language' not in line
return criteria.match(line) \
and 'no translation for language' not in line \
and 'Deprecated method' not in line
filters = {
'critical': critical,
'errors': errors,
'warnings': warnings,
'warnings_trans': warnings_trans,
'warnings_deprecated': warnings_deprecated,
'import_errors': import_errors
}
success = True
......@@ -509,7 +522,7 @@ def resume_log(log_lines):
if criteria(stripped_line):
if name in ['critical', 'errors']:
success = False
elif name == 'warnings' and 'Deprecated' in stripped_line:
elif name == 'warnings_deprecated' and not allow_deprecated:
success = False
res.get(name).append(stripped_line)
break
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment