zuul-jobs/test-playbooks/ensure-pip.yaml
Ian Wienand f578a38693 ensure-pip : fix Xenial exported virtualenv command
This is a fix for Id8347b6b09735659a7ed9bbe7f9d2798fbec9620 which did
not specify the full path in ensure_pip_virtualenv_command for Xenial.

This slipped by testing because there we check
ensure_pip_virtualenv_command runs under a shell:, but not when called
as the argument to the pip: module (which exec's it differently and
requires the full path).  Update testing to do that too.

Change-Id: I65ff5ce913917079ab2fc1d88c56d1c0a24ea83e
2020-05-06 11:15:00 +10:00

59 lines
1.4 KiB
YAML

- hosts: all
tasks:
# ensure-pip
- name: Include ensure-pip
include_role:
name: ensure-pip
- name: Create temp directory
tempfile:
state: directory
suffix: venv-test
register: _tmp_venv
- name: Sanity check provided virtualenv command installs
pip:
name: tox
virtualenv_command: '{{ ensure_pip_virtualenv_command }}'
virtualenv: '{{ _tmp_venv.path }}'
- name: Sanity check installed command runs without error
command: '{{ _tmp_venv.path }}/bin/tox --version'
- name: Remove tmpdir
file:
path: '{{ _tmp_venv.path }}'
state: absent
# ensure-virtualenv
- name: Include ensure-virtualenv
include_role:
name: ensure-virtualenv
- name: Sanity check virtualenv command works
shell: |
tmp_venv=$(mktemp -d -t venv-XXXXXXXXXX)
trap "rm -rf $tmp_venv" EXIT
virtualenv $tmp_venv
$tmp_venv/bin/pip install tox
failed_when: false
register: _virtualenv_sanity
- name: Assert sanity check
fail:
msg: 'The virtualenv command does not appear to work!'
when:
- _virtualenv_sanity.rc != 0
# NOTE(ianw) : this does not play nicely with pip-and-virtualenv which
# has already installed from source. We might be able to test this
# once it's gone...
# - hosts: all
# roles:
# - role: ensure-pip
# vars:
# ensure_pip_from_upstream: True