Create tox_package_name for tox role
This allows projects, that use tox but may not have a setup.cfg file still use tox siblings. We do this to allow non-python project, to use tox as an entry point for testing, and still have depends-on requirements work in zuul. Change-Id: I9b37117b27ff6b7e436d456b6cbae39ccb9b968c Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
parent
77833088f2
commit
c6bf69e60b
@ -35,6 +35,11 @@ Runs tox for a project
|
|||||||
Flag controlling whether to attempt to install python packages from any
|
Flag controlling whether to attempt to install python packages from any
|
||||||
other source code repos zuul has checked out. Defaults to True.
|
other source code repos zuul has checked out. Defaults to True.
|
||||||
|
|
||||||
|
.. zuul:rolevar:: tox_package_name
|
||||||
|
|
||||||
|
Allows a user to setup the package name to be used by tox, over reading
|
||||||
|
a setup.cfg file in the project.
|
||||||
|
|
||||||
.. zuul:rolevar:: zuul_work_dir
|
.. zuul:rolevar:: zuul_work_dir
|
||||||
:default: {{ zuul.project.src_dir }}
|
:default: {{ zuul.project.src_dir }}
|
||||||
|
|
||||||
|
@ -287,11 +287,13 @@ def main():
|
|||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
tox_show_config=dict(required=True, type='path'),
|
tox_show_config=dict(required=True, type='path'),
|
||||||
tox_constraints_file=dict(type='str'),
|
tox_constraints_file=dict(type='str'),
|
||||||
|
tox_package_name=dict(type='str'),
|
||||||
project_dir=dict(required=True, type='str'),
|
project_dir=dict(required=True, type='str'),
|
||||||
projects=dict(required=True, type='list'),
|
projects=dict(required=True, type='list'),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
constraints = module.params.get('tox_constraints_file')
|
constraints = module.params.get('tox_constraints_file')
|
||||||
|
tox_package_name = module.params.get('tox_package_name')
|
||||||
project_dir = module.params['project_dir']
|
project_dir = module.params['project_dir']
|
||||||
projects = module.params['projects']
|
projects = module.params['projects']
|
||||||
tox_show_config = module.params.get('tox_show_config')
|
tox_show_config = module.params.get('tox_show_config')
|
||||||
@ -308,19 +310,23 @@ def main():
|
|||||||
|
|
||||||
log.append('Using envlist: {}'.format(envlist))
|
log.append('Using envlist: {}'.format(envlist))
|
||||||
|
|
||||||
if not os.path.exists(os.path.join(project_dir, 'setup.cfg')):
|
if (not tox_package_name
|
||||||
|
and not os.path.exists(os.path.join(project_dir, 'setup.cfg'))
|
||||||
|
):
|
||||||
module.exit_json(changed=False, msg="No setup.cfg, no action needed")
|
module.exit_json(changed=False, msg="No setup.cfg, no action needed")
|
||||||
if constraints and not os.path.exists(constraints):
|
if constraints and not os.path.exists(constraints):
|
||||||
module.fail_json(msg="Constraints file {constraints} was not found")
|
module.fail_json(msg="Constraints file {constraints} was not found")
|
||||||
|
|
||||||
# Who are we?
|
# Who are we?
|
||||||
try:
|
package_name = tox_package_name
|
||||||
c = configparser.ConfigParser()
|
if not package_name:
|
||||||
c.read(os.path.join(project_dir, 'setup.cfg'))
|
try:
|
||||||
package_name = c.get('metadata', 'name')
|
c = configparser.ConfigParser()
|
||||||
except Exception:
|
c.read(os.path.join(project_dir, 'setup.cfg'))
|
||||||
module.exit_json(
|
package_name = c.get('metadata', 'name')
|
||||||
changed=False, msg="No name in setup.cfg, skipping siblings")
|
except Exception:
|
||||||
|
module.exit_json(
|
||||||
|
changed=False, msg="No name in setup.cfg, skipping siblings")
|
||||||
|
|
||||||
log.append(
|
log.append(
|
||||||
"Processing siblings for {name} from {project_dir}".format(
|
"Processing siblings for {name} from {project_dir}".format(
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
tox_install_sibling_packages:
|
tox_install_sibling_packages:
|
||||||
tox_show_config: "{{ _tox_show_config_tempfile.path }}"
|
tox_show_config: "{{ _tox_show_config_tempfile.path }}"
|
||||||
tox_constraints_file: "{{ tox_constraints_file | default(omit) }}"
|
tox_constraints_file: "{{ tox_constraints_file | default(omit) }}"
|
||||||
|
tox_package_name: "{{ tox_package_name | default(omit) }}"
|
||||||
project_dir: "{{ zuul_work_dir }}"
|
project_dir: "{{ zuul_work_dir }}"
|
||||||
projects: "{{ zuul.projects.values() | selectattr('required') | list }}"
|
projects: "{{ zuul.projects.values() | selectattr('required') | list }}"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user