-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·51 lines (41 loc) · 1.11 KB
/
test.sh
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
#!/usr/bin/env bash
set -e
VENV_PRESENT=true
check_venv() {
if [ -z "$VIRTUAL_ENV" ]
then
printf '\e[1;33m[WARN] Looks like Python virtualenv is deactivated. Trying to activate it automatically..\e[0m\n'
export VENV_PRESENT=false
virtualenv venv
if ! source venv/bin/activate
then
printf "\e[1;31m[ERROR] Automatic virtualenv activation failed! Run 'virtualenv venv' manually and try again.\e[0m\n"
exit 1
fi
fi
}
install_deps() {
pip3 install --upgrade -r test-requirements.txt
## Uncomment to install Galaxy collections or roles
# ansible-galaxy collection install -r requirements.yml
# ansible-galaxy install -f -p roles -r requirements.yml
}
run_tests() {
molecule lint
}
##############
## MAIN ##
##############
main() {
check_venv
install_deps
if [ -f molecule/default/molecule.yml ]
then
run_tests
else
printf '\n\e[1;33m[WARN] Skipping tests due to Molecule not being configured for the role.
Run "molecule init scenario -r my_role_name -d vagrant" command from within the role directory (e.g. my_role_name/).
\e[0m\n'
fi
}
main "$@"