From 18fab585ad50016e81efce3d8272026c5281c588 Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Fri, 13 Dec 2024 15:46:09 +0100 Subject: [PATCH 1/2] CI: build collection before runnings tests We were running the playbooks before building the collections, so this probably wasn't testing much. --- tests/scripts/testcases_run.sh | 72 +++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/tests/scripts/testcases_run.sh b/tests/scripts/testcases_run.sh index 87792c23b..e7749f1d5 100755 --- a/tests/scripts/testcases_run.sh +++ b/tests/scripts/testcases_run.sh @@ -29,6 +29,42 @@ export ANSIBLE_BECOME_USER=root export ANSIBLE_INVENTORY=${CI_PROJECT_DIR}/inventory/sample/ make -C tests INVENTORY_DIR=${ANSIBLE_INVENTORY} create-${CI_PLATFORM} -s + +# Test collection build and install by installing our collection, emptying our repository, adding +# cluster.yml, reset.yml, and remote-node.yml files that simply point to our collection's playbooks, and then +# running the same tests as before +if [[ "${CI_JOB_NAME}" =~ "collection" ]]; then + # Build and install collection + ansible-galaxy collection build + ansible-galaxy collection install kubernetes_sigs-kubespray-$(grep "^version:" galaxy.yml | awk '{print $2}').tar.gz + + # Simply remove all of our files and directories except for our tests directory + # to be absolutely certain that none of our playbooks or roles + # are interfering with our collection + find -mindepth 1 -maxdepth 1 ! -regex './\(tests\|inventory\)' -exec rm -rfv {} + + +cat > cluster.yml < upgrade-cluster.yml < reset.yml < remove-node.yml < cluster.yml < reset.yml < remove-node.yml < Date: Fri, 13 Dec 2024 16:09:02 +0100 Subject: [PATCH 2/2] CI: test collections in one packet job --- .gitlab-ci/packet.yml | 2 +- ...ebian11-calico.yml => packet_debian11-calico-collection.yml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/files/{packet_debian11-calico.yml => packet_debian11-calico-collection.yml} (100%) diff --git a/.gitlab-ci/packet.yml b/.gitlab-ci/packet.yml index 2ed183c6a..1bb0405d3 100644 --- a/.gitlab-ci/packet.yml +++ b/.gitlab-ci/packet.yml @@ -94,7 +94,7 @@ packet_almalinux8-crio: packet_almalinux8-kube-ovn: extends: .packet_pr -packet_debian11-calico: +packet_debian11-calico-collection: extends: .packet_pr packet_debian11-macvlan: diff --git a/tests/files/packet_debian11-calico.yml b/tests/files/packet_debian11-calico-collection.yml similarity index 100% rename from tests/files/packet_debian11-calico.yml rename to tests/files/packet_debian11-calico-collection.yml