-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheanthony.sh
executable file
·137 lines (118 loc) · 3.59 KB
/
eanthony.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
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
#!/bin/bash
#set -x
BASEDIR=$EABASEDIR
if [ -z $BASEDIR ] || [ ! -d $BASEDIR ]; then
echo "you need to set an existing basedir in \$EABASEDIR"
exit -1
fi
uname | grep -v CYGWIN > /dev/null
ISWIN=$?
while :
do
RUNID=`date +%s`
echo $RUNID
date
git -C $BASEDIR pull
# these files need to exist and denote R version and MonetDB HG branch to use
RTAG=`cat $BASEDIR/r-tag`
RUNTESTS=$BASEDIR/runtests
if [ -z $RTAG ] ; then
echo "need to define R version in $RTAG"
exit -1
fi
if [ ! -f $RUNTESTS ] ; then
echo "need to define tests to run in $RUNTESTS"
exit -1
fi
RSRCDIR=$BASEDIR/r-source-$RTAG
RINSTALLDIR=$BASEDIR/r-install-$RTAG
RBIN=$RINSTALLDIR/bin/R
if [ $ISWIN -eq 1 ]; then
RBIN=$RBIN.exe
fi
# R packages should be reinstalled with new R version
RLIBDIR=$BASEDIR/r-packages-$RTAG
RTMPDIR=$BASEDIR/r-tmp
RWDDIR=$BASEDIR/r-wd
LOGDIR=$BASEDIR/logs/$RUNID
find $RTMPDIR -name "Rtmp*" -type d -exec chmod -R 700 {} + -exec rm -rf {} +
rm -rf $RWDDIR/*
rm $BASEDIR/logs/current
ln -s $LOGDIR $BASEDIR/logs/current
mkdir -p $RSRCDIR $RLIBDIR $RTMPDIR $RWDDIR $LOGDIR $RINSTALLDIR
if [ ! -d $MINSTALLDIR ]; then
echo "Unable to make install dirs."
exit -1
fi
# build R
# TODO: remove old R source/install/packages dirs
# TODO: auto-install new R versions on Windows?
echo $RTAG > $LOGDIR/r-version
if [ ! -f $RBIN ] && [ $ISWIN -eq 0 ] ; then
RTBURL="https://cran.r-project.org/src/base/R-3/R-$RTAG.tar.gz"
curl -s $RTBURL | tar xz -C $RSRCDIR --strip-components=1
cd $RSRCDIR
./configure --prefix=$RINSTALLDIR --with-x=no --without-recommended-packages > $LOGDIR/r-configure.log 2>&1
make DEBUG=T > $LOGDIR/r-make.log 2>&1
# make R install without latex
touch $RSRCDIR/doc/NEWS.pdf
touch $RSRCDIR/doc/RESOURCES
touch $RSRCDIR/doc/FAQ
make install >> $LOGDIR/r-make.log 2>&1
cd ..
fi
if [ ! -f $RBIN ] ; then
echo "Still no R. FML."
exit -1
fi
export R_LIBS=$RLIBDIR PATH=$RINSTALLDIR/bin:/cygdrive/c/Rtools/bin:$PATH TMP=$RTMPDIR TEMP=$RTMPDIR
# install/update various packages
$RBIN -f $BASEDIR/packages.R > $LOGDIR/packages.log 2>&1
# record versions of installed packages
$RBIN --slave -e "write.table(installed.packages(lib.loc='$RLIBDIR')[, c('Package','Version')], '$LOGDIR/package-versions', sep='\t', quote=F, row.names=F, col.names=F)"
if [ $? != 0 ]; then
echo "Package installation failure"
continue
else
touch $LOGDIR/packages-success
fi
sleep 1
cp $RUNTESTS $LOGDIR
RTESTS=`cat $RUNTESTS | shuf`
for RSCRIPT in $RTESTS ; do
if [ -z $RSCRIPT ] || [ ! -f $BASEDIR/$RSCRIPT-setup.R ] ; then
echo "Could not run $RSCRIPT"
continue
fi
(echo "running $RSCRIPT"
touch $LOGDIR/$RSCRIPT-started
export RWD=$RWDDIR/$RSCRIPT-$RUNID
export TMP=$RTMPDIR/$RSCRIPT TEMP=$RTMPDIR/$RSCRIPT
mkdir -p $TMP
mkdir -p $RWD
set -o pipefail
timeout -k 40h 30h $RBIN -f $BASEDIR/$RSCRIPT-setup.R 2>&1 | awk '{print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' > $LOGDIR/$RSCRIPT.log
SETUPRC=$?
echo -e "\nsetup return code=$SETUPRC" >> $LOGDIR/$RSCRIPT.log
if [ $SETUPRC != 0 ]; then
echo "$RSCRIPT setup fail"
else
touch $LOGDIR/$RSCRIPT-setup-success
timeout -k 40h 30h $RBIN -f $BASEDIR/$RSCRIPT-test.R 2>&1 | awk '{print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' >> $LOGDIR/$RSCRIPT.log
TESTRC=$?
echo -e "\ntest return code=$TESTRC" >> $LOGDIR/$RSCRIPT.log
if [ $TESTRC != 0 ]; then
echo "$RSCRIPT test fail"
else
touch $LOGDIR/$RSCRIPT-test-success
fi
fi
touch $LOGDIR/$RSCRIPT-complete
rm -rf $RWD
) &
sleep 1
done
wait
touch $LOGDIR/complete
sleep 10
done