zuul-jobs/roles/ensure-if-python/tasks/main.yaml
Lukas Kranz d8ec17cab0 Remove get_md5 parameter from stat module.
The get_md5 parameter was removed with ansible 9.
https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_9.html#id44

If it is being used the following error appears:
"Unsupported parameters for (stat) module: get_md5..."

Unrelated, but also blocking testing/merging of this change, the
Ansible version specs for older python versions is loosened
to allow installing older versions of Ansible on test nodes (like
focal) that have older pythons that are unsupported by newer Ansible.

Change-Id: I99dd4f16fde659d84eb3dfa191557b3d9508b0fb
2024-08-01 07:12:17 -07:00

74 lines
2.2 KiB
YAML

# TODO(mordred) rework tox-siblings so it can be used here - probably by
# making it take a parameter as to what path to python/pip to use.
- name: Find Constraints File
include_role:
name: find-constraints
- name: Check to see if the project is a python project
find:
paths: "{{ zuul_work_dir }}"
patterns:
- setup.cfg
- setup.py
register: found_python_files
when: install_package
# Installing the directory with the constraints flag can hit into problems
# with conflicting values between constraints and current project. So look
# for a requirements.txt file so we can install it directly.
- name: Check to see if the project has a requirements.txt file
stat:
get_checksum: false
get_mime: false
path: "{{ zuul_work_dir }}/requirements.txt"
register: requirements_file
- name: Install requirements if they exist
pip:
chdir: "{{ zuul_work_dir }}"
virtualenv: "{{ zuul_work_virtualenv }}"
requirements: requirements.txt
extra_args: "{{ upper_constraints | default(omit) }}"
register: requirements_install
when:
- install_package
- found_python_files.matched
- requirements_file.stat.exists
failed_when:
- error_on_failure is defined
- error_on_failure
- requirements_install is failed
# Build an sdist. This is needed for pbr projects that may expect
# the ChangeLog to have been generated.
- name: Make sdist to generate ChangeLog
command:
cmd: "{{ zuul_work_virtualenv }}/bin/python setup.py sdist"
chdir: "{{ zuul_work_dir }}"
when:
- install_package
- found_python_files.matched
register: sdist_results
failed_when:
- error_on_failure is defined
- error_on_failure
- sdist_results is failed
# Try installing current repo in case it needs to be available for
# example for version number calculation. Ignore any failures here.
- name: Install the project if it is a Python project
pip:
chdir: "{{ zuul_work_dir }}"
virtualenv: "{{ zuul_work_virtualenv }}"
name: .
extra_args: --no-deps
when:
- install_package
- found_python_files.matched
register: install_package_results
failed_when:
- error_on_failure is defined
- error_on_failure
- install_package_results is failed