1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-22 13:19:13 +00:00
community.general/tests/integration/targets/uv_python/tasks/main.yaml

285 lines
No EOL
7.5 KiB
YAML

---
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Install uv python package
ansible.builtin.pip:
name: uv
- name: Add uv installation directory to PATH in macOS
shell: export PATH="$(python3 -m site --user-base)/bin:$PATH"
when: ansible_facts['os_family'] == "Darwin"
- name: Check if Python 3.14 exists already
command: uv python find 3.14
ignore_errors: true
register: check_python_314_exists
changed_when: false
- name: Install Python 3.14 in check mode
uv_python:
version: 3.14
state: present
check_mode: true
register: install_check_mode
- name: Verify Python 3.14 installation in check mode
assert:
that:
- install_check_mode.changed == check_python_314_exists.failed
- install_check_mode.failed is false
- install_check_mode.python_versions | length >= 1
- name: Install Python 3.14
uv_python:
version: 3.14
state: present
register: install_python
- name: Verify Python 3.14 installation
assert:
that:
- install_python.changed == check_python_314_exists.failed
- install_python.failed is false
- install_python.python_versions | length >= 1
- install_python.python_paths | length >= 1
- name: Re-install Python 3.14
uv_python:
version: 3.14
state: present
register: reinstall_python
- name: Verify Python 3.14 re-installation
assert:
that:
- reinstall_python.changed is false
- reinstall_python.failed is false
- reinstall_python.python_versions | length >= 1
- reinstall_python.python_paths | length >= 1
- name: Check if Python 3.13.5 exists already
command: uv python find 3.13.5
ignore_errors: true
register: check_python_3135_exists
changed_when: false
- name: Install Python 3.13.5
uv_python:
version: 3.13.5
register: install_python_3135
- name: Verify Python 3.13.5 installation
assert:
that:
- install_python_3135.changed == check_python_3135_exists.failed
- install_python_3135.failed is false
- '"3.13.5" in install_python_3135.python_versions'
- install_python_3135.python_paths | length >= 1
- name: Re-install Python 3.13.5
uv_python:
version: 3.13.5
state: present
register: reinstall_python
- name: Verify Python 3.13.5 installation
assert:
that:
- reinstall_python.changed is false
- reinstall_python.failed is false
- '"3.13.5" in reinstall_python.python_versions'
- name: Remove uninstalled Python 3.10 # removes latest patch version for 3.10 if exists
uv_python:
version: "3.10"
state: absent
register: remove_python
- name: Verify Python 3.10 deletion
assert:
that:
- remove_python.changed is false
- remove_python.failed is false
- remove_python.python_versions | length == 0
- name: Remove Python 3.13.5 in check mode
uv_python:
version: 3.13.5
state: absent
check_mode: true
register: remove_python_in_check_mode
- name: Verify Python 3.13.5 deletion in check mode
assert:
that:
- remove_python_in_check_mode.changed == install_python_3135.changed
- remove_python_in_check_mode.failed is false
- name: Additional check for Python 3.13.5 deletion in check mode
when: install_python_3135.changed is true
assert:
that:
- '"3.13.5" in remove_python_in_check_mode.python_versions'
- remove_python_in_check_mode.python_paths | length >= 1
- name: Remove Python 3.13.5
uv_python:
version: 3.13.5
state: absent
register: remove_python
- name: Verify Python 3.13.5 deletion
assert:
that:
- remove_python.changed == install_python_3135.changed
- remove_python.failed is false
- name: Additional check for Python 3.13.5 deletion
when: install_python_3135.changed is true
assert:
that:
- remove_python.python_paths | length >= 1
- '"3.13.5" in remove_python.python_versions'
- name: Remove Python 3.13.5 again
uv_python:
version: 3.13.5
state: absent
register: remove_python
- name: Verify Python 3.13.5 deletion again
assert:
that:
- remove_python.changed is false
- remove_python.failed is false
- remove_python.python_versions | length == 0
- remove_python.python_paths | length == 0
- name: Upgrade Python 3.13
uv_python:
version: 3.13
state: latest
register: upgrade_python
- name: Verify Python 3.13 upgrade
assert:
that:
- upgrade_python.changed is true
- upgrade_python.failed is false
- upgrade_python.python_versions | length >= 1
- upgrade_python.python_paths | length >= 1
- name: Upgrade Python 3.13 in check mode
uv_python:
version: 3.13
state: latest
check_mode: true
register: upgrade_python
- name: Verify Python 3.13 upgrade in check mode
assert:
that:
- upgrade_python.changed is false
- upgrade_python.failed is false
- upgrade_python.python_versions | length >= 1
- name: Upgrade Python 3.13 again
uv_python:
version: 3.13
state: latest
check_mode: true
register: upgrade_python
- name: Verify Python 3.13 upgrade again
assert:
that:
- upgrade_python.changed is false
- upgrade_python.failed is false
- upgrade_python.python_versions | length >= 1
- name: Install unsupported Python version in check mode
uv_python:
version: 2.0
state: present
register: unsupported_python_check_mode
ignore_errors: true
check_mode: true
- name: Verify unsupported Python 2.0 install in check mode
assert:
that:
- unsupported_python_check_mode.changed is false
- unsupported_python_check_mode.failed is true
- '"Version 2.0 is not available." in unsupported_python_check_mode.msg'
- name: Install unsupported Python version
uv_python:
state: present
version: 2.0
register: unsupported_python
ignore_errors: true
- name: Verify unsupported Python 2.0 install
assert:
that:
- unsupported_python.changed is false
- unsupported_python.failed is true
- name: Install unsupported Python version with latest state
uv_python:
version: 2.0
state: latest
register: unsupported_python
ignore_errors: true
- name: Verify Python 2.0 install with latest state
assert:
that:
- unsupported_python.changed is false
- unsupported_python.failed is true
- name: Delete Python 3.13 version
uv_python:
version: 3.13
state: absent
register: uninstall_result
- name: Verify Python 3.13 deletion
assert:
that:
- uninstall_result.changed is true
- uninstall_result.failed is false
- '"3.13.12" in uninstall_result.python_versions'
- name: No specified version
uv_python:
state: latest
version: ""
ignore_errors: true
register: no_version
- name: Verify failure when no version is specified
assert:
that:
- no_version.failed is true
- '"Unsupported version format" in no_version.msg'
- name: Unsupported version format given
uv_python:
state: latest
version: "3.8.post2"
ignore_errors: true
register: wrong_version
- name: Verify failure when unsupported version format is specified
assert:
that:
- wrong_version.failed is true
- '"Unsupported version format" in wrong_version.msg'