Clark Boylan cf678365af Pin tox to <4 in ensure-tox installation
Tox v4 just released and has a number of breaking changes. One of which
(yet to be properly identified) has completely broken Zuul's tox
siblings processing and produces errors like:

  Traceback (most recent call last):
    File "<stdin>", line 107, in <module>
    File "<stdin>", line 99, in _ansiballz_main
    File "<stdin>", line 47, in invoke_module
    File "/usr/lib/python3.10/runpy.py", line 224, in run_module
      return _run_module_code(code, init_globals, run_name, mod_spec)
    File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
      _run_code(code, mod_globals, init_globals,
    File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
      exec(code, run_globals)
    File "/tmp/ansible_tox_install_sibling_packages_payload_0af4x4lc/ansible_tox_install_sibling_packages_payload.zip/ansible/modules/tox_install_sibling_packages.py", line 397, in <module>
    File "/tmp/ansible_tox_install_sibling_packages_payload_0af4x4lc/ansible_tox_install_sibling_packages_payload.zip/ansible/modules/tox_install_sibling_packages.py", line 328, in main
    File "/usr/lib/python3.10/configparser.py", line 724, in read_string
      self.read_file(sfile, source)
    File "/usr/lib/python3.10/configparser.py", line 719, in read_file
      self._read(f, source)
    File "/usr/lib/python3.10/configparser.py", line 1097, in _read
      raise DuplicateOptionError(sectname, optname,
  configparser.DuplicateOptionError: While reading from '<string>' [line 45]: option 'root' in section 'testenv:docs' already exists

Let's pin tox for now and a change that removes the pin can also fix tox
siblings (the change to remove the pin should be self testing
thankfully).

Also we make the zuul-tox-docs job temporarily non voting as it runs
ensure-tox non speculatively out of the opendev/base-jobs repo. We have
plenty of tox jobs runing against this changeto show it should work
fine.

Change-Id: Idcebd397f47cfef718721d2576cb43dbdb70801d
2022-12-07 11:31:44 -08:00

49 lines
1.3 KiB
YAML

- name: Install pip
include_role:
name: ensure-pip
vars:
ensure_pip_from_packages_with_python2: '{{ tox_prefer_python2 }}'
- name: Check if tox is installed
shell: |
command -v {{ tox_executable }} {{ tox_venv_path }}/bin/tox || exit 1
args:
executable: /bin/bash
register: tox_preinstalled
failed_when: false
- name: Export preinstalled tox_exectuable
set_fact:
tox_executable: '{{ tox_preinstalled.stdout_lines[0] }}'
cacheable: true
when: tox_preinstalled.rc == 0
- name: Install tox to local env
when: tox_preinstalled.rc != 0
block:
- name: Create local venv
command: '{{ ensure_pip_virtualenv_command }} {{ tox_venv_path }}'
- name: Install tox to local venv
# We pin tox to version <4 as v4 is not currently compatible with
# zuul's tox siblings processing.
command: '{{ tox_venv_path }}/bin/pip install tox<4'
- name: Export installed tox_executable path
set_fact:
tox_executable: '{{ tox_venv_path }}/bin/tox'
cacheable: true
- name: Output tox version
command: "{{ tox_executable }} --version"
- name: Make global symlink
when:
- ensure_global_symlinks
- tox_executable != '/usr/local/bin/tox'
file:
state: link
src: "{{ tox_executable }}"
dest: /usr/local/bin/tox
become: yes