44 lines
1.5 KiB
YAML
44 lines
1.5 KiB
YAML
- name: Check if tox is accesible # noqa 305
|
|
environment: "{{ tox_environment }}"
|
|
shell: |
|
|
set -eux
|
|
tox --version
|
|
{{ ansible_python.executable }} -m tox --version
|
|
register: result
|
|
failed_when: result.rc != 0 and 'not found' not in result.stderr
|
|
changed_when: false
|
|
|
|
# installing tox with --user will create tox script inside ~/.local/bin but
|
|
# this folder is *not* included PATH in all distros. While most modern ones
|
|
# adopted it, there is no guarantee.
|
|
- name: Ensure tox is installed # noqa 305
|
|
shell: |
|
|
set -eu
|
|
# {# for systems that do not have ~/.local/bin in PATH yet #}
|
|
# if [[ ":$PATH:" != *":${HOME}/.local/bin:"* ]] && [ -d "${HOME}/.local/bin" ]; then
|
|
# export PATH=${HOME}/.local/bin:$PATH
|
|
# fi
|
|
{% if result is failed or tox_upgrade %}
|
|
{{ ansible_python.executable }} -m pip install --user --upgrade '{{ tox_condition }}'
|
|
{% else %}
|
|
{{ ansible_python.executable }} -m pip install --user '{{ tox_condition }}'
|
|
{% endif %}
|
|
{{ ansible_python.executable }} -m tox --version
|
|
args:
|
|
executable: /bin/bash
|
|
|
|
# We want to be sure that if someone calls 'tox' without having `~/.local/bin`
|
|
# in PATH, they still get a *working* copy of it.
|
|
- name: Ensure a system tox is also available
|
|
become: true
|
|
environment: "{{ tox_environment }}"
|
|
shell: |
|
|
set -eu
|
|
type tox >/dev/null || {
|
|
{# -s is key here to prevent it from finding tox from userdir #}
|
|
{{ ansible_python.executable }} -s -m pip install '{{ tox_condition }}'
|
|
}
|
|
tox --version
|
|
args:
|
|
executable: /bin/bash
|