nightly-test for public repo master
authorgebele <gebele@in-silico.ch>
Mon, 12 Nov 2018 15:06:44 +0000 (16:06 +0100)
committergebele <gebele@in-silico.ch>
Mon, 12 Nov 2018 15:06:44 +0000 (16:06 +0100)
.gitignore [new file with mode: 0644]
Dockerfile [new file with mode: 0644]
nightly.sh [new file with mode: 0755]
start.sh [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..5093a29
--- /dev/null
@@ -0,0 +1 @@
+scripts/
diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..d7db2bc
--- /dev/null
@@ -0,0 +1,53 @@
+FROM        base/archlinux
+MAINTAINER  in-silico toxicology GmbH
+
+RUN         pacman-db-upgrade && pacman -Syyu --noconfirm && pacman -S --noconfirm \
+            base-devel \
+            boost-libs \
+            cmake \
+            eigen3 \
+            fontconfig \
+            gcc-fortran \
+            git \
+            gsl \
+            jre10-openjdk-headless \
+            msmtp \
+            msmtp-mta \
+            mongodb \
+            mongodb-tools \
+            r \
+            ruby \
+            swig \
+            vim \
+            wget && pacman -Scc --noconfirm
+
+RUN         useradd -ms /bin/bash ist
+RUN         echo "ist ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
+
+RUN         mkdir -p /data/db
+USER        ist
+WORKDIR     /home/ist
+
+RUN         echo 'export GEM_HOME=$(ruby -e 'print Gem.user_dir')' > ~/.bashrc
+
+RUN         sudo R -e "install.packages('Rserve', repos='http://rforge.net/')"
+
+RUN         echo 'gem: --user-install --no-document' > ~/.gemrc
+ENV         PATH $PATH:/home/ist/.gem/ruby/2.5.0/bin
+
+RUN         gem install bundler
+
+RUN         git clone https://github.com/opentox/lazar.git && \
+            cd lazar && \
+            ruby ext/lazar/extconf.rb && \
+            bundle install --path ~/.gem
+
+RUN         mkdir -p /home/ist/log
+
+COPY        nightly.sh /home/ist/nightly.sh
+RUN         sudo chmod +x /home/ist/nightly.sh
+
+COPY        start.sh /home/ist/start.sh
+RUN         sudo chmod +x /home/ist/start.sh
+
+ENTRYPOINT  ["/home/ist/start.sh"]
diff --git a/nightly.sh b/nightly.sh
new file mode 100755 (executable)
index 0000000..4c92659
--- /dev/null
@@ -0,0 +1,110 @@
+#!/bin/bash
+
+
+TITLE="master"
+HOME="/home/ist"
+LAZARDIR="$HOME/lazar"
+LAZARGUI="$HOME/lazar-gui"
+BRANCH="master"
+
+. $HOME/.bashrc
+
+GIT=`which git`
+DATE=`date +%y%m%d`
+separator="============================"
+
+LOGDIR="$HOME/log"
+COMID="$LOGDIR/id.log"
+ERRLOG="$LOGDIR/$DATE-err.log"
+LOG="$LOGDIR/$DATE.log"
+MSG="$HOME/msg.log"
+rm "$LOG" 2>/dev/null
+rm "$ERRLOG" 2>/dev/null
+rm "$MSG" 2>/dev/null
+
+touch $COMID
+touch $LOG
+touch $ERRLOG
+touch $MSG
+
+if ! cd "$LAZARDIR"; then
+  echo "lazar dir not found."
+  exit 1
+fi
+
+# pull lazar code from github
+if ! $GIT checkout $BRANCH; then
+  echo "lazar checkout to $BRANCH failed."
+  exit 1
+fi
+
+if ! $GIT pull; then
+  echo "lazar pull failed."
+  exit 1
+fi
+
+if ! cd $LAZARDIR/test; then
+  echo "test dir not found."
+  exit 1
+fi
+
+
+task_out=""
+echo "https://github.com/opentox/lazar | branch: $BRANCH | latest commit:" >> $MSG
+$GIT log|head -6 | tee -a $LOG $MSG
+echo $separator >>$MSG
+
+
+cd $LAZARDIR/test
+tests=(*.rb)
+exclude=(setup.rb all.rb default_environment.rb model-nanoparticle.rb nanomaterial-model-validation.rb validation-nanoparticle.rb)
+for i in ${exclude[@]}; do
+  # delete exclute from tests list
+  tests=(${tests[@]//*$i*})
+done
+
+for t in ${tests[@]}; do
+  echo $separator | tee -a $LOG $MSG
+  echo " "$t|tr [a-z] [A-Z] | tee -a $LOG $MSG
+  echo " "`date` | tee -a $LOG $MSG
+  echo $separator | tee -a $LOG $MSG
+  echo ruby $t | tee -a $LOG $MSG
+  # whole test output to logfile only
+  ruby $t >> $LOG
+  # take last occurrence of regex to end of the file
+  awk '/^Finished in/ { buf = "" } { buf = buf "\n" $0 } END { print buf }' $LOG >> $MSG
+  echo "" >> $LOG
+done
+
+cd $LAZARGUI/test
+tests=(*.rb)
+for t in ${tests[@]}; do
+  echo $separator | tee -a $LOG $MSG
+  echo " "$t|tr [a-z] [A-Z] | tee -a $LOG $MSG
+  echo " "`date` | tee -a $LOG $MSG
+  echo $separator | tee -a $LOG $MSG
+  echo ruby $t | tee -a $LOG $MSG
+  # whole test output to logfile only
+  ruby $t >> $LOG
+  # take last occurrence of regex to end of the file
+  awk '/^Finished in/ { buf = "" } { buf = buf "\n" $0 } END { print buf }' $LOG >> $MSG
+  echo "" >> $LOG
+done
+
+# MAIL 
+file="$HOME/scripts/recipients"
+recipients=$(cat $file) 
+if grep -q "Error:" $LOG; then ERRMSG=" ERROR (`grep -c ' Error:' $LOG`)"; else ERRMSG=" OK "; fi
+if grep -q "Failure:" $LOG; then FAILMSG=" FAIL (`grep -c ' Failure:' $LOG`)"; else FAILMSG=""; fi
+
+for p in ${recipients[@]}; do
+  { printf "To: $p\nSubject: [lazar nightly test] -$TITLE- $DATE $ERRMSG $FAILMSG\n"; cat $MSG; } | msmtp -a default $p
+done
+
+# drop database
+mongo development --eval "db.dropDatabase()"
+
+rm $COMID
+touch $COMID
+$GIT log|head -1 >> $COMID
+exit 0
diff --git a/start.sh b/start.sh
new file mode 100755 (executable)
index 0000000..c0a4312
--- /dev/null
+++ b/start.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+sudo pacman-db-upgrade &&
+sudo pacman -Syyu --noconfirm
+sudo /usr/bin/mongod &
+R CMD Rserve --vanilla &
+ln -s "$HOME/scripts/.msmtprc" "$HOME/.msmtprc"
+sudo chown ist:ist ~/.msmtprc
+sudo chmod 600 ~/.msmtprc
+./nightly.sh