mirror of https://github.com/ansible/ansible.git
Fix ansible-test submodule handling. (#68759)
* Refactor ansible-test integration test. * Add env --list-files option. * Add tests for collection files tracked by git. * Fix ansible-test submodule usage on older git. * Fix submodule directory detection as files. * Improve handling of nested source control.pull/68774/head
parent
d4d2c95819
commit
148e83f832
@ -0,0 +1,2 @@
|
|||||||
|
minor_changes:
|
||||||
|
- ansible-test now has a ``--list-files`` option to list files using the ``env`` command.
|
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- ansible-test now supports submodules using older ``git`` versions which require querying status from the top level directory of the repo.
|
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- ansible-test now ignores version control within subdirectories of collections. Previously this condition was an error.
|
@ -0,0 +1,2 @@
|
|||||||
|
minor_changes:
|
||||||
|
- ansible-test no longer detects ``git`` submodule directories as files.
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux -o pipefail
|
||||||
|
|
||||||
|
export GIT_TOP_LEVEL SUBMODULE_DST
|
||||||
|
|
||||||
|
GIT_TOP_LEVEL="${WORK_DIR}/super/ansible_collections/ns/col"
|
||||||
|
SUBMODULE_DST="sub"
|
||||||
|
|
||||||
|
source collection-tests/git-common.bash
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux -o pipefail
|
||||||
|
|
||||||
|
export GIT_TOP_LEVEL SUBMODULE_DST
|
||||||
|
|
||||||
|
GIT_TOP_LEVEL="${WORK_DIR}/super"
|
||||||
|
SUBMODULE_DST="ansible_collections/ns/col/sub"
|
||||||
|
|
||||||
|
source collection-tests/git-common.bash
|
@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux -o pipefail
|
||||||
|
|
||||||
|
# make sure git is installed
|
||||||
|
git --version || ansible-playbook collection-tests/install-git.yml -i ../../inventory "$@"
|
||||||
|
|
||||||
|
# init sub project
|
||||||
|
mkdir "${WORK_DIR}/sub"
|
||||||
|
cd "${WORK_DIR}/sub"
|
||||||
|
touch "README.md"
|
||||||
|
git init
|
||||||
|
git config user.name 'Ansible Test'
|
||||||
|
git config user.email 'ansible-test@ansible.com'
|
||||||
|
git add "README.md"
|
||||||
|
git commit -m "Initial commit."
|
||||||
|
|
||||||
|
# init super project
|
||||||
|
rm -rf "${WORK_DIR}/super" # needed when re-creating in place
|
||||||
|
mkdir "${WORK_DIR}/super"
|
||||||
|
cp -a "${TEST_DIR}/ansible_collections" "${WORK_DIR}/super"
|
||||||
|
cd "${GIT_TOP_LEVEL}"
|
||||||
|
git init
|
||||||
|
|
||||||
|
# add submodule
|
||||||
|
git submodule add "${WORK_DIR}/sub" "${SUBMODULE_DST}"
|
||||||
|
|
||||||
|
# prepare for tests
|
||||||
|
expected="${WORK_DIR}/expected.txt"
|
||||||
|
actual="${WORK_DIR}/actual.txt"
|
||||||
|
cd "${WORK_DIR}/super/ansible_collections/ns/col"
|
||||||
|
mkdir tests/.git
|
||||||
|
touch tests/.git/keep.txt # make sure ansible-test correctly ignores version control within collection subdirectories
|
||||||
|
find . -type f ! -path '*/.git/*' ! -name .git | sed 's|^\./||' | sort >"${expected}"
|
||||||
|
set -x
|
||||||
|
|
||||||
|
# test at the collection base
|
||||||
|
ansible-test env --list-files | sort >"${actual}"
|
||||||
|
diff --unified "${expected}" "${actual}"
|
||||||
|
|
||||||
|
# test at the submodule base
|
||||||
|
(cd sub && ansible-test env --list-files | sort >"${actual}")
|
||||||
|
diff --unified "${expected}" "${actual}"
|
@ -0,0 +1,5 @@
|
|||||||
|
- hosts: localhost
|
||||||
|
tasks:
|
||||||
|
- name: Make sure git is installed
|
||||||
|
package:
|
||||||
|
name: git
|
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux -o pipefail
|
||||||
|
|
||||||
|
cp -a "${TEST_DIR}/ansible_collections" "${WORK_DIR}"
|
||||||
|
cd "${WORK_DIR}/ansible_collections/ns/col"
|
||||||
|
|
||||||
|
# common args for all tests
|
||||||
|
common=(--venv --python "${ANSIBLE_TEST_PYTHON_VERSION}" --color --truncate 0 "${@}")
|
||||||
|
|
||||||
|
# prime the venv to work around issue with PyYAML detection in ansible-test
|
||||||
|
ansible-test sanity "${common[@]}" --test ignores
|
||||||
|
|
||||||
|
# tests
|
||||||
|
ansible-test sanity "${common[@]}"
|
||||||
|
ansible-test units "${common[@]}"
|
||||||
|
ansible-test integration "${common[@]}"
|
Loading…
Reference in New Issue