zuul-jobs/roles/ensure-nox/tasks/main.yaml
James E. Blair 77b1b24911 Add ensure-nox role
This is an alternative to tox.

Change-Id: I394774836e303584473f0e7d64d496baa393037a
2022-12-15 13:22:49 -08:00

35 lines
946 B
YAML

- name: Install pip
include_role:
name: ensure-pip
- name: Check if nox is installed
shell: |
command -v {{ nox_executable }} {{ nox_venv_path }}/bin/nox || exit 1
args:
executable: /bin/bash
register: nox_preinstalled
failed_when: false
- name: Export preinstalled nox_exectuable
set_fact:
nox_executable: '{{ nox_preinstalled.stdout_lines[0] }}'
cacheable: true
when: nox_preinstalled.rc == 0
- name: Install nox to local env
when: nox_preinstalled.rc != 0
block:
- name: Create local venv
command: '{{ ensure_pip_virtualenv_command }} {{ nox_venv_path }}'
- name: Install nox to local venv
command: '{{ nox_venv_path }}/bin/pip install nox{{ ensure_nox_version }}'
- name: Export installed nox_executable path
set_fact:
nox_executable: '{{ nox_venv_path }}/bin/nox'
cacheable: true
- name: Output nox version
command: "{{ nox_executable }} --version"