From f6bd62feb46b4836c49bb32f660f66c887f5d119 Mon Sep 17 00:00:00 2001
From: Rafael Guterres Jeffman <rjeffman@redhat.com>
Date: Thu, 31 Oct 2024 19:02:19 -0300
Subject: [PATCH] upstream CI: Move scripts that evaluate repo changes to
 infra/azure

All scripts related to the Azure CI now reside on inrfa/azure, but the
scripts that evaluate the changes made against ansible-freeipa's main
development branch.

This patch move these scripts to the proper locations.
---
 {utils => infra/azure/scripts}/get_test_modules.py | 4 ++--
 {utils => infra/azure/scripts}/set_test_modules    | 5 +++--
 infra/azure/templates/run_tests.yml                | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)
 rename {utils => infra/azure/scripts}/get_test_modules.py (98%)
 rename {utils => infra/azure/scripts}/set_test_modules (90%)

diff --git a/utils/get_test_modules.py b/infra/azure/scripts/get_test_modules.py
similarity index 98%
rename from utils/get_test_modules.py
rename to infra/azure/scripts/get_test_modules.py
index 3e9306b0dd..ff4c97043e 100644
--- a/utils/get_test_modules.py
+++ b/infra/azure/scripts/get_test_modules.py
@@ -159,7 +159,7 @@ def map_test_module_sources(base):
     """Create a map of 'test-modules' to 'plugin-sources', from 'base'."""
     # Find root directory of playbook tests.
     script_dir = os.path.dirname(__file__)
-    test_root = os.path.realpath(os.path.join(script_dir, f"../{base}"))
+    test_root = os.path.realpath(os.path.join(script_dir, f"../../../{base}"))
     # create modules:source_files map
     _result = {}
     for test_module in [d for d in os.scandir(test_root) if d.is_dir()]:
@@ -170,7 +170,7 @@ def map_test_module_sources(base):
 
 
 def usage(err=0):
-    print("filter_plugins.py [-h|--help] [-p|--pytest] PY_SRC...")
+    print("get_test_modules.py [-h|--help] [-p|--pytest] PY_SRC...")
     print(
         """
 Print a comma-separated list of modules that should be tested if
diff --git a/utils/set_test_modules b/infra/azure/scripts/set_test_modules
similarity index 90%
rename from utils/set_test_modules
rename to infra/azure/scripts/set_test_modules
index f9f1d91e4a..de09e07c6f 100644
--- a/utils/set_test_modules
+++ b/infra/azure/scripts/set_test_modules
@@ -11,7 +11,8 @@ die() {
     echo -e "${RED}${*}${RST}" >&2
 }
 
-TOPDIR="$(dirname "${BASH_SOURCE[0]}")/.."
+BASEDIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"
+TOPDIR="$(readlink -f "${BASEDIR}/../../..")"
 
 [ -n "$(command -v python3)" ] && python="$(command -v python3)" || python="$(command -v python2)"
 
@@ -41,7 +42,7 @@ then
     git remote remove "${remote}"
 
     # shellcheck disable=SC2046
-    enabled_modules="$(${python} utils/get_test_modules.py $(cat "${files_list}"))"
+    enabled_modules="$(${python} "${BASEDIR}/get_test_modules.py" $(cat "${files_list}"))"
     [ -z "${enabled_modules}" ] && enabled_modules="None"
 
     # Get individual tests that should be executed
diff --git a/infra/azure/templates/run_tests.yml b/infra/azure/templates/run_tests.yml
index 1cc00030bf..ef5c4ff9af 100644
--- a/infra/azure/templates/run_tests.yml
+++ b/infra/azure/templates/run_tests.yml
@@ -46,7 +46,7 @@ jobs:
     displayName: Set repo rootdir
 
   - script: |
-      . "${TOPDIR}/utils/set_test_modules"
+      . "${TOPDIR}/infra/azure/scripts/set_test_modules"
       python3 utils/check_test_configuration.py ${{ parameters.distro }}
     displayName: Check test configuration
     env:
@@ -65,7 +65,7 @@ jobs:
       echo "ROLES: ${ANSIBLE_ROLES_PATH}"
       echo "LIBRARY: ${ANSIBLE_LIBRARY}"
       echo "MODULE_UTILS: ${ANSIBLE_MODULE_UTILS}"
-      . "${TOPDIR}/utils/set_test_modules"
+      . "${TOPDIR}/infra/azure/scripts/set_test_modules"
       [ "${{ parameters.test_galaxy }}" == "True"  ] && cd ~/.ansible/collections/ansible_collections/freeipa/ansible_freeipa
       pytest \
           -m "${{ parameters.test_type }}" \