Changeset 25916
- Timestamp:
- 12/29/20 13:27:50 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/jenkins/jenkins.sh ¶
r25878 r25916 1 1 #!/bin/bash 2 2 ################################################################################ 3 # This bashscript manages installation of ISSM on a given Jenkins node using a3 # This script manages installation of ISSM on a given Jenkins node using a 4 4 # configuration file passed as the only argument. This file also contains 5 5 # details about which nightly run tests should be executed after the build has … … 23 23 #Get configuration 24 24 #Source config file{{{ 25 if [ $# -ne 1 ]; 26 then 25 if [ $# -ne 1 ]; then 27 26 #no config file specified: exit 28 27 echo "no config file specified. Exiting..." >&2 # Error message to stderr. 29 28 exit 1 30 29 fi 31 if [ ! -f "$1" ] 32 then 30 if [ ! -f "$1" ]; then 33 31 echo "File $1 not found!" >&2 # Error message to stderr. 34 32 exit 1 … … 46 44 NUMCPUS_RUN=1 47 45 48 49 46 #source configuration script 50 47 source $1; 51 48 #}}} 49 50 if [[ $EXAMPLES_TEST -eq 1 && $MATLAB_TEST+$PYTHON_TEST+$JAVASCRIPT_TEST -ne 0 ]]; then 51 echo "When running examples tests, set *only* EXAMPLES_TEST=1" 52 exit 1 53 fi 54 52 55 #Get Operating system (OS) name{{{ 53 56 OS=$(uname -s) … … 62 65 echo " Determining Installation type " 63 66 echo "======================================================"; 64 if [ -a $ISSM_DIR/svn_revision_old ] 65 then 67 if [ -a $ISSM_DIR/svn_revision_old ]; then 66 68 SVN_PREVIOUS=$(cat $ISSM_DIR/svn_revision_old) 67 69 SVN_CURRENT=$SVN_REVISION_1 … … 97 99 # If the contents of the externalpackages directory were modified in any 98 100 # way, check for changed external packages 99 if [ ! -z "$(cat $ISSM_DIR/TEMP | grep externalpackages)" ] 100 echo " -- checking for changed externalpackages... yes" ;101 if [ ! -z "$(cat $ISSM_DIR/TEMP | grep externalpackages)" ]; then 102 echo " -- checking for changed externalpackages... yes" 101 103 ISSM_EXTERNALPACKAGES="yes" 102 104 else 103 echo " -- checking for changed externalpackages... no" ;105 echo " -- checking for changed externalpackages... no" 104 106 ISSM_EXTERNALPACKAGES="no" 105 107 fi … … 109 111 if [ ! -z "$(cat $ISSM_DIR/TEMP | grep -e "Makefile.am" -e "m4" )" ] || 110 112 [ ! -f "$ISSM_DIR/bin/issm.exe" ] && [ ! -f "$ISSM_DIR/bin/issm-bin.js" ] || 111 [ "$ISSM_EXTERNALPACKAGES" == "yes" ] ; 112 then 113 echo " -- checking for reconfiguration... yes"; 113 [ "$ISSM_EXTERNALPACKAGES" == "yes" ]; then 114 echo " -- checking for reconfiguration... yes" 114 115 ISSM_RECONFIGURE="yes" 115 116 else 116 echo " -- checking for reconfiguration... no" ;117 echo " -- checking for reconfiguration... no" 117 118 ISSM_RECONFIGURE="no" 118 119 fi … … 120 121 # If source files were changed in any way, recompile 121 122 if [ ! -z "$(cat $ISSM_DIR/TEMP | grep -e "\.cpp" -e "\.h" )" ] || 122 [ "$ISSM_RECONFIGURE" == "yes" ] ; 123 then 124 echo " -- checking for recompilation... yes"; 123 [ "$ISSM_RECONFIGURE" == "yes" ]; then 124 echo " -- checking for recompilation... yes" 125 125 ISSM_COMPILATION="yes" 126 126 else 127 echo " -- checking for recompilation... no" ;127 echo " -- checking for recompilation... no" 128 128 ISSM_COMPILATION="no" 129 129 fi … … 134 134 else 135 135 echo "Previous revision not found, this must be a fresh install" 136 echo " -- checking for changed externalpackages... yes" ;137 echo " -- checking for reconfiguration... yes" ;138 echo " -- checking for recompilation... yes" ;136 echo " -- checking for changed externalpackages... yes" 137 echo " -- checking for reconfiguration... yes" 138 echo " -- checking for recompilation... yes" 139 139 ISSM_EXTERNALPACKAGES="yes" 140 140 ISSM_RECONFIGURE="yes" … … 168 168 EXTERNALPACKAGES_FAILED=0; 169 169 170 for ((i=1;i<=$NUMPACKAGES;i++)) 171 do 170 for ((i=1;i<=$NUMPACKAGES;i++)); do 172 171 NUM1=$((2*$i-1)) 173 172 NUM2=$((2*$i)) … … 176 175 177 176 #install if requested or if previous install has not been successful 178 if [ "$ISSM_EXTERNALPACKAGES" == "yes" ] || [[ ! -d ./install && ! -d ./install-javascript ]]; then177 if [ "$ISSM_EXTERNALPACKAGES" == "yes" ]; then # NOTE: Removed check on if 'install' directory exist 179 178 cd $ISSM_DIR/externalpackages/$PACKAGENAME 180 179 … … 198 197 echo "<testcase classname=\"externalpackages\" name=\"$PACKAGENAME\"/>" >> $EXTERNAL_TEST_FILE 199 198 fi 200 source $ISSM_DIR/etc/environment .sh199 source $ISSM_DIR/etc/environment-shared.sh 201 200 202 201 #If external package is rebuilt, we also need to recompile … … 210 209 fi 211 210 done 211 212 212 echo '</testsuite>' >> $EXTERNAL_TEST_FILE 213 213 … … 220 220 221 221 # Source here to include any newly installed externalpackages on the path. 222 source $ISSM_DIR/etc/environment .sh222 source $ISSM_DIR/etc/environment-shared.sh 223 223 224 224 if [ "$OS" == "win" ]; then … … 249 249 #}}} 250 250 #ISSM compilation yes/no (ISSM_COMPILATION) {{{ 251 if [ "$ISSM_COMPILATION" == "yes" ] 252 then 251 if [ "$ISSM_COMPILATION" == "yes" ]; then 253 252 cd $ISSM_DIR 254 if [ "$ISSM_RECONFIGURE" == "yes" ] 255 then 253 if [ "$ISSM_RECONFIGURE" == "yes" ]; then 256 254 echo "======================================================"; 257 255 echo " Cleaning up and reconfiguring " … … 274 272 275 273 #4: compile and install ISSM 276 echo "======================================================" ;274 echo "======================================================" 277 275 echo " Compiling ISSM " 278 echo "======================================================" ;276 echo "======================================================" 279 277 if [ $NUMCPUS_INSTALL -gt 1 ]; then 280 278 echo "Making with " $NUMCPUS_INSTALL " cpus" … … 310 308 # {{{ 311 309 if [ $MATLAB_TEST -eq 1 ]; then 312 #Launch all tests on different cpus 313 for (( i=1;i<=$NUMCPUS_RUN;i++ )) 314 do 315 #Launch matlab and the nightly run script 316 cat > $ISSM_DIR/nightlylog/matlab_run$i.m << EOF 317 warning off %necessary to avoid a log of several Go for parallel runs 318 try, 319 $(if [ "$MATLAB_NROPTIONS" = "" ]; then 320 echo "runme('output','nightly','rank',$i,'numprocs',$NUMCPUS_RUN);" 310 #Launch all tests on different cpus 311 for (( i=1;i<=$NUMCPUS_RUN;i++ )); do 312 #Launch matlab and the nightly run script 313 cat > $ISSM_DIR/nightlylog/matlab_run$i.m << EOF 314 warning off %necessary to avoid a log of several Go for parallel runs 315 try, 316 $(if [ "$MATLAB_NROPTIONS" = "" ]; then 317 echo "runme('output','nightly','rank',$i,'numprocs',$NUMCPUS_RUN);" 318 else 319 echo "runme($MATLAB_NROPTIONS,'output','nightly','rank',$i,'numprocs',$NUMCPUS_RUN);" 320 fi) 321 catch me, 322 %An error occured, get report and exit 323 message=getReport(me) 324 directory=strsplit(pwd,'/'); 325 fid=fopen([issmdir '/nightlylog/matlaberror.log'], 'at'); 326 fprintf(fid,'\nMatlab error occured in: %s\n\n',directory{end}); 327 fprintf(fid,'%s',message); 328 fclose(fid); 329 end 330 disp('MATLABEXITEDCORRECTLY'); 331 exit 332 EOF 333 cd $ISSM_DIR/test/NightlyRun 334 if [ "$OS" = "win" ]; then 335 $MATLAB_PATH/bin/matlab -nodisplay -nosplash -r "addpath $ISSM_DIR_WIN/src/m/dev; devpath; addpath $ISSM_DIR_WIN/nightlylog/; matlab_run$i" -logfile $ISSM_DIR_WIN/nightlylog/matlab_log$i.log & 336 else 337 $MATLAB_PATH/bin/matlab -nodisplay -nosplash -r "addpath $ISSM_DIR/src/m/dev; devpath; addpath $ISSM_DIR/nightlylog/; matlab_run$i" -logfile $ISSM_DIR/nightlylog/matlab_log$i.log & 338 fi 339 done 340 341 #wait until matlab closes 342 if [ "$OS" = "win" ]; then 343 sleep 5; 344 echo "Waiting for matlab on windows" 345 pid=$(ps aux -W | grep MATLAB | awk '{printf("%s\n","MATLAB");}') 346 echo '-----------------------------' 347 echo "pid: $pid" 348 echo '-----------------------------' 349 while [ -n "$pid" ]; do 350 pid=$(ps aux -W | grep MATLAB | awk '{printf("%s\n","MATLAB");}') 351 sleep 1; 352 done 353 echo "DONE!" 321 354 else 322 echo "runme($MATLAB_NROPTIONS,'output','nightly','rank',$i,'numprocs',$NUMCPUS_RUN);" 323 fi 324 ) 325 catch me, 326 %An error occured, get report and exit 327 message=getReport(me) 328 directory=strsplit(pwd,'/'); 329 fid=fopen([issmdir '/nightlylog/matlaberror.log'], 'at'); 330 fprintf(fid,'\nMatlab error occured in: %s\n\n',directory{end}); 331 fprintf(fid,'%s',message); 332 fclose(fid); 333 end 334 disp('MATLABEXITEDCORRECTLY'); 335 336 exit 337 EOF 338 cd $ISSM_DIR/test/NightlyRun 339 if [ "$OS" = "win" ]; then 340 $MATLAB_PATH/bin/matlab -nodisplay -nosplash -r "addpath $ISSM_DIR_WIN/src/m/dev; devpath; addpath $ISSM_DIR_WIN/nightlylog/; matlab_run$i" -logfile $ISSM_DIR_WIN/nightlylog/matlab_log$i.log & 341 else 342 $MATLAB_PATH/bin/matlab -nodisplay -nosplash -r "addpath $ISSM_DIR/src/m/dev; devpath; addpath $ISSM_DIR/nightlylog/; matlab_run$i" -logfile $ISSM_DIR/nightlylog/matlab_log$i.log & 343 fi 344 done 345 346 #wait until matlab closes 347 if [ "$OS" = "win" ]; then 348 sleep 5; 349 echo "Waiting for matlab on windows" 350 pid=$(ps aux -W | grep MATLAB | awk '{printf("%s\n","MATLAB");}') 351 echo '-----------------------------' 352 echo "pid: $pid" 353 echo '-----------------------------' 354 while [ -n "$pid" ] 355 do 356 pid=$(ps aux -W | grep MATLAB | awk '{printf("%s\n","MATLAB");}') 357 sleep 1; 358 done 359 echo "DONE!" 360 else 361 wait 362 fi 363 364 #concatenate reports 365 cd $ISSM_DIR/nightlylog/ 366 #echo 'CHECKING NIGHTLYLOG DIRECTORY' 367 #echo '-----------------------------' 368 #ls -la 369 #echo '-----------------------------' 370 371 if [ -f matlab_log.log ]; then 372 rm matlab_log.log 373 fi 374 375 for job in `jobs -p` 376 do 377 echo "Waiting on: $job" 378 wait $job 379 done 380 381 for (( i=1;i<=$NUMCPUS_RUN;i++ )) 382 do 383 cat matlab_log$i.log >> matlab_log.log 384 done 385 386 #filter out windows characters: 387 cat matlab_log.log | tr -cd '\11\12\40-\176' > matlab_log.log2 && mv matlab_log.log2 matlab_log.log 355 wait 356 fi 357 358 #concatenate reports 359 cd $ISSM_DIR/nightlylog/ 360 #echo 'CHECKING NIGHTLYLOG DIRECTORY' 361 #echo '-----------------------------' 362 #ls -la 363 #echo '-----------------------------' 364 365 if [ -f matlab_log.log ]; then 366 rm matlab_log.log 367 fi 368 369 for job in `jobs -p`; do 370 echo "Waiting on: $job" 371 wait $job 372 done 373 374 for (( i=1;i<=$NUMCPUS_RUN;i++ )); do 375 cat matlab_log$i.log >> matlab_log.log 376 done 377 378 #filter out windows characters: 379 cat matlab_log.log | tr -cd '\11\12\40-\176' > matlab_log.log2 && mv matlab_log.log2 matlab_log.log 388 380 fi 389 381 # }}} … … 429 421 rm -f $ISSM_DIR/execution/*/ADOLC-* 430 422 431 # Examples Test 423 # Examples Tests 432 424 # {{{ 433 # This test will allow us to check on the status of the examples. 434 if [ $EXAMPLES_TEST -eq 1 ]; 435 then 436 FILE='runme.m' 437 cd $ISSM_DIR/examples 438 439 for dir in ./* ; 440 do 441 if [ -d "${dir}" ]; 442 then 443 # Some of the examples are incomplete (on purpose). As such, we will 444 # have to populate the missing steps in order to make sure that 445 # everything is working. 446 echo "Testing directory example: $(basename $dir)" 447 448 if [ -z "$SED" ]; 449 then 450 SED='sed' 451 fi 452 453 cd ${dir} 454 455 if [ "${dir}" == "./Greenland" ]; 456 then 457 # Greenland is missing step 8 458 STEP_EIGHT="\n disp(' Step 8: Plotting exercise');\n md = loadmodel('.\/Models\/Greenland.HistoricTransient');\n figure\n surfmb=[]; for i=2:201; surfmb=[surfmb ...\n md.results.TransientSolution(i).SmbMassBalance]; end\n subplot(3,1,1); plot([1:200],mean(surfmb));\n title('Mean Surface mass balance');\n vel=[]; for i=2:201; vel=[vel md.results.TransientSolution(i).Vel]; end\n subplot(3,1,2); plot([1:200],mean(vel));\n title('Mean Velocity');\n volume=[]; for i=2:201; volume=[volume md.results.TransientSolution(i).IceVolume]; end\n subplot(3,1,3); plot([1:200],volume);\n title('Ice Volume'); xlabel('years');" 459 460 $SED -i .bak 's/steps=\[1\];/steps=\[1:8\];\n\ntry\n/' $FILE 461 $SED -i .bak "s/if any(steps==8)/&${STEP_EIGHT}/" $FILE 462 elif [ "${dir}" == "./IceBridge" ]; 463 then 464 $SED -i .bak 's/steps=\[1\];/steps=\[1:5\];\n\ntry\n/' $FILE 465 elif [ "${dir}" == "./IceflowModels" ]; 466 then 467 # Almost nothing to this example 468 $SED -i .bak '1 s/^.*$/try\n\n&/' $FILE 469 elif [ "${dir}" == "./ISMIP" ]; 470 then 471 # Eight steps... none of which are implmented in the script... 472 $SED -i .bak '1 s/^.*$/try\n\n&/' $FILE 473 elif [ "${dir}" == "./Inversion" ]; 474 then 475 $SED -i .bak 's/steps=\[1\];/steps=\[1:4\];\n\ntry\n/' $FILE 476 elif [ "${dir}" == "./Jakobshavn" ]; 477 then 478 $SED -i .bak 's/steps=\[1\];/steps=\[1:4\];\n\ntry\n/' $FILE 479 elif [ "${dir}" == "./Jakobshavn" ]; 480 then 481 $SED -i .bak 's/steps=\[1\];/steps=\[1:4\];\n\ntry\n/' $FILE 482 elif [ "${dir}" == "./Pig" ]; 483 then 484 # Step 6 is needed 485 STEP_SIX="\n disp('Needs work!')" 486 $SED -i .bak 's/steps=\[1\];/steps=\[1:7\];\n!mv DomainOutline.bkp DomainOutline.exp;\n\ntry\n/' $FILE 487 $SED -i .bak "s/if any(steps==6)/&${STEP_SIX}/" $FILE 488 elif [ "${dir}" == "./PigSensitivity" ]; 489 then 490 # Step 4 is needed 491 STEP_FOUR="\n disp('Needs work!')" 492 $SED -i .bak 's/steps=\[1\];/steps=\[1:4\];\n\ntry\n/' $FILE 493 $SED -i .bak "s/if any(steps==6)/&${STEP_FOUR}/" $FILE 494 elif [ "${dir}" == "./SquareIceShelf" ]; 495 then 496 # Almost nothing to this example 497 $SED -i .bak '1 s/^.*$/try\n\n&/' $FILE 498 elif [ "${dir}" == "./UncertaintyQuantification" ]; 499 then 500 $SED -i .bak 's/steps=\[1\];/steps=\[1:7\];\n\ntry\n/' $FILE 501 elif [ "${dir}" == "./Data" ]; 502 then 503 echo "Data directory is used by examples. No modifications required." 504 else 505 echo "Not implemented yet!" 506 $SED -i .bak '1 s/^.*$/try\n\n&/' $FILE 507 fi 508 509 if [ "${dir}" == "./Data" ]; 510 then 511 ./Download.sh 512 else 513 LOG_FILE="matlab_log_$(basename $dir)_examples.log" 514 echo "disp('SUCCESS');" >> $FILE 515 echo 'catch me' >> $FILE 516 echo 'message=getReport(me);' >> $FILE 517 echo "fprintf('%s',message);" >> $FILE 518 echo "disp('FAILURE');" >> $FILE 519 echo 'end' >> $FILE 520 521 $MATLAB_PATH/bin/matlab -nodisplay -nosplash -r "addpath $ISSM_DIR/src/m/dev; devpath; addpath $ISSM_DIR/nightlylog/; runme" -logfile $ISSM_DIR/nightlylog/$LOG_FILE 522 echo "starting: $(basename $dir)" >> $ISSM_DIR/nightlylog/matlab_log_examples.log 523 cat $ISSM_DIR/nightlylog/$LOG_FILE >> $ISSM_DIR/nightlylog/matlab_log_examples.log 524 echo "finished: $(basename $dir)" >> $ISSM_DIR/nightlylog/matlab_log_examples.log 525 fi 526 cd .. 527 fi 528 done 425 # The following tests check that the examples (i.e. contents of examples 426 # directory, which are implementations of the tutorials found at 427 # https://issm.jpl.nasa.gov/documentation/tutorials/) can be run. 428 # 429 # runme files are modifed as needed to fill in statements that would otherwise 430 # be added by user. 431 # 432 # NOTE: 433 # - Indentation of replacement string literals (e.g. 'STEP_EIGHT') is set to 434 # nest cleanly in this file, but will result in unclean nesting runme file 435 # (which should not be an issue) 436 # - Single-line string replacements in runme.m can effectively be performed 437 # using sed. When performing multi-line replacements, perl is a better 438 # option. 439 # 440 if [ $EXAMPLES_TEST -eq 1 ]; then 441 $ISSM_DIR/jenkins/examples_tests.sh 529 442 fi 530 443 # }}} … … 542 455 543 456 #look through numtests: 544 for i in `echo $testlist` 545 do 457 for i in `echo $testlist`; do 546 458 juLog -test=MATLAB-$i -name=Error -error=ERROR awk "/starting:$i/{flag=1;next}/finished/{flag=0} flag{print}" matlab_log.log 547 459 juLog -test=MATLAB-$i -name=Failure -error=FAILURE awk "/starting:$i/{flag=1;next}/finished/{flag=0} flag{print}" matlab_log.log … … 551 463 matlabExitedInError=`grep -E "Activation cannot proceed|Error in matlab_run" matlab_log.log | wc -l` 552 464 553 if [ $matlabExitedInError -ne 0 ] 554 then 465 if [ $matlabExitedInError -ne 0 ]; then 555 466 echo "----------MATLAB exited in error!----------" 556 467 cat matlab_log.log … … 570 481 571 482 #look through numtests: 572 for i in `echo $testlist` 573 do 483 for i in `echo $testlist`; do 574 484 juLog -test=PYTHON-$i -name=Error -error=ERROR awk "/starting:$i/{flag=1;next}/finished/{flag=0} flag{print}" python_log.log 575 485 juLog -test=PYTHON-$i -name=Failure -error=FAILURE awk "/starting:$i/{flag=1;next}/finished/{flag=0} flag{print}" python_log.log … … 579 489 pythonExitedInError=`grep -E "Error|Standard exception|Traceback|bad interpreter" python_log.log | wc -l` 580 490 581 if [ $pythonExitedInError -ne 0 ] 582 then 491 if [ $pythonExitedInError -ne 0 ]; then 583 492 echo "----------Python exited in error!----------" 584 493 cat python_log.log … … 595 504 fi 596 505 597 if [ $EXAMPLES_TEST -eq 1 ]; 598 then 506 if [ $EXAMPLES_TEST -eq 1 ]; then 599 507 # Inexplicably, there are backspace chars in the error output that are causing issues 600 $SED -i .bak's///g' matlab_log_examples.log508 sed -i '.bak' 's///g' matlab_log_examples.log 601 509 602 510 numtests=`cat matlab_log_examples.log | grep "starting: " | wc -l` … … 604 512 605 513 echo "Processing: $numtests" 606 for i in `echo $testlist` 607 do 514 for i in `echo $testlist`; do 608 515 juLog -test=Example-$i -name=Error -error=FAILURE awk "/starting: $i/{flag=1;next}/finished: $i/{flag=0} flag{print}" matlab_log_examples.log 609 516 done
Note:
See TracChangeset
for help on using the changeset viewer.