Debian Codegraph @

test/integration/targets/git/tasks/submodules.yml

raw
1 #
2 # Submodule tests
3 #
4
5 # Repository A with submodules defined (repo_submodules)
6 # .gitmodules file points to Repository I
7 # Repository B forked from A that has newer commits (repo_submodules_newer)
8 # .gitmodules file points to Repository II instead of I
9 # .gitmodules file also points to Repository III
10 # Repository I for submodule1 (repo_submodule1)
11 # Has 1 file checked in
12 # Repository II forked from I that has newer commits (repo_submodule1_newer)
13 # Has 2 files checked in
14 # Repository III for a second submodule (repo_submodule2)
15 # Has 1 file checked in
16
17 - name: SUBMODULES | clear checkout_dir
18 file:
19 state: absent
20 path: "{{ checkout_dir }}"
21
22 - name: SUBMODULES | Test that clone without recursive does not retrieve submodules
23 git:
24 repo: "{{ repo_submodules }}"
25 version: 45c6c07ef10fd9e453d90207e63da1ce5bd3ae1e
26 dest: "{{ checkout_dir }}"
27 recursive: no
28
29 - name: SUBMODULES | List submodule1
30 command: 'ls -1a {{ checkout_dir }}/submodule1'
31 register: submodule1
32
33 - name: SUBMODULES | Ensure submodule1 is at the appropriate commit
34 assert:
35 that: submodule1.stdout_lines | length == 2
36
37 - name: SUBMODULES | clear checkout_dir
38 file:
39 state: absent
40 path: "{{ checkout_dir }}"
41
42
43 - name: SUBMODULES | Test that clone with recursive retrieves submodules
44 git:
45 repo: "{{ repo_submodules }}"
46 dest: "{{ checkout_dir }}"
47 version: 45c6c07ef10fd9e453d90207e63da1ce5bd3ae1e
48 recursive: yes
49
50 - name: SUBMODULES | List submodule1
51 command: 'ls -1a {{ checkout_dir }}/submodule1'
52 register: submodule1
53
54 - name: SUBMODULES | Ensure submodule1 is at the appropriate commit
55 assert:
56 that: submodule1.stdout_lines | length == 4
57
58 - name: SUBMODULES | Copy the checkout so we can run several different tests on it
59 command: 'cp -pr {{ checkout_dir }} {{ checkout_dir }}.bak'
60
61
62 - name: SUBMODULES | Test that update without recursive does not change submodules
63 git:
64 repo: "{{ repo_submodules }}"
65 version: d2974e4bbccdb59368f1d5eff2205f0fa863297e
66 dest: "{{ checkout_dir }}"
67 recursive: no
68 update: yes
69 track_submodules: yes
70
71 - name: SUBMODULES | List submodule1
72 command: 'ls -1a {{ checkout_dir }}/submodule1'
73 register: submodule1
74
75 - name: SUBMODULES | Stat submodule2
76 stat:
77 path: "{{ checkout_dir }}/submodule2"
78 register: submodule2
79
80 - name: SUBMODULES | List submodule2
81 command: ls -1a {{ checkout_dir }}/submodule2
82 register: submodule2
83
84 - name: SUBMODULES | Ensure both submodules are at the appropriate commit
85 assert:
86 that:
87 - submodule1.stdout_lines|length == 4
88 - submodule2.stdout_lines|length == 2
89
90
91 - name: SUBMODULES | Remove checkout dir
92 file:
93 state: absent
94 path: "{{ checkout_dir }}"
95
96 - name: SUBMODULES | Restore checkout to prior state
97 command: 'cp -pr {{ checkout_dir }}.bak {{ checkout_dir }}'
98
99
100 - name: SUBMODULES | Test that update with recursive updated existing submodules
101 git:
102 repo: "{{ repo_submodules }}"
103 version: d2974e4bbccdb59368f1d5eff2205f0fa863297e
104 dest: "{{ checkout_dir }}"
105 update: yes
106 recursive: yes
107 track_submodules: yes
108
109 - name: SUBMODULES | List submodule 1
110 command: 'ls -1a {{ checkout_dir }}/submodule1'
111 register: submodule1
112
113 - name: SUBMODULES | Ensure submodule1 is at the appropriate commit
114 assert:
115 that: submodule1.stdout_lines | length == 5
116
117
118 - name: SUBMODULES | Test that update with recursive found new submodules
119 command: 'ls -1a {{ checkout_dir }}/submodule2'
120 register: submodule2
121
122 - name: SUBMODULES | Ensure submodule2 is at the appropriate commit
123 assert:
124 that: submodule2.stdout_lines | length == 4
125
126 - name: SUBMODULES | clear checkout_dir
127 file:
128 state: absent
129 path: "{{ checkout_dir }}"
130
131
132 - name: SUBMODULES | Clone main submodule repository
133 git:
134 repo: "{{ repo_submodules }}"
135 dest: "{{ checkout_dir }}/test.gitdir"
136 version: 45c6c07ef10fd9e453d90207e63da1ce5bd3ae1e
137 recursive: yes
138
139 - name: SUBMODULES | Test that cloning submodule with .git in directory name works
140 git:
141 repo: "{{ repo_submodule1 }}"
142 dest: "{{ checkout_dir }}/test.gitdir/submodule1"
143
144 - name: SUBMODULES | List submodule1
145 command: 'ls -1a {{ checkout_dir }}/test.gitdir/submodule1'
146 register: submodule1
147
148 - name: SUBMODULES | Ensure submodule1 is at the appropriate commit
149 assert:
150 that: submodule1.stdout_lines | length == 4