From ca948b4ea1441ed548cd801a22f20aa6349329e3 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Fri, 30 Jan 2015 16:59:08 -0500 Subject: [PATCH] added a travis ci scripts --- .travis.yml | 26 +++++++++++++++++++++ data/get_nndc_data.py | 24 ++++++++++++++----- readme.rst | 3 +++ tests/run_tests.py | 5 ++++ tests/travis.sh | 10 ++++++++ tests/travis_install.sh | 52 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 6 deletions(-) create mode 100644 .travis.yml create mode 100755 tests/travis.sh create mode 100755 tests/travis_install.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..16e15c24bd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq -y python-numpy + - sudo apt-get install -qq -y python-scipy + - sudo apt-get install -qq -y python-h5py + - sudo apt-get install -qq -y gfortran + - sudo apt-get install -qq -y g++ + - ./tests/travis_install.sh + - export FC=gfortran + - export MPI_DIR=$PWD/mpich_install + - export PHDF5_DIR=$PWD/phdf5_install + - export HDF5_DIR=$PWD/hdf5_install + - export PETSC_DIR=$PWD/petsc_install + - ls -ll + +before_script: + - cd data + - ./get_nndc_data.py --batch > /dev/null 2>&1 + - export CROSS_SECTIONS=$PWD/nndc/cross_sections.xml + - cd .. + +script: + - cd tests + - export OMP_NUM_THREADS=3 + - ./travis.sh + - cd .. diff --git a/data/get_nndc_data.py b/data/get_nndc_data.py index 12a6de6e0b..b888073fc9 100755 --- a/data/get_nndc_data.py +++ b/data/get_nndc_data.py @@ -8,6 +8,12 @@ import sys import tarfile import glob import hashlib +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument('-b', '--batch', action = 'store_true', + help = 'supresses standard in') +args = parser.parse_args() try: from urllib.request import urlopen @@ -118,10 +124,13 @@ shutil.copyfile('cross_sections_nndc.xml', 'nndc/cross_sections.xml') # PROMPT USER TO DELETE .TAR.GZ FILES # Ask user to delete -if sys.version_info[0] < 3: - response = raw_input('Delete *.tar.gz files? ([y]/n) ') +if not args.batch: + if sys.version_info[0] < 3: + response = raw_input('Delete *.tar.gz files? ([y]/n) ') + else: + response = input('Delete *.tar.gz files? ([y]/n) ') else: - response = input('Delete *.tar.gz files? ([y]/n) ') + response = 'y' # Delete files if requested if not response or response.lower().startswith('y'): @@ -134,10 +143,13 @@ if not response or response.lower().startswith('y'): # PROMPT USER TO CONVERT ASCII TO BINARY # Ask user to convert -if sys.version_info[0] < 3: - response = raw_input('Convert ACE files to binary? ([y]/n) ') +if not args.batch: + if sys.version_info[0] < 3: + response = raw_input('Convert ACE files to binary? ([y]/n) ') + else: + response = input('Convert ACE files to binary? ([y]/n) ') else: - response = input('Convert ACE files to binary? ([y]/n) ') + response = 'y' # Convert files if requested if not response or response.lower().startswith('y'): diff --git a/readme.rst b/readme.rst index a010974375..6288c12780 100644 --- a/readme.rst +++ b/readme.rst @@ -2,6 +2,9 @@ OpenMC Monte Carlo Particle Transport Code ========================================== +.. image:: https://travis-ci.org/bhermanmit/openmc.svg?branch=travis + :target: https://travis-ci.org/bhermanmit/openmc + The OpenMC project aims to provide a fully-featured Monte Carlo particle transport code based on modern methods. It is a constructive solid geometry, continuous-energy transport code that uses ACE format cross sections. The diff --git a/tests/run_tests.py b/tests/run_tests.py index 661f8c50a4..133f1a3e37 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -509,6 +509,8 @@ else: ENDC = '' BOLD = '' +return_code = 0 + for test in tests: print(test + '.'*(50 - len(test)), end='') if tests[test].success: @@ -516,3 +518,6 @@ for test in tests: else: print(BOLD + FAIL + '[FAILED]' + ENDC) print(' '*len(test)+tests[test].msg) + return_code = 1 + +sys.exit(return_code) diff --git a/tests/travis.sh b/tests/travis.sh new file mode 100755 index 0000000000..aef90203d4 --- /dev/null +++ b/tests/travis.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -ev + +# Run all debug tests +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + ./run_tests.py -C "^basic-debug$|^hdf5-debug$|^mpi-omp-debug$|^phdf5-omp-debug$|^omp-phdf5-petsc-debug$" -j 4 -s +else + ./run_tests.py -C "^basic-debug$" -j 4 +fi diff --git a/tests/travis_install.sh b/tests/travis_install.sh new file mode 100755 index 0000000000..e0461d82cb --- /dev/null +++ b/tests/travis_install.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +set -ev + +# Build HDF5 and PETSc for rest of debug tests +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + + # Build MPICH + wget -q http://www.mpich.org/static/downloads/3.1.3/mpich-3.1.3.tar.gz + tar -xzvf mpich-3.1.3.tar.gz >/dev/null 2>&1 + cd mpich-3.1.3 + ./configure --prefix=$PWD/../mpich_install -q + make -j >/dev/null 2>&1 + make install >/dev/null 2>&1 + cd .. + + # Build PHDF5 + wget -q http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.14.tar.gz + tar -xzvf hdf5-1.8.14.tar.gz >/dev/null 2>&1 + mv hdf5-1.8.14 phdf5-1.8.14; cd phdf5-1.8.14 + CC=$PWD/../mpich_install/bin/mpicc FC=$PWD/../mpich_install/bin/mpif90 \ + ./configure \ + --prefix=$PWD/../phdf5_install -q --enable-fortran \ + --enable-fortran2003 --enable-parallel + make -j >/dev/null 2>&1 + make install >/dev/null 2>&1 + cd .. + + # Build HDF5 + tar -xzvf hdf5-1.8.14.tar.gz >/dev/null 2>&1 + cd hdf5-1.8.14 + CC=gcc FC=gfortran ./configure --prefix=$PWD/../hdf5_install -q \ + --enable-fortran --enable-fortran2003 + make -j >/dev/null 2>&1 + make install >/dev/null 2>&1 + cd .. + + # Build PETSc + wget -q http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.5.3.tar.gz + tar -xzvf petsc-lite-3.5.3.tar.gz >/dev/null 2>&1 + cd petsc-3.5.3 + ./configure --prefix=$PWD/../petsc_install -q --download-fblaslapack \ + --with-mpi-dir=$PWD/../mpich_install --with-share-libraries \ + --with-fortran-datatypes + make PETSC_DIR=/home/travis/build/bhermanmit/openmc/petsc-3.5.3 \ + PETSC_ARCH=arch-linux2-c-debug all >/dev/null 2>&1 + make PETSC_DIR=/home/travis/build/bhermanmit/openmc/petsc-3.5.3 \ + PETSC_ARCH=arch-linux2-c-debug install >/dev/null 2>&1 + make install >/dev/null 2>&1 + cd .. + +fi