zuul-jobs/test-playbooks/ensure-pip.yaml
Ian Wienand a016a1a565 linters: standardise on newline at end of file
I noticed this by accident when I ran ansible-lint over this repo from
an outside context; it didn't use the .yamllint in here and started
compalining about eof whitespace.

After scratching my head for a bit as to why this didn't fail here, I
realised we've allowed various newlines since the initial commit
I936fe2c997597972d884c5fc62655d28e8aaf8c5.

Remove this and just use the default eof rules, and fixup the
whitespace as required.  This is fairly unimportant, but is nice for
consistency.

Change-Id: Idb46a1f39ba798b0bf70eaa27b4c6b4758ce3d26
2022-07-28 16:19:06 +10:00

73 lines
2.3 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
- name: Sanity check pip wheel generation
shell: |
cd {{ ansible_user_dir }}/src/opendev.org/zuul/zuul-client
# This should run anywhere without too much logic ...
run_pip=$(command -v pip3 || command -v pip2 || command -v pip)
# Preinstall pbr to work around very old distutils lacking SNI support
$run_pip install pbr
$run_pip wheel --no-deps .
ls zuul_client-*.whl || exit 1
- name: Test virtualenv
# NOTE(ianw) 2022-02-03 : not supported on 9-stream, see inline comments
# NOTE(frickler) 2022-03-01 : pin pluggy so as to work on Debian Buster
when: not (ansible_facts['distribution'] == 'CentOS' and ansible_facts['distribution_major_version']|int >= 9)
block:
# 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 "pluggy<1"
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