Skip to content

Commit

Permalink
move scripts into their own new-home
Browse files Browse the repository at this point in the history
  • Loading branch information
szaghi committed Oct 6, 2016
1 parent 9fb9252 commit 353dfa2
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 14 deletions.
21 changes: 20 additions & 1 deletion .travis.yml
Expand Up @@ -22,7 +22,9 @@ addons:
env:
global:
- MAKECOVERAGE="FoBiS.py rule -ex makecoverage"
- MAKEDOC="./makedoc.sh szaghi/PENF"
- MAKEDOC="./scripts/makedoc.sh szaghi/PENF"
- CLEAN="FoBiS.py rule -ex clean"
- MAKETAR="FoBiS.py rule -ex maketar"

before_install:
- git submodule update --init --recursive
Expand Down Expand Up @@ -50,3 +52,20 @@ after_success:
- find . -name '*.gcno' -print
- bash <(curl -s https://codecov.io/bash)
- $MAKEDOC

before_deploy:
- $CLEAN
- $MAKETAR
- mv PENF.tar.gz PENF-$TRAVIS_TAG.tar.gz

deploy:
provider: releases
api_key:
secure: XTY3kve/IprjjfLBG1e5/qwBXePovf6eNClUhWXQq/+QIkTlGXkZ+T3DKhCPnQ9HBsLH6F/Pdx52r+u3irAzkDK5Voc6uf0p+XQp8KEB3NKkBdvzMusuZLhECqqWyTSr1tdmo1tSwIEuuGsNcA7YuyiX6+po2sZG7gLDDBB4Im0=
file:
- PENF-$TRAVIS_TAG.tar.gz
- ./scripts/install.sh
skip_cleanup: true
overwrite: true
on:
tags: true
46 changes: 33 additions & 13 deletions fobos
Expand Up @@ -193,23 +193,43 @@ jobs = 2
cflags_heritage = True

[rule-makedoc]
help = Rule for building documentation from source files
help = Build documentation from source files
rule_1 = rm -rf doc/html/*
rule_2 = ford --debug doc/main_page.md
rule_2 = ford doc/main_page.md --debug
rule_3 = cp -r doc/html/publish/* doc/html/

[rule-makecoverage]
help = Rule for performing coverage analysis
rule_1 = FoBiS.py clean -mode tests-gnu
rule_2 = FoBiS.py build -mode tests-gnu -coverage
rule_3 = ./exe/test_all
rule_4 = ./exe/compact_real
rule_5 = gcov -o exe/obj/ src/lib/penf.F90 src/tests/*
rule_4 = rm -rf doc/html/publish

[rule-deldoc]
help = Rule for deleting documentation
help = Delete documentation
rule = rm -rf doc/html/*

[rule-delexe]
help = Delete exes
rule = rm -rf exe/

[rule-clean]
help = Clean the project tree
rule_1 = FoBiS.py rule -ex deldoc
rule_2 = FoBiS.py rule -ex delexe
rule_3 = rm -f *.gcov

[rule-maketar]
help = Rule for making tar archive of the project
rule = tar -czf BeFoR64.tar.gz *
help = Make tar archive of the project
rule = tar --xform="s%^%PENF/%" -czf PENF.tar.gz *


[rule-makecoverage]
help = Perform coverage analysis
rule_1 = FoBiS.py clean -mode tests-gnu
rule_2 = FoBiS.py build -mode tests-gnu -coverage
rule_3 = ./scripts/run_tests.sh
rule_4 = gcov -o exe/obj/ src/lib/*
rule_5 = rm -f *.gcov

[rule-makecoverage-analysis]
help = Perform coverage analysis and saving reports in markdown
rule_1 = FoBiS.py clean -mode tests-gnu
rule_2 = FoBiS.py build -mode tests-gnu -coverage
rule_3 = ./scripts/run_tests.sh
rule_4 = FoBiS.py rule -gcov_analyzer wiki/ Coverage-Analysis
rule_5 = rm -f *.gcov
184 changes: 184 additions & 0 deletions scripts/install.sh
@@ -0,0 +1,184 @@
#!/bin/bash -
#
# File: intstall.sh
#
# Description: A utility script that builds PENF project
#
# License: GPL3+
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#

# DEBUGGING
set -e
set -C # noclobber

# INTERNAL VARIABLES AND INITIALIZATIONS
readonly USERNAME="szaghi"
readonly PROJECT="PENF"
readonly GITHUB="https://github.com/$USERNAME/$PROJECT"
readonly PROGRAM=`basename "$0"`

function projectdownload () {
if [ $VERBOSE -eq 1 ]; then
echo "download project"
fi

if command -v $DOWNLOAD >/dev/null 2>&1; then
if [ $VERBOSE -eq 1 ]; then
echo " using $DOWNLOAD"
fi
else
echo "error: $DOWNLOAD tool (to download project) not found"
exit 1
fi

if [ "$DOWNLOAD" == "git" ]; then
git clone --recursive $GITHUB
cd $PROJECT
git submodule update --init --recursive
cd -
elif [ "$DOWNLOAD" == "wget" ]; then
wget $(curl -s https://api.github.com/repos/$USERNAME/$PROJECT/releases/latest | grep 'browser_' | cut -d\" -f4)
tar xf $PROJECT.tar.gz
rm -f $PROJECT.tar.gz
fi

if [ $VERBOSE -eq 1 ]; then
echo "project downloaded into: $PROJECT"
fi
}

function projectbuild () {
if [ $VERBOSE -eq 1 ]; then
echo "build project"
fi

if [ "$BUILD" == "fobis" ]; then
BUILD="FoBiS.py"
fi

if command -v $BUILD >/dev/null 2>&1; then
if [ $VERBOSE -eq 1 ]; then
echo " using $BUILD"
fi
else
echo "error: $BUILD tool (to build project) not found"
exit 1
fi

if [ "$BUILD" == "FoBiS.py" ]; then
FoBiS.py build -mode static-gnu
elif [ "$BUILD" == "make" ]; then
make -j 1 STATIC=yes
elif [ "$BUILD" == "cmake" ]; then
mkdir -p static
cd static
cmake ../
cmake --build .
cd ../
fi
}

function usage () {
echo "Install script of $PROJECT"
echo "Usage:"
echo
echo "$PROGRAM --help|-?"
echo " Print this usage output and exit"
echo
echo "$PROGRAM --download|-d <arg> [--verbose|-v]"
echo " Download the project"
echo
echo " --download|-d [arg] Download the project, arg=git|wget to download with git or wget respectively"
echo " --verbose|-v Output verbose mode activation"
echo
echo "$PROGRAM --build|-b <arg> [--verbose|-v]"
echo " Build the project"
echo
echo " --build|-b [arg] Build the project, arg=fobis|make|cmake to build with FoBiS.py, GNU Make or CMake respectively"
echo " --verbose|-v Output verbose mode activation"
echo
echo "Examples:"
echo
echo "$PROGRAM --download git"
echo "$PROGRAM --build make"
echo "$PROGRAM --download wget --build cmake"
}

DOWNLOAD=0
BUILD=0
VERBOSE=0

# RETURN VALUES/EXIT STATUS CODES
readonly E_BAD_OPTION=254

# PROCESS COMMAND-LINE ARGUMENTS
if [ $# -eq 0 ]; then
usage
exit 0
fi
while test $# -gt 0; do
if [ x"$1" == x"--" ]; then
# detect argument termination
shift
break
fi
case $1 in
--download | -d )
shift
DOWNLOAD="$1"
shift
;;

--build | -b )
shift
BUILD="$1"
shift
;;

--verbose | -v )
shift
VERBOSE=1
;;

-? | --help )
usage
exit
;;

-* )
echo "Unrecognized option: $1" >&2
usage
exit $E_BAD_OPTION
;;

* )
break
;;
esac
done

if [ "$DOWNLOAD" != "0" ] && [ "$BUILD" == "0" ]; then
projectdownload
elif [ "$DOWNLOAD" == "0" ] && [ "$BUILD" != "0" ]; then
projectbuild
elif [ "$DOWNLOAD" != "0" ] && [ "$BUILD" != "0" ]; then
projectdownload
cd $PROJECT
projectbuild
fi

exit 0
File renamed without changes.
35 changes: 35 additions & 0 deletions scripts/run_tests.sh
@@ -0,0 +1,35 @@
#!/bin/bash

all_passed () {
local array="$1[@]"
local ok=1
for element in "${!array}"; do
if [ "$element" == 'F' ]; then
ok=0
break
fi
done
echo $ok
}

echo "Run all tests"
declare -a tests_executed
for e in $( find ./exe/ -type f -executable -print ); do
is_passed=`$e | grep -i "Are all tests passed? " | awk '{print $5}'`
tests_executed=("${tests_executed[@]}" "$is_passed")
echo " run test $e, is passed? $is_passed"
if [ "$is_passed" == 'F' ]; then
echo
echo "Test failed"
$e
fi
done
passed=$(all_passed tests_executed)
echo "Number of tests executed ${#tests_executed[@]}"
if [ $passed -eq 1 ]; then
echo "All tests passed"
exit 0
else
echo "Some tests failed"
exit 1
fi

0 comments on commit 353dfa2

Please sign in to comment.