-
Notifications
You must be signed in to change notification settings - Fork 13
/
psij-ci-run
executable file
·76 lines (67 loc) · 1.58 KB
/
psij-ci-run
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
#!/bin/bash
usage() {
cat <<EOF
Usage: ./psij-ci-run [--help] [--repeat]
--help Displays this message
--repeat If specified, run tests every 24 hours in a loop.
EOF
}
failifempty() {
if [ "$2" == "" ]; then
echo "Missing parameter for $1"
usage
exit 1
fi
}
if [ -f psij-ci-env ]; then
source psij-ci-env
fi
REPEAT=0
RESCHEDULE=0
while [ "$1" != "" ]; do
case "$1" in
--help)
usage
exit 0
;;
--repeat)
REPEAT=1
shift
;;
--reschedule)
RESCHEDULE=1
TIME="$2"
shift 2
;;
*)
echo "Unrecognized command line option: $1."
usage
exit 1
esac
done
if python --version 2>&1 | egrep -q 'Python 3\..*' >/dev/null 2>&1 ; then
PYTHON="python"
else
PYTHON="python3"
fi
# Ensure latest test runner is there
git fetch https://github.com/ExaWorks/psij-python.git
git checkout FETCH_HEAD -- tests/ci_runner.py
if [ "$REPEAT" == "1" ]; then
CRT_TIME=`date +%s`
while true ; do
echo "`date` Running tests..."
$PYTHON tests/ci_runner.py $MODE
echo "`date` Waiting (CTRL+C to interrupt)..."
CRT_TIME=$((CRT_TIME + 86400))
NOW=`date +%s`
TO_SLEEP=$((CRT_TIME - NOW))
sleep $TO_SLEEP
done
elif [ "$RESCHEDULE" == "1" ]; then
CMD="./psij-ci-run --reschedule $TIME >> testing.log 2>&1"
echo "$CMD" | at $TIME
$PYTHON tests/ci_runner.py $MODE
else
$PYTHON tests/ci_runner.py $MODE
fi