Use upper-constraints in the Tobiko ansible roles

In Tobiko we have roles to e.g. ensure that tox is installed. It uses
pip but it didn't use upper-constraints.txt file from the OpenStack
requirements and that could cause some issues, especially on e.g. older
operating systems, see related bug for example.

With this patch those ansible roles which uses pip to install some
python packages will use upper-constraints file if it exists in the file
system (in the u/s CI it will exist).

This patch also lowers min tox version for stable/2023.1 and stable/zed
branches are those should still use tox 3.28

Closes-Bug: #2057492
Change-Id: I147770a7949c59ba61b8dcca23d5c6fbbacb2606
This commit is contained in:
Slawek Kaplonski 2024-03-13 09:32:44 +01:00
parent 7733488f00
commit 2005446dc6
4 changed files with 44 additions and 5 deletions

View File

@ -1,8 +1,16 @@
---
- name: "check if upper-constraints file exists"
stat:
path: "{{ openstack_requirements_dir }}/upper-constraints.txt"
register: upper_constraints_file
- name: "ensure Bindep is installed"
command: >
'{{ python_executable }}' -m pip install --user 'bindep>={{ bindep_min_version }}'
'{{ python_executable }}' -m pip install \
{% if upper_constraints_file.stat.exists == true %}-c'{{ upper_constraints_file.stat.path }}'{% endif %} \
--user bindep>='{{ bindep_min_version }}'
register: install_bindep
changed_when: "'Successfully installed' in install_bindep.stdout"

View File

@ -18,6 +18,8 @@ test_project:
test_git_repo: '{{ git_base }}/x/tobiko.git'
test_src_dir: ''
openstack_requirements_dir: "/opt/stack/requirements"
# NOTE: if test_dir and tobiko_dir variables endup being the same actual
# directory then test_src and test_git_* variables will be overriden

View File

@ -57,10 +57,17 @@
failed_when: (python_info | length) == 0
- name: "check if upper-constraints file exists"
stat:
path: "{{ openstack_requirements_dir }}/upper-constraints.txt"
register: upper_constraints_file
- name: "upgrade '{{ python_command }}' packages to the latest versions"
command: >
'{{ python_info[python_command].executable }}' -m pip install '{{ item }}' \
--upgrade --user
'{{ python_info[python_command].executable }}' -m pip install \
{% if upper_constraints_file.stat.exists == true %}-c'{{ upper_constraints_file.stat.path }}'{% endif %}
'{{ item }}' --upgrade --user
register: upgrade_python_packages
changed_when:
"'Successfully installed' in upgrade_python_packages.stdout"

View File

@ -1,9 +1,31 @@
---
- name: "check if upper-constraints file exists"
stat:
path: "{{ openstack_requirements_dir }}/upper-constraints.txt"
register: upper_constraints_file
- name: "Determine min tox version to be installed"
when: upper_constraints_file.stat.exists == true
block:
- name: "Check requirements repo branch"
ansible.builtin.command:
cmd: git rev-parse --abbrev-ref HEAD
chdir: "{{ openstack_requirements_dir }}"
register: requirements_branch
- name: "Set min tox version for Ubuntu 20.04"
set_fact:
tox_min_version: "3.28"
when: requirements_branch.stdout == "stable/2023.1" or "stable/zed"
- name: "ensure Tox is installed"
command: >
{{ python_executable }} -m pip install --user
'tox>={{ tox_min_version }}{% if tox_max_version is not none %},<={{ tox_max_version }}{% endif %}'
'{{ python_executable }}' -m pip install \
{% if upper_constraints_file.stat.exists is true %}-c'{{ upper_constraints_file.stat.path }}'{% endif %} \
--user 'tox>={{ tox_min_version }}{% if tox_max_version is not none %},<={{ tox_max_version }}{% endif %}'
register: install_tox
changed_when: "'Successfully installed' in install_tox.stdout"