1#!/usr/local/bin/bash
2
3set -o pipefail -eux
4
5declare -a args
6IFS='/:' read -ra args <<< "$1"
7
8group="${args[1]}"
9
10if [ "${BASE_BRANCH:-}" ]; then
11    base_branch="origin/${BASE_BRANCH}"
12else
13    base_branch=""
14fi
15
16if [ "${group}" == "extra" ]; then
17    ../internal_test_tools/tools/run.py --color --bot --junit
18    exit
19fi
20
21case "${group}" in
22    1) options=(--skip-test pylint --skip-test ansible-doc --skip-test validate-modules) ;;
23    2) options=(                   --test      ansible-doc      --test validate-modules) ;;
24    3) options=(--test pylint           plugins/modules/) ;;
25    4) options=(--test pylint --exclude plugins/modules/) ;;
26esac
27
28# allow collection migration sanity tests for groups 3 and 4 to pass without updating this script during migration
29network_path="lib/ansible/modules/network/"
30
31if [ -d "${network_path}" ]; then
32    if [ "${group}" -eq 3 ]; then
33        options+=(--exclude "${network_path}")
34    elif [ "${group}" -eq 4 ]; then
35        options+=("${network_path}")
36    fi
37fi
38
39# shellcheck disable=SC2086
40ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \
41    --docker --base-branch "${base_branch}" \
42    "${options[@]}" --allow-disabled
43