blob: e5d73912a2d58264668adc1019fdfdc7fc09fa6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
#!/usr/bin/env bash
set -o pipefail -eux
error() {
echo >&2 "error: $*"
exit 1
}
retry() {
local exit_code=1
for _ in 1 2 3; do
set +e
"$@"
exit_code=$?
set -e
if [ $exit_code == 0 ]; then
return $exit_code
fi
done
echo "Command '$*' failed 3 times!"
exit $exit_code
}
declare -a entry_point_args
IFS='/:' read -ra entry_point_args <<< "$1"
# Explode entry point args, for example '2.16/integration/3.10/2' or '2.16/sanity'
ansible_version="${entry_point_args[0]}"
test_name="${entry_point_args[1]}"
python_version="${entry_point_args[2]:-}"
test_group="${entry_point_args[3]:-}"
export PYTHONIOENCODING="utf-8"
export PIP_DISABLE_PIP_VERSION_CHECK=true
export PIP_NO_WARN_SCRIPT_LOCATION=false # Negative options are a bit weird: https://pip.pypa.io/en/stable/topics/configuration/#boolean-options
export ANSIBLE_COLLECTIONS_PATH="$PWD/../.."
command -v python
python -V
command -v pip
pip --version
pip list
if [ "$ansible_version" == "devel" ]; then
pip install "https://github.com/ansible/ansible/archive/devel.tar.gz"
else
pip install "https://github.com/ansible/ansible/archive/stable-$ansible_version.tar.gz"
fi
command -v ansible
ansible --version
# Prepare coverage args
if $COVERAGE; then
coverage_args="--coverage"
elif [[ "$COMMIT_MESSAGE" =~ ci_coverage ]]; then
coverage_args="--coverage"
else
coverage_args="--coverage-check"
fi
# Prepare changed args
if $COMPLETE; then
changed_args=""
elif [[ "$COMMIT_MESSAGE" =~ ci_complete ]]; then
changed_args=""
else
changed_args="--changed"
fi
# Prepare unstable args
if $IS_PULL_REQUEST; then
unstable_args="--allow-unstable-changed"
else
unstable_args=""
fi
# Install dependencies
pip install rstcheck
# Ensure we can write other collections to this dir
sudo chown "$(whoami)" "$ANSIBLE_COLLECTIONS_PATH"
pip install -r tests/integration/requirements.txt -c tests/constraints.txt
ansible-galaxy -vvv collection install -r tests/requirements.yml
# Dump env and set timeout
timeout=45
if $COVERAGE; then
timeout=60
fi
ansible-test env --color -v --dump --show --timeout "$timeout"
# Run tests
case "$test_name" in
sanity)
# shellcheck disable=SC2086
ansible-test sanity --color -v \
--exclude plugins/module_utils/vendor/ \
--exclude scripts/ \
--exclude tests/utils/ \
--docker default \
--junit \
$coverage_args \
$changed_args \
--allow-disabled
;;
units)
# shellcheck disable=SC2086
ansible-test units --color -v \
--docker default \
--python "$python_version" \
$coverage_args \
$changed_args
;;
integration)
# shellcheck disable=SC2086
ansible-test integration --color -v \
--remote-terminate always \
--remote-stage prod \
--docker default \
--python "$python_version" \
--retry-on-error \
$coverage_args \
$changed_args \
--changed-all-target none \
--changed-all-mode include \
$unstable_args \
"azp/group$test_group/"
;;
*)
error "found invalid test_name: $test_name"
;;
esac
|