Skip to content
Snippets Groups Projects
Select Git revision
  • e92f09b920e89aa7b70f55f67dc3d9fe88dad586
  • master default protected
  • v1.14.7
  • v1.14.6
  • v1.14.5
  • v1.14.4
  • v1.14.3
  • v1.14.2
  • v1.14.1
  • v1.14.0
  • v1.13.2
  • v1.13.1
  • v1.13.0
  • v1.12.1
  • v1.12.0
  • v1.11.1
  • v1.11.0
  • v1.10.0
  • v1.9.2
  • v1.9.1
  • v1.9.0
  • v1.8.4
22 results

set_test_modules

Blame
  • user avatar
    Rafael Guterres Jeffman authored
    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.
    f6bd62fe
    History
    set_test_modules 2.00 KiB
    #!/bin/bash -eu
    # This file shoud be source'd (. set_test_modules) rather than executed.
    #
    # Set SKIP_GIT_TEST="True" or use -a to prevent git modification comparison.
    #
    
    RED="\033[31;1m"
    RST="\033[0m"
    
    die() {
        echo -e "${RED}${*}${RST}" >&2
    }
    
    BASEDIR="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"
    TOPDIR="$(readlink -f "${BASEDIR}/../../..")"
    
    [ -n "$(command -v python3)" ] && python="$(command -v python3)" || python="$(command -v python2)"
    
    pushd "${TOPDIR}" >/dev/null 2>&1 || die "Failed to change directory."
    
    SKIP_GIT_TEST=${SKIP_GIT_TEST:-"False"}
    
    while getopts ":a" opt
    do
        case "${opt}" in
            a) SKIP_GIT_TEST="True" ;;
            *) ;; # ignore other options
        esac
    done
    
    files_list=$(mktemp)
    
    enabled_modules="None"
    enabled_tests="None"
    
    if [ "${SKIP_GIT_TEST}" != "True" ]
    then
        remote="$(basename "$(mktemp -u remote_XXXXXX)")"
        git remote add "${remote}" https://github.com/freeipa/ansible-freeipa
        git fetch --prune --no-tags --quiet "${remote}"
        git diff "${remote}/master" --name-only > "${files_list}"
        git remote remove "${remote}"
    
        # shellcheck disable=SC2046
        enabled_modules="$(${python} "${BASEDIR}/get_test_modules.py" $(cat "${files_list}"))"
        [ -z "${enabled_modules}" ] && enabled_modules="None"
    
        # Get individual tests that should be executed
        mapfile -t tests < <(sed -n 's#.*/\(test_[^/]*\).yml#\1#p' "${files_list}" | tr -d " ")
        [ ${#tests[@]} -gt 0 ] && enabled_tests=$(IFS=, ; echo "${tests[*]}")
        [ -z "${enabled_tests}" ] && enabled_tests="None"
    
        [ -n "${enabled_tests}" ] && IPA_ENABLED_TESTS="${enabled_tests},${IPA_ENABLED_TESTS}"
        [ -n "${enabled_modules}" ] && IPA_ENABLED_MODULES="${enabled_modules},${IPA_ENABLED_MODULES}"
    
        rm -f "${files_list}"
    fi
    
    # Get all modules that should have tests executed
    
    export IPA_ENABLED_MODULES
    export IPA_ENABLED_TESTS
    
    echo "IPA_ENABLED_MODULES = [${IPA_ENABLED_MODULES}]"
    echo "IPA_ENABLED_TESTS = [${IPA_ENABLED_TESTS}]"
    
    popd >/dev/null 2>&1 || die "Failed to change back to original directory."