-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrun-integration-tests.sh
executable file
·57 lines (41 loc) · 1.7 KB
/
run-integration-tests.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
52
53
54
55
56
#!/usr/bin/env bash
set -o nounset # exit with non-zero status if expansion is attempted on an unset variable
set -o errexit # exit immediately if a pipeline, a list, or a compound command fails
set -o pipefail # failures in pipe in the commands before last one, also count as failures
# Trapping non-zero exit codes:
on_error() {
line_num="$1"
echo "Caught error on line $line_num"
}
on_exit() {
true
}
on_interrupt() {
true
}
trap 'on_error $LINENO' ERR
trap on_exit EXIT
trap on_interrupt INT
echo "Start integration testing of Python package 'sportmonks'"
source ~/sportmonks/functions.sh
set_environment_variables
activate_virtual_environment
echo "Loading SportMonks API key from environment variable SPORTMONKS_API_KEY, with fallback to ~/.sportmonks_api_key file."
# Check if variable is set (https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash)
if [[ -z ${SPORTMONKS_API_KEY+x} ]]; then
echo "Environment variable SPORTMONKS_API_KEY not set. Falling back to ~/.sportmonks_api_key"
echo "Check if ~/.sportmonks_api_key exists"
if [[ -f ~/.sportmonks_api_key ]]; then
echo "~/.sportmonks_api_key exists."
sportmonks_api_key=$(head -1 ~/.sportmonks_api_key | tr -d '\n')
echo "Loaded API key from ~/.sportmonks_api_key"
else
echo "~/.sportmonks_api_key does not exist. Quit with exit code 1."
exit 1
fi
else
sportmonks_api_key=$(echo $SPORTMONKS_API_KEY)
echo "Loaded API key from environment variable SPORTMONKS_API_KEY"
fi
echo "Run the tests"
PYTHONPATH=~/sportmonks $PYTHON -m pytest -vv --sportmonks-api-key "$sportmonks_api_key" ~/sportmonks/integration-tests --log-cli-level=INFO