a047fe0e4c
* Correct usage for shutil.rmtree Fix adds correct usage of shutil.rmtree in git module Fixes: #31225 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com> * Include archive tests so they get run * Use new include syntax * Cleanup syntax on git tests - use multi-line YAML - remove unneeded {{ }} around vars in conditionals - remove unneeded quotes - add task file name to task names for easier troubleshooting when things fail * Make archive tests work for RHEL/CentOS 6 The older versions of Jinja2 in RHEL/CentOS 6 required assertion tasks using the map filter to be skipped. The older version of git required gzip compression to be skipped on RHEL/CentOS 6. * Account for ansible_distribution_major_version missing
116 lines
3 KiB
YAML
116 lines
3 KiB
YAML
#
|
|
# Submodule tests
|
|
#
|
|
|
|
# Repository A with submodules defined (repo_submodules)
|
|
# .gitmodules file points to Repository I
|
|
# Repository B forked from A that has newer commits (repo_submodules_newer)
|
|
# .gitmodules file points to Repository II instead of I
|
|
# .gitmodules file also points to Repository III
|
|
# Repository I for submodule1 (repo_submodule1)
|
|
# Has 1 file checked in
|
|
# Repository II forked from I that has newer commits (repo_submodule1_newer)
|
|
# Has 2 files checked in
|
|
# Repository III for a second submodule (repo_submodule2)
|
|
# Has 1 file checked in
|
|
|
|
- name: SUBMODULES | clear checkout_dir
|
|
file:
|
|
state: absent
|
|
path: "{{ checkout_dir }}"
|
|
|
|
- name: SUBMODULES | Test that clone without recursive does not retrieve submodules
|
|
git:
|
|
repo: "{{ repo_submodules }}"
|
|
dest: "{{ checkout_dir }}"
|
|
recursive: no
|
|
|
|
- command: 'ls -1a {{ checkout_dir }}/submodule1'
|
|
register: submodule1
|
|
|
|
- assert:
|
|
that: '{{ submodule1.stdout_lines | length }} == 2'
|
|
|
|
- name: SUBMODULES | clear checkout_dir
|
|
file:
|
|
state: absent
|
|
path: "{{ checkout_dir }}"
|
|
|
|
|
|
- name: SUBMODULES | Test that clone with recursive retrieves submodules
|
|
git:
|
|
repo: "{{ repo_submodules }}"
|
|
dest: "{{ checkout_dir }}"
|
|
recursive: yes
|
|
|
|
- command: 'ls -1a {{ checkout_dir }}/submodule1'
|
|
register: submodule1
|
|
|
|
- assert:
|
|
that: '{{ submodule1.stdout_lines | length }} == 4'
|
|
|
|
- name: SUBMODULES | Copy the checkout so we can run several different tests on it
|
|
command: 'cp -pr {{ checkout_dir }} {{ checkout_dir }}.bak'
|
|
|
|
|
|
|
|
- name: SUBMODULES | Test that update without recursive does not change submodules
|
|
command: 'git config --replace-all remote.origin.url {{ repo_submodules_newer }}'
|
|
args:
|
|
chdir: '{{ checkout_dir }}'
|
|
|
|
- git:
|
|
repo: "{{ repo_submodules_newer }}"
|
|
dest: "{{ checkout_dir }}"
|
|
recursive: no
|
|
update: yes
|
|
track_submodules: yes
|
|
|
|
- command: 'ls -1a {{ checkout_dir }}/submodule1'
|
|
register: submodule1
|
|
|
|
- stat:
|
|
path: "{{ checkout_dir }}/submodule2"
|
|
register: submodule2
|
|
|
|
- command: ls -1a {{ checkout_dir }}/submodule2
|
|
register: submodule2
|
|
|
|
- assert:
|
|
that: '{{ submodule1.stdout_lines|length }} == 4'
|
|
|
|
- assert:
|
|
that: '{{ submodule2.stdout_lines|length }} == 2'
|
|
|
|
|
|
- name: SUBMODULES | Restore checkout to prior state
|
|
file:
|
|
state: absent
|
|
path: "{{ checkout_dir }}"
|
|
- command: 'cp -pr {{ checkout_dir }}.bak {{ checkout_dir }}'
|
|
|
|
- name: SUBMODULES | Test that update with recursive updated existing submodules
|
|
command: 'git config --replace-all remote.origin.url {{ repo_submodules_newer }}'
|
|
args:
|
|
chdir: "{{ checkout_dir }}"
|
|
|
|
- git:
|
|
repo: "{{ repo_submodules_newer }}"
|
|
dest: "{{ checkout_dir }}"
|
|
update: yes
|
|
recursive: yes
|
|
track_submodules: yes
|
|
|
|
- command: 'ls -1a {{ checkout_dir }}/submodule1'
|
|
register: submodule1
|
|
|
|
- assert:
|
|
that: '{{ submodule1.stdout_lines|length }} == 5'
|
|
|
|
|
|
- name: SUBMODULES | Test that update with recursive found new submodules
|
|
command: 'ls -1a {{ checkout_dir }}/submodule2'
|
|
register: submodule2
|
|
|
|
- assert:
|
|
that: '{{ submodule2.stdout_lines|length }} == 4'
|