source: issm/oecreview/Archive/16554-17801/ISSM-16605-16606.diff@ 17802

Last change on this file since 17802 was 17802, checked in by Mathieu Morlighem, 11 years ago

Added archives

File size: 8.0 KB
RevLine 
[17802]1Index: ../trunk-jpl/scripts/jenkins.sh
2===================================================================
3--- ../trunk-jpl/scripts/jenkins.sh (revision 16605)
4+++ ../trunk-jpl/scripts/jenkins.sh (revision 16606)
5@@ -1,328 +0,0 @@
6-#!/bin/bash
7-#This bash script calls the nightlyrun.m matlab file to run our nightly test decks.
8-#It then processes the results and sends an email to the Ice developpers.
9-
10-#some functions
11-function timer() #{{{
12-{
13- if [[ $# -eq 0 ]]; then
14- echo $(date '+%s')
15- else
16- local stime=$1
17- etime=$(date '+%s')
18-
19- if [[ -z "$stime" ]]; then stime=$etime; fi
20-
21- dt=$((etime - stime))
22- ds=$((dt % 60))
23- dm=$(((dt / 60) % 60))
24- dh=$((dt / 3600))
25- printf '%d:%02d:%02d' $dh $dm $ds
26- fi
27-} #}}}
28-function todaydate() #{{{
29-{
30- suffix=`date | awk '{printf("%s-%s-%s %s",$2,$3,$6,$4);}'`
31- echo $suffix;
32-} #}}}
33-function host_name() #{{{
34-{
35- #return host name depending on the OS
36- if [ "$1" = "win7" ]
37- then
38- HOST_NAME=`hostname | sed 's/-//g'`;
39- else
40- HOST_NAME=`hostname -s | sed 's/-//g'`;
41- fi
42- echo $HOST_NAME;
43-} #}}}
44-function pause() #{{{
45-{
46-pid=`ps aux -W | grep $1 | awk '{printf("%s\n",$1);}'`
47-
48-while [ -n "$pid" ]
49-do
50- pid=`ps aux -W | grep $1 | awk '{printf("%s\n",$1);}'`
51-done
52-}
53-#}}}
54-
55-#Get configuration
56-#Source config file{{{
57-if [ $# -ne 1 ];
58-then
59- #no config file specified: exit
60- echo "no config file specified. Exiting..." >&2 # Error message to stderr.
61- exit 1
62-fi
63-if [ ! -f "$1" ]
64-then
65- echo "File $1 not found!" >&2 # Error message to stderr.
66- exit 1
67-fi
68-source $1;
69-#}}}
70-#Export ISSM_* variables{{{
71-export ISSM_DIR
72-export ISSM_ARCH
73-#}}}
74-#Initialize variables {{{
75-TODAY=$(todaydate);
76-HOST_NAME=$(host_name $OS);
77-OS=$(uname -s)
78-START_TIME=$(timer);
79-ISSM_RELEASE=$(basename $(echo $REPOSITORY));
80-USER=$(whoami);
81-INIT_PATH=$(pwd);
82-#}}}
83-
84-#Installation ISSM
85-#create matlab's installation sript {{{
86-cat << END > $ISSM_DIR/externalpackages/matlab/install.sh
87-#!/bin/bash
88-rm -rf install
89-ln -s $MATLAB_PATH install
90-END
91-#}}}
92-#install/copy/none external packages (ISSM_EXTERNALPACKAGES){{{
93-if [ "$ISSM_EXTERNALPACKAGES" == "install" ]
94-then
95-
96- cd $ISSM_DIR/externalpackages
97-
98- #number of packages:
99- NUMPACKAGES=$(($(echo $EXTERNALPACKAGES | wc -w )/2))
100-
101- for ((i=1;i<=$NUMPACKAGES;i++))
102- do
103- NUM1=$((2*$i-1))
104- NUM2=$((2*$i))
105- PACKAGENAME=$(echo $EXTERNALPACKAGES | cut -d " " -f $NUM1-$NUM1)
106- PACKAGEINST=$(echo $EXTERNALPACKAGES | cut -d " " -f $NUM2-$NUM2)
107-
108- cd $PACKAGENAME
109- echo "======================================================";
110- echo " Installing $PACKAGENAME ";
111- echo "======================================================";
112- ./$PACKAGEINST | tee compil.log
113- if [ $? -ne 0 ]; then
114- echo "======================================================";
115- echo " ERROR: installation of $PACKAGENAME failed ";
116- echo "======================================================";
117- fi
118- source $ISSM_DIR/etc/environment.sh
119- cd ..
120- done
121-
122-elif [ "$ISSM_EXTERNALPACKAGES" == "copy" ]
123-then
124- cd $ISSM_DIR
125- rm -rf externalpackages
126- cp -Rf $EXTERNALPACKAGESDIR ./
127-elif [ "$ISSM_EXTERNALPACKAGES" == "link" ]
128-then
129- cd $ISSM_DIR
130- rm -rf externalpackages
131- ln -s $EXTERNALPACKAGESDIR .
132-elif [ "$ISSM_EXTERNALPACKAGES" == "none" ]
133-then
134- echo "Skipping external packages installation"
135-else
136- echo "ISSM_EXTERNALPACKAGES supported values are: install, copy and none. Exiting..." >&2 # Error message to stderr.
137- exit 1
138-fi
139-source $ISSM_DIR/etc/environment.sh
140-#}}}
141-#ISSM compilation yes/no (ISSM_COMPILATION) {{{
142-if [ "$ISSM_COMPILATION" == "yes" ]
143-then
144- cd $ISSM_DIR
145- make uninstall
146- make clean
147- make distclean
148- ./scripts/automakererun.sh
149- cat > configure.sh << EOF
150-./configure $ISSM_CONFIG
151-EOF
152- chmod 700 configure.sh
153- ./configure.sh
154-
155- #4: compile and install ISSM
156- if [ $NUMCPUS_INSTALL -gt 1 ]
157- then
158- echo "Making with " $NUMCPUS_INSTALL " cpus"
159- make -j $NUMCPUS_INSTALL install
160- else
161- make install
162- fi
163-elif [ "$ISSM_COMPILATION" == "no" ]
164-then
165- echo "Skipping ISSM compilation"
166-else
167- echo "ISSM_COMPILATION supported values are: yes and no. Exiting..." >&2 # Error message to stderr.
168- exit 1
169-fi
170-#}}}
171-
172-#Prepare info.log
173-#{{{
174-rm -rf $ISSM_DIR/nightlylog
175-mkdir $ISSM_DIR/nightlylog
176-INSTALL_TIME=$(timer)
177-ELAPSED=$(timer $START_TIME)
178-VERSION=$(svnversion $ISSM_DIR)
179-cat << END > $ISSM_DIR/nightlylog/info.log
180-name: $(echo $NAME)
181-today: $(echo $TODAY)
182-user: $(echo $USER)
183-host: $(echo $HOST_NAME)
184-OS: $(echo $OS)
185-release: $(echo $ISSM_RELEASE)
186-init_path: $(echo $INIT_PATH)
187-is_matlab: $(echo $MATLAB_TEST)
188-is_python: $(echo $PYTHON_TEST)
189-elapsed_install: $(echo $ELAPSED)
190-version: $(echo $VERSION)
191-END
192-#}}}
193-
194-#matlab tests
195-if [ $MATLAB_TEST -eq 1 ]; then
196-#Launch all tests on different cpus {{{
197-MATLAB_START_TIME=$(timer);
198-for (( i=1;i<=$NUMCPUS_RUN;i++ ))
199-do
200- #Launch matlab and the nightly run script
201- cat > $ISSM_DIR/nightlylog/matlab_run$i.m << EOF
202- warning off %necessary to avoid a info.log of several Go for parallel runs
203- try,
204- $(if [ "$MATLAB_NROPTIONS" = "" ]
205- then
206- echo "runme('output','nightly','rank',$i,'numprocs',$NUMCPUS_RUN);"
207- else
208- echo "runme($MATLAB_NROPTIONS,'output','nightly','rank',$i,'numprocs',$NUMCPUS_RUN);"
209- fi
210- )
211- catch me,
212- %An error occured, get report and exit
213- message=getReport(me)
214- directory=strsplit(pwd,'/');
215- fid=fopen([issmdir '/nightlylog/matlaberror.log'], 'at');
216- fprintf(fid,'\nMatlab error occured in: %s\n\n',directory{end});
217- fprintf(fid,'%s',message);
218- fclose(fid);
219- end
220- disp('MATLABEXITEDCORRECTLY');
221- exit
222-EOF
223- cd $ISSM_DIR/test/NightlyRun
224- matlab -nojvm -nosplash -r "addpath $ISSM_DIR/src/m/dev; devpath; addpath $ISSM_DIR/nightlylog/; matlab_run$i" -logfile $ISSM_DIR/nightlylog/matlab_log$i.log &
225-done
226-
227-#wait until matlab closes
228-if [ "$OS" = "win7" ]; then
229- pause MATLAB
230-else
231- wait
232-fi
233-
234-#concatenate reports
235-cd $ISSM_DIR/nightlylog/
236-rm matlab_log.log
237-for (( i=1;i<=$NUMCPUS_RUN;i++ ))
238-do
239- cat matlab_log$i.log >> matlab_log.log
240-done
241-#}}}
242-#Complete info.log {{{
243-if [ $(cat matlab_log.log | grep "MATLABEXITEDCORRECTLY" | wc -l) -eq $NUMCPUS_RUN ]
244-then
245- MATLABCRASH=0
246-else
247- MATLABCRASH=1
248-fi
249-ELAPSED=$(timer $MATLAB_START_TIME)
250-cat << END >> $ISSM_DIR/nightlylog/info.log
251-elapsed_matlab: $(echo $ELAPSED)
252-matlab_crash: $(echo $MATLABCRASH)
253-END
254-#}}}
255-fi
256-
257-#python tests
258-if [ $PYTHON_TEST -eq 1 ]; then
259-#Launch all tests on different cpus {{{
260-PYTHON_START_TIME=$(timer);
261-export PYTHONSTARTUP=$ISSM_DIR/src/m/dev/devpath.py
262-for (( i=1;i<=$NUMCPUS_RUN;i++ ))
263-do
264- cd $ISSM_DIR/test/NightlyRun
265- ./runme.py --output=nightly --rank=$i --numprocs=$NUMCPUS_RUN $PYTHON_NROPTIONS 2>&1 > $ISSM_DIR/nightlylog/python_log$i.log &
266-done
267-
268-#wait until python closes
269-if [ "$OS" = "win7" ]; then
270- pause MATLAB
271-else
272- wait
273-fi
274-
275-#concatenate reports
276-cd $ISSM_DIR/nightlylog/
277-rm python_log.log
278-for (( i=1;i<=$NUMCPUS_RUN;i++ ))
279-do
280- cat python_log$i.log >> python_log.log
281-done
282-#}}}
283-#Complete info.log {{{
284-if [ $(cat python_log.log | grep "PYTHONEXITEDCORRECTLY" | wc -l) -eq $NUMCPUS_RUN ]
285-then
286- PYTHONCRASH=0
287-else
288- PYTHONCRASH=1
289-fi
290-ELAPSED=$(timer $PYTHON_START_TIME)
291-cat << END >> $ISSM_DIR/nightlylog/info.log
292-elapsed_python: $(echo $ELAPSED)
293-python_crash: $(echo $PYTHONCRASH)
294-END
295-#}}}
296-fi
297-
298-#complete info.log
299-#{{{
300-ELAPSED=$(timer $START_TIME)
301-cat << END >> $ISSM_DIR/nightlylog/info.log
302-elapsed_total: $(echo $ELAPSED)
303-END
304-#}}}
305-
306-#Send Report
307-#Build html report {{{
308-cd $ISSM_DIR/nightlylog/
309-sh ../scripts/report.sh
310-echo "html report located in $ISSM_DIR/nightlylog/report.html"
311-#}}}
312-#send mail if requested (SKIPMAIL) {{{
313-if [ "$SKIPMAIL" != "yes" ]
314-then
315- echo "sending report..."
316- for i in `echo $MAILINGLIST`; do
317-
318-cat - $ISSM_DIR/nightlylog/report.html <<HERE | /usr/lib/sendmail -oi -t
319-From: "ISSM Nightly run" <$EMAIL_ADRESS>
320-To: $i
321-Subject: ISSM nightly runs report: $NAME
322-Mime-Version: 1.0
323-Content-Type: text/html
324-HERE
325- done
326-fi
327-#}}}
328-
329-#remove lock file
330-#{{{
331-cd $ISSM_DIR/../
332-rm NIGHTLYLOCK
333-#}}}
Note: See TracBrowser for help on using the repository browser.