Skip to content

Commit

Permalink
Initial implementation of Travis-CI automation
Browse files Browse the repository at this point in the history
Add a simple travis configuration file to automate testing software
builds on each pull request. Travis-CI is a continuous integration
service that automates building and testing software. As a starting
point, the travis script simply clones the repository branch and
attempts to configure EGSnrc with default parameters, to trap basic
configuration failures.

Add a configure.expect script to answer the EGSnrc configuration script
questions automatically. This requires the expect utility to be
available.

Adjust the egsnrc_bashrc_additions to avoid returning an error when
optional local additions files don't exist.

Ensure the travis check fails when any part of the configuration fails.
Some critical failures cause the configuration to abort with status 1
(error), but most failures merely echo a "failed" status to the
terminal, hence travis does not trap those because it reports failure
upon a non-zero return value. As a quick solution, tee the configuration
terminal output message to file and use grep to trigger a status of 1
if the file contains "fail":

! grep -i fail configure.log
  • Loading branch information
ftessier committed Feb 27, 2017
1 parent c3093aa commit 87e875d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: bash

addons:
apt:
packages:
- gfortran
- gcc
- g++
- expect

before_install:
- sudo apt-get -qq update
- sudo apt-get install -y grace
- sudo apt-get install -y libmotif-dev

install:
- HEN_HOUSE/scripts/configure.expect linux.conf | tee configure.log

script:
- pwd
- for f in HEN_HOUSE/log/*.log configure.log; do echo $f; cat $f; done
- (! grep -i fail configure.log)
- export EGS_HOME=/home/travis/build/nrc-cnrc/EGSnrc/egs_home
- export EGS_CONFIG=/home/travis/build/nrc-cnrc/EGSnrc/HEN_HOUSE/specs/linux.conf
- source /home/travis/build/nrc-cnrc/EGSnrc/HEN_HOUSE/scripts/egsnrc_bashrc_additions
- date
50 changes: 50 additions & 0 deletions HEN_HOUSE/scripts/configure.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/expect -f

set timeout -1

# configuration filename
set confname "expect.conf"
if {$argc > 0} {
set confname [lindex $argv 0]
}

# clear environment variables
set env(HEN_HOUSE) ""
set env(EGS_CONFIG) ""
set env(EGS_HOME) ""

# spawn EGSnrc configuration script
spawn HEN_HOUSE/scripts/configure

# Information
expect "Press enter to continue." { send "\n" }

# Fortran compiler
expect "Input fortran compiler:" { send "\n" }
expect "Input standard compilation flags:" { send "\n" }
expect "Input optimization flags:" { send "\n" }
expect "Input flags for debugging:" { send "\n" }
expect "Input libraries that your compiler may need:" { send "\n" }

# C compiler
expect "Input the one you would like to use:" { send "\n" }
expect "Input C compiler flags to use:" { send "\n" }

# Configuration
expect "Input path to EGSnrc HEN_HOUSE directory:" { send "\n" }
expect "Choose a configuration file name:" { send "$confname\n" }
set timeout 1
expect "Do you want to overwrite ?" { puts "no\n"; exit }
set timeout -1

# C++ compiler
expect "Input C++ compiler:" { send "\n" }
expect "Input option to change, or enter to proceed:" { send "\n" }

# Finalize for user
expect "Do you want to finalize" { send "yes\n" }
expect "Press enter to continue." { send "\n" }

expect "Choose a directory for your user codes:" { send "\n" }
expect "Choose 1 (all), 2 (some) or 3 (none):" { send "1\n" }
expect "EOF"
8 changes: 6 additions & 2 deletions HEN_HOUSE/scripts/egsnrc_bashrc_additions
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@ export HEN_HOUSE PATH

# Now check for local system wide sh additions
#
test -f $HEN_HOUSE/scripts/local_bashrc_additions && \. $HEN_HOUSE/scripts/local_bashrc_additions
if test -f $HEN_HOUSE/scripts/local_bashrc_additions; then
source $HEN_HOUSE/scripts/local_bashrc_additions
fi

# Every individual user may customize their settings by creating a
# .egsnrc_bashrc_additions file in their HOME directory.
# Source this file if available
#
test -f $HOME/.egsnrc_bashrc_additions && \. $HOME/.egsnrc_bashrc_additions
if test -f $HOME/.egsnrc_bashrc_additions; then
source $HOME/.egsnrc_bashrc_additions
fi

0 comments on commit 87e875d

Please sign in to comment.