Debian Codegraph @

test/integration/targets/ansible-galaxy-collection/tasks/build.yml

raw
1 ---
2 - name: create a dangling symbolic link inside collection directory
3 ansible.builtin.file:
4 src: '/non-existent-path/README.md'
5 dest: '{{ galaxy_dir }}/scratch/ansible_test/my_collection/docs/README.md'
6 state: link
7 force: yes
8
9 - name: build basic collection based on current directory with dangling symlink
10 command: ansible-galaxy collection build {{ galaxy_verbosity }}
11 args:
12 chdir: '{{ galaxy_dir }}/scratch/ansible_test/my_collection'
13 register: fail_symlink_build
14 ignore_errors: yes
15
16 - name: assert that build fails due to dangling symlink
17 assert:
18 that:
19 - fail_symlink_build.failed
20 - '"Failed to find the target path" in fail_symlink_build.stderr'
21
22 - name: remove dangling symbolic link
23 ansible.builtin.file:
24 path: '{{ galaxy_dir }}/scratch/ansible_test/my_collection/docs/README.md'
25 state: absent
26
27 - name: build basic collection based on current directory
28 command: ansible-galaxy collection build {{ galaxy_verbosity }}
29 args:
30 chdir: '{{ galaxy_dir }}/scratch/ansible_test/my_collection'
31 register: build_current_dir
32
33 - name: get result of build basic collection on current directory
34 stat:
35 path: '{{ galaxy_dir }}/scratch/ansible_test/my_collection/ansible_test-my_collection-1.0.0.tar.gz'
36 register: build_current_dir_actual
37
38 - name: assert build basic collection based on current directory
39 assert:
40 that:
41 - '"Created collection for ansible_test.my_collection" in build_current_dir.stdout'
42 - build_current_dir_actual.stat.exists
43
44 - name: build basic collection based on relative dir
45 command: ansible-galaxy collection build scratch/ansible_test/my_collection {{ galaxy_verbosity }}
46 args:
47 chdir: '{{ galaxy_dir }}'
48 register: build_relative_dir
49
50 - name: get result of build basic collection based on relative dir
51 stat:
52 path: '{{ galaxy_dir }}/ansible_test-my_collection-1.0.0.tar.gz'
53 register: build_relative_dir_actual
54
55 - name: assert build basic collection based on relative dir
56 assert:
57 that:
58 - '"Created collection for ansible_test.my_collection" in build_relative_dir.stdout'
59 - build_relative_dir_actual.stat.exists
60
61 - name: fail to build existing collection without force
62 command: ansible-galaxy collection build scratch/ansible_test/my_collection {{ galaxy_verbosity }}
63 args:
64 chdir: '{{ galaxy_dir }}'
65 ignore_errors: yes
66 register: build_existing_no_force
67
68 - name: build existing collection with force
69 command: ansible-galaxy collection build scratch/ansible_test/my_collection --force {{ galaxy_verbosity }}
70 args:
71 chdir: '{{ galaxy_dir }}'
72 register: build_existing_force
73
74 - name: assert build existing collection
75 assert:
76 that:
77 - '"use --force to re-create the collection artifact" in build_existing_no_force.stderr'
78 - '"Created collection for ansible_test.my_collection" in build_existing_force.stdout'
79
80 - name: build collection containing ignored files
81 command: ansible-galaxy collection build
82 args:
83 chdir: '{{ galaxy_dir }}/scratch/ansible_test/ignore'
84
85 - name: list the created tar contents
86 command: tar -tf {{ galaxy_dir }}/scratch/ansible_test/ignore/ansible_test-ignore-1.0.0.tar.gz
87 register: tar_output
88
89 - name: assert ignored files are not present in the archive
90 assert:
91 that:
92 - item not in tar_output.stdout_lines
93 loop: '{{ collection_ignored_files }}'
94
95 - name: assert ignored directories are not present in the archive
96 assert:
97 that:
98 - item not in tar_output.stdout_lines
99 loop: '{{ collection_ignored_directories }}'