Debian Codegraph @

test/integration/targets/pip/tasks/url_packages.yml

raw
1 - name: Create local package
2 vars:
3 repo_path: "{{ remote_tmp_dir }}/pip_vcs_pkgs"
4 block:
5 - name: Create a nested package directory layout
6 file:
7 path: "{{ repo_path }}/dummy-root/dummy-subdirectory"
8 recurse: yes
9 state: directory
10 mode: '0755'
11
12 - name: Create a root-level pyproject.toml
13 copy:
14 dest: "{{ repo_path }}/pyproject.toml"
15 content: |
16 [build-system]
17 requires = ["setuptools == 80.0.0"]
18 build-backend = "setuptools.build_meta"
19
20 [project]
21 name = "dummy-root"
22 version = "0.0.1"
23 dependencies = []
24
25 - name: Create nested package's pyproject.toml
26 copy:
27 dest: "{{ repo_path }}/dummy-root/dummy-subdirectory/pyproject.toml"
28 content: |
29 [build-system]
30 requires = ["setuptools == 80.0.0"]
31 build-backend = "setuptools.build_meta"
32
33 [project]
34 name = "nested-package"
35 version = "0.0.1"
36 dependencies = []
37
38 - name: Create git repository
39 command:
40 cmd: "{{ item }}"
41 args:
42 chdir: "{{ repo_path }}"
43 environment:
44 GIT_CONFIG_NOSYSTEM: 1
45 loop:
46 - git init .
47 - git add .
48 - git -c user.name="Ansible Test" -c user.email="[email protected]" commit -m "First commit"
49
50 - name: Setup venvs
51 # We test for correct handling of vcs packages only in pip versions >= 24.1
52 # Despite dry-run being added in 22.2, it fails in several cases until 24.1
53 vars:
54 modern_pip_venv_version: "25.2"
55 outdated_pip_venv_version: "24.0"
56 block:
57 - name: Set venv paths
58 set_fact:
59 modern_pip_venv_path: "{{ remote_tmp_dir }}/modernvenv"
60 outdated_pip_venv_path: "{{ remote_tmp_dir }}/outdatedvenv"
61
62 - name: Create modern venv
63 pip:
64 name: pip=={{modern_pip_venv_version}}
65 virtualenv: "{{ modern_pip_venv_path }}"
66
67 - name: Create outdated venv
68 pip:
69 name: pip=={{outdated_pip_venv_version}}
70 virtualenv: "{{ outdated_pip_venv_path }}"
71
72 - name: Check vcs package installation and checking functionality
73 vars:
74 repo_path: "{{ remote_tmp_dir }}/pip_vcs_pkgs"
75 venv_path: "{{ modern_pip_venv_path }}"
76 block:
77 - name: Check installation of packages via git
78 pip:
79 name: "git+file://{{ repo_path }}/.git"
80 virtualenv: "{{ venv_path }}"
81 check_mode: true
82 register: check_git_install_to_empty_venv
83 environment:
84 FORCE_COLOR: "1" # Here to encourage pip to include ansi color escape codes to validate pip output parsing
85
86 - name: Install package via git
87 pip:
88 name: "git+file://{{ repo_path }}/.git"
89 virtualenv: "{{ venv_path }}"
90
91 - name: Re-check to ensure not changed
92 pip:
93 name: "git+file://{{ repo_path }}/.git"
94 virtualenv: "{{ venv_path }}"
95 check_mode: true
96 register: check_reinstall_one_pkg
97
98 - name: Re-check with multiple to ensure changed
99 pip:
100 name:
101 - "git+file://{{ repo_path }}/.git"
102 - "nested-package @ git+file://{{ repo_path }}/.git#subdirectory=dummy-root/dummy-subdirectory"
103 virtualenv: "{{ venv_path }}"
104 check_mode: true
105 register: check_reinstall_two
106
107 - name: Re-install dummy-root to ensure not changed
108 pip:
109 name: "git+file://{{ repo_path }}/.git"
110 virtualenv: "{{ venv_path }}"
111 check_mode: true
112 register: reinstall_git_pkg
113
114 - name: Assert that git repo wasn't installed
115 assert:
116 that:
117 - check_git_install_to_empty_venv is changed
118 - check_reinstall_one_pkg is not changed
119 - check_reinstall_two is changed
120 - reinstall_git_pkg is not changed
121
122 - name: Install nonsense git repo
123 pip:
124 name: "git+https://notawebsite.tld/doesntexist/doesntexist"
125 virtualenv: "{{ venv_path }}"
126 check_mode: true
127 register: check_failure_on_bad_repo
128 ignore_errors: true
129
130 - name: Assert failure on nonsense git
131 assert:
132 that: check_failure_on_bad_repo is failed
133
134 - name: Check installation of file-path package
135 pip:
136 virtualenv: "{{ venv_path }}"
137 name: "{{ repo_path }}"
138 check_mode: true
139 register: check_file_install_root
140
141 - name: Check installation of file-path package
142 pip:
143 virtualenv: "{{ venv_path }}"
144 name: "{{ repo_path }}/dummy-root/dummy-subdirectory"
145 check_mode: true
146 register: check_file_install_subdirectory
147
148 - name: Assert changed for file-path packages
149 assert:
150 that:
151 - check_file_install_root is not changed
152 - check_file_install_subdirectory is changed
153
154 # This tests for default behavior in the outdated versions of pip
155 - name: Check for failure in handling vcs packages with outdated pip
156 vars:
157 repo_path: "{{ remote_tmp_dir }}/pip_vcs_pkgs"
158 venv_path: "{{ outdated_pip_venv_path }}"
159 block:
160 - name: Install file-path package to fresh outdated venv
161 pip:
162 name: "{{ repo_path }}"
163 virtualenv: "{{ venv_path }}"
164
165 - name: Check installation of file-path package to venv
166 pip:
167 name: "{{ repo_path }}"
168 virtualenv: "{{ venv_path }}"
169 check_mode: true
170 register: pip_result
171
172 - name: Assert improper name resolution due to outdated pip
173 assert:
174 that: pip_result is changed