#!/bin/bash set -euxo pipefail echo "CI_JOB_NAME is $CI_JOB_NAME" if [[ "$CI_JOB_NAME" =~ "upgrade" ]]; then if [ "${UPGRADE_TEST}" == "false" ]; then echo "Job name contains 'upgrade', but UPGRADE_TEST='false'" exit 1 fi else if [ "${UPGRADE_TEST}" != "false" ]; then echo "UPGRADE_TEST!='false', but job names does not contain 'upgrade'" exit 1 fi fi # Check out latest tag if testing upgrade if [ "${UPGRADE_TEST}" != "false" ]; then git fetch --all && git checkout "$KUBESPRAY_VERSION" # Checkout the current tests/ directory ; even when testing old version, # we want the up-to-date test setup/provisionning git checkout "${CI_COMMIT_SHA}" -- tests/ fi export ANSIBLE_REMOTE_USER=$SSH_USER export ANSIBLE_BECOME=true 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 <