Skip to content

Commit

Permalink
Merge pull request #4 from gtrensch/gtrensch_cond_builds_travis
Browse files Browse the repository at this point in the history
Travis-CI logparser: set build return code
  • Loading branch information
lekshmideepu authored Jan 29, 2019
2 parents 3ef856d + 04ec06e commit 540c885
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 126 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,35 @@ jobs:
include:
- stage: Staticcheck
python: 3.4.4
env: xTHREADING=0 xMPI=0 xGSL=0 xLIBNEUROSIM=0 xLTDL=0 xREADLINE=0 xPYTHON=0 xMUSIC=0 xSTATIC_ANALYSIS=1 CACHE_NAME=JOB # static code analysis
env: xTHREADING=0 xMPI=0 xGSL=0 xLIBNEUROSIM=0 xLTDL=0 xREADLINE=0 xPYTHON=0 xMUSIC=0 xSTATIC_ANALYSIS=1 xRUN_TESTSUITE=0 CACHE_NAME=JOB # only static code analysis and build
- stage: MPI-Threading-Python
python: 3.4.4
env: xTHREADING=0 xMPI=1 xGSL=0 xLIBNEUROSIM=0 xLTDL=1 xREADLINE=1 xPYTHON=0 xMUSIC=0 xSTATIC_ANALYSIS=0 CACHE_NAME=JOB # only MPI
env: xTHREADING=0 xMPI=1 xGSL=0 xLIBNEUROSIM=0 xLTDL=1 xREADLINE=1 xPYTHON=0 xMUSIC=0 xSTATIC_ANALYSIS=0 xRUN_TESTSUITE=1 CACHE_NAME=JOB # only MPI
- stage: MPI-Threading-Python
python: 3.4.4
env: xTHREADING=1 xMPI=0 xGSL=0 xLIBNEUROSIM=0 xLTDL=1 xREADLINE=1 xPYTHON=0 xMUSIC=0 xSTATIC_ANALYSIS=0 CACHE_NAME=JOB # only threading
env: xTHREADING=1 xMPI=0 xGSL=0 xLIBNEUROSIM=0 xLTDL=1 xREADLINE=1 xPYTHON=0 xMUSIC=0 xSTATIC_ANALYSIS=0 xRUN_TESTSUITE=1 CACHE_NAME=JOB # only threading
- stage: MPI-Threading-Python
python: 3.4.4
env: xTHREADING=1 xMPI=0 xGSL=0 xLIBNEUROSIM=0 xLTDL=0 xREADLINE=0 xPYTHON=1 xMUSIC=0 xSTATIC_ANALYSIS=0 CACHE_NAME=JOB # Python & Threading
env: xTHREADING=1 xMPI=0 xGSL=0 xLIBNEUROSIM=0 xLTDL=0 xREADLINE=0 xPYTHON=1 xMUSIC=0 xSTATIC_ANALYSIS=0 xRUN_TESTSUITE=1 CACHE_NAME=JOB # Python & Threading
- stage: MPI-Threading-Python
python: 3.4.4
env: xTHREADING=0 xMPI=1 xGSL=0 xLIBNEUROSIM=0 xLTDL=0 xREADLINE=0 xPYTHON=1 xMUSIC=0 xSTATIC_ANALYSIS=0 CACHE_NAME=JOB # Python & MPI
env: xTHREADING=0 xMPI=1 xGSL=0 xLIBNEUROSIM=0 xLTDL=0 xREADLINE=0 xPYTHON=1 xMUSIC=0 xSTATIC_ANALYSIS=0 xRUN_TESTSUITE=1 CACHE_NAME=JOB # Python & MPI
- stage: MPI-Threading-Python
python: 3.4.4
env: xTHREADING=0 xMPI=0 xGSL=0 xLIBNEUROSIM=0 xLTDL=0 xREADLINE=0 xPYTHON=1 xMUSIC=0 xSTATIC_ANALYSIS=0 CACHE_NAME=JOB # only Python
env: xTHREADING=0 xMPI=0 xGSL=0 xLIBNEUROSIM=0 xLTDL=0 xREADLINE=0 xPYTHON=1 xMUSIC=0 xSTATIC_ANALYSIS=0 xRUN_TESTSUITE=1 CACHE_NAME=JOB # only Python
- stage: Python-Full-build
python: 3.4.4
env: xTHREADING=1 xMPI=1 xGSL=1 xLIBNEUROSIM=1 xLTDL=1 xREADLINE=1 xPYTHON=1 xMUSIC=1 xSTATIC_ANALYSIS=0 CACHE_NAME=JOB # full
env: xTHREADING=1 xMPI=1 xGSL=1 xLIBNEUROSIM=1 xLTDL=1 xREADLINE=1 xPYTHON=1 xMUSIC=1 xSTATIC_ANALYSIS=0 xRUN_TESTSUITE=1 CACHE_NAME=JOB # full
- stage: Python-Full-build
python: 2.7.13
env: xTHREADING=1 xMPI=1 xGSL=1 xLIBNEUROSIM=1 xLTDL=1 xREADLINE=1 xPYTHON=1 xMUSIC=1 xSTATIC_ANALYSIS=0 CACHE_NAME=JOB # full
env: xTHREADING=1 xMPI=1 xGSL=1 xLIBNEUROSIM=1 xLTDL=1 xREADLINE=1 xPYTHON=1 xMUSIC=1 xSTATIC_ANALYSIS=0 xRUN_TESTSUITE=1 CACHE_NAME=JOB # full
- stage: GCC8Clang7
language: cpp
env: MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
- stage: GCC8Clang7
language: cpp
env: MATRIX_EVAL="CC=clang-7 && CXX=clang++-7"

#https://docs.travis-ci.com/user/installing-dependencies#Installing-Packages-with-the-APT-Addon
addons:
apt:
Expand Down
39 changes: 22 additions & 17 deletions extras/parse_travis_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,7 @@ def testsuite_results(log_filename, msg_testsuite_section_start,
# section. Stop reading the log file.
break

#return status_tests, total_number_of_tests, number_of_tests_failed

if in_installcheck_section:
return status_tests, total_number_of_tests, number_of_tests_failed
else:
# No make installcheck
return None, None, None
return status_tests, total_number_of_tests, number_of_tests_failed


def convert_bool_value_to_status_string(value):
Expand Down Expand Up @@ -868,7 +862,9 @@ def build_return_code(status_cmake_configure,
ignore_vera,
ignore_cppcheck,
ignore_format,
ignore_pep8):
ignore_pep8,
skip_code_analysis,
skip_installcheck):
"""Depending in the build results, create a return code.
Parameters
Expand All @@ -894,19 +890,23 @@ def build_return_code(status_cmake_configure,
fail: True, False
ignore_pep8: PEP8 messages will not cause the build to
fail: True, False
skip_code_analysis: build ran w/o static code analysis: True, False
skip_installcheck: build ran w/o executing the test suite: True, False
Returns
-------
0 (success) or 1.
"""
if ((status_cmake_configure) and
(status_make) and
(status_make_install) and
(status_tests) and
(ignore_vera or get_num_msgs(summary_vera) == 0) and
(ignore_cppcheck or get_num_msgs(summary_cppcheck) == 0) and
(ignore_format or get_num_msgs(summary_format) == 0) and
(ignore_pep8 or get_num_msgs(summary_pep8) == 0)):
if ((status_cmake_configure) and # noqa
(status_make) and # noqa
(status_make_install) and # noqa
(skip_installcheck or status_tests) and # noqa
(skip_code_analysis or ((ignore_vera or get_num_msgs(summary_vera) == 0) and # noqa
(ignore_cppcheck or get_num_msgs(summary_cppcheck) == 0) and # noqa
(ignore_format or get_num_msgs(summary_format) == 0) and # noqa
(ignore_pep8 or get_num_msgs(summary_pep8) == 0)) # noqa
) # noqa
): # noqa

return 0
else:
Expand All @@ -924,6 +924,9 @@ def build_return_code(status_cmake_configure,
list_of_changed_files(log_filename, "MSGBLD0070",
"MSGBLD0100", "MSGBLD0095")

skip_code_analysis = is_message_in_logfile(log_filename, "MSGBLD0225")
skip_installcheck = is_message_in_logfile(log_filename, "MSGBLD0305")

# The NEST Travis CI build consists of several steps and sections.
# Each section is enclosed in a start- and an end-message.
# By checking these message-pairs it can be verified whether a section
Expand Down Expand Up @@ -974,7 +977,9 @@ def build_return_code(status_cmake_configure,
ignore_vera,
ignore_cppcheck,
ignore_format,
ignore_pep8)
ignore_pep8,
skip_code_analysis,
skip_installcheck)

# Only after a successful build, Travis CI will upload the build artifacts
# to Amazon S3.
Expand Down
202 changes: 102 additions & 100 deletions extras/travis_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,104 +102,106 @@ NEST_RESULT=$(readlink -f $NEST_RESULT)
mkdir "$NEST_VPATH" "$NEST_RESULT"
mkdir "$NEST_VPATH/reports"

echo
echo "+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"
echo "+ S T A T I C C O D E A N A L Y S I S +"
echo "+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"

echo "MSGBLD0010: Initializing VERA++ static code analysis."
wget --no-verbose https://bitbucket.org/verateam/vera/downloads/vera++-1.3.0.tar.gz
tar -xzf vera++-1.3.0.tar.gz
cd vera++-1.3.0
cmake -DCMAKE_INSTALL_PREFIX=/usr -DVERA_LUA=OFF -DVERA_USE_SYSTEM_BOOST=ON
sudo make install
cd ..
rm -fr ./vera++-1.3.0
rm -f ./vera++-1.3.0.tar.gz
# Add the NEST profile to the VERA++ profiles.
sudo cp ./extras/vera++.profile /usr/lib/vera++/profiles/nest
echo "MSGBLD0020: VERA++ initialization completed."
if [ ! -f "$HOME/.cache/bin/cppcheck" ]; then
echo "MSGBLD0030: Installing CPPCHECK version 1.69."
# Build cppcheck version 1.69
git clone https://github.com/danmar/cppcheck.git
cd cppcheck
git checkout tags/1.69
mkdir -p install
make PREFIX=$HOME/.cache CFGDIR=$HOME/.cache/cfg HAVE_RULES=yes install
if [ "$xSTATIC_ANALYSIS" = "1" ]; then
echo "+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"
echo "+ S T A T I C C O D E A N A L Y S I S +"
echo "+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"

echo "MSGBLD0010: Initializing VERA++ static code analysis."
wget --no-verbose https://bitbucket.org/verateam/vera/downloads/vera++-1.3.0.tar.gz
tar -xzf vera++-1.3.0.tar.gz
cd vera++-1.3.0
cmake -DCMAKE_INSTALL_PREFIX=/usr -DVERA_LUA=OFF -DVERA_USE_SYSTEM_BOOST=ON
sudo make install
cd ..
echo "MSGBLD0040: CPPCHECK installation completed."

echo "MSGBLD0050: Installing CLANG-FORMAT."
wget --no-verbose http://llvm.org/releases/3.6.2/clang+llvm-3.6.2-x86_64-linux-gnu-ubuntu-14.04.tar.xz
tar xf clang+llvm-3.6.2-x86_64-linux-gnu-ubuntu-14.04.tar.xz
# Copy and not move because '.cache' may aleady contain other subdirectories and files.
cp -R clang+llvm-3.6.2-x86_64-linux-gnu-ubuntu-14.04/* $HOME/.cache
echo "MSGBLD0060: CLANG-FORMAT installation completed."

# Remove these directories, otherwise the copyright-header check will complain.
rm -rf ./cppcheck
rm -rf ./clang+llvm-3.6.2-x86_64-linux-gnu-ubuntu-14.04
fi
rm -fr ./vera++-1.3.0
rm -f ./vera++-1.3.0.tar.gz
# Add the NEST profile to the VERA++ profiles.
sudo cp ./extras/vera++.profile /usr/lib/vera++/profiles/nest
echo "MSGBLD0020: VERA++ initialization completed."
if [ ! -f "$HOME/.cache/bin/cppcheck" ]; then
echo "MSGBLD0030: Installing CPPCHECK version 1.69."
# Build cppcheck version 1.69
git clone https://github.com/danmar/cppcheck.git
cd cppcheck
git checkout tags/1.69
mkdir -p install
make PREFIX=$HOME/.cache CFGDIR=$HOME/.cache/cfg HAVE_RULES=yes install
cd ..
echo "MSGBLD0040: CPPCHECK installation completed."

echo "MSGBLD0050: Installing CLANG-FORMAT."
wget --no-verbose http://llvm.org/releases/3.6.2/clang+llvm-3.6.2-x86_64-linux-gnu-ubuntu-14.04.tar.xz
tar xf clang+llvm-3.6.2-x86_64-linux-gnu-ubuntu-14.04.tar.xz
# Copy and not move because '.cache' may aleady contain other subdirectories and files.
cp -R clang+llvm-3.6.2-x86_64-linux-gnu-ubuntu-14.04/* $HOME/.cache
echo "MSGBLD0060: CLANG-FORMAT installation completed."

# Remove these directories, otherwise the copyright-header check will complain.
rm -rf ./cppcheck
rm -rf ./clang+llvm-3.6.2-x86_64-linux-gnu-ubuntu-14.04
fi

# Ensure that the cppcheck and clang-format installation can be found.
export PATH=$HOME/.cache/bin:$PATH
# Ensure that the cppcheck and clang-format installation can be found.
export PATH=$HOME/.cache/bin:$PATH

echo "MSGBLD0070: Retrieving changed files."
# Note: BUG: Extracting the filenames may not work in all cases.
# The commit range might not properly reflect the history.
# see https://github.com/travis-ci/travis-ci/issues/2668
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "MSGBLD0080: PULL REQUEST: Retrieving changed files using GitHub API."
file_names=`curl "https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST/files" | jq '.[] | .filename' | tr '\n' ' ' | tr '"' ' '`
else
echo "MSGBLD0090: Retrieving changed files using git diff."
file_names=`(git diff --name-only $TRAVIS_COMMIT_RANGE || echo "") | tr '\n' ' '`
fi

echo "MSGBLD0070: Retrieving changed files."
# Note: BUG: Extracting the filenames may not work in all cases.
# The commit range might not properly reflect the history.
# see https://github.com/travis-ci/travis-ci/issues/2668
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "MSGBLD0080: PULL REQUEST: Retrieving changed files using GitHub API."
file_names=`curl "https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST/files" | jq '.[] | .filename' | tr '\n' ' ' | tr '"' ' '`
printf '%s\n' "$file_names" | while IFS= read -r line
do
for single_file_name in $file_names
do
echo "MSGBLD0095: File changed: $single_file_name"
done
done
echo "MSGBLD0100: Retrieving changed files completed."
echo


# Set the command line arguments for the static code analysis script and execute it.

# The names of the static code analysis tools executables.
VERA=vera++
CPPCHECK=cppcheck
CLANG_FORMAT=clang-format
PEP8=pep8

# Perform or skip a certain analysis.
PERFORM_VERA=true
PERFORM_CPPCHECK=true
PERFORM_CLANG_FORMAT=true
PERFORM_PEP8=true

# The following command line parameters indicate whether static code analysis error messages
# will cause the Travis CI build to fail or are ignored.
IGNORE_MSG_VERA=false
IGNORE_MSG_CPPCHECK=true
IGNORE_MSG_CLANG_FORMAT=false
IGNORE_MSG_PEP8=false

# The script is called within the Travis CI environment and thus can not be run incremental.
RUNS_ON_TRAVIS=true
INCREMENTAL=false

chmod +x ./extras/static_code_analysis.sh
./extras/static_code_analysis.sh "$RUNS_ON_TRAVIS" "$INCREMENTAL" "$file_names" "$NEST_VPATH" \
"$VERA" "$CPPCHECK" "$CLANG_FORMAT" "$PEP8" \
"$PERFORM_VERA" "$PERFORM_CPPCHECK" "$PERFORM_CLANG_FORMAT" "$PERFORM_PEP8" \
"$IGNORE_MSG_VERA" "$IGNORE_MSG_CPPCHECK" "$IGNORE_MSG_CLANG_FORMAT" "$IGNORE_MSG_PEP8"
else
echo "MSGBLD0090: Retrieving changed files using git diff."
file_names=`(git diff --name-only $TRAVIS_COMMIT_RANGE || echo "") | tr '\n' ' '`
fi

printf '%s\n' "$file_names" | while IFS= read -r line
do
for single_file_name in $file_names
do
echo "MSGBLD0095: File changed: $single_file_name"
done
done
echo "MSGBLD0100: Retrieving changed files completed."
echo

echo "MSGBLD0225: Static code analysis skipped due to build configuration."
fi # End of Static code analysis.

# Set the command line arguments for the static code analysis script and execute it.

# The names of the static code analysis tools executables.
VERA=vera++
CPPCHECK=cppcheck
CLANG_FORMAT=clang-format
PEP8=pep8

# Perform or skip a certain analysis.
PERFORM_VERA=true
PERFORM_CPPCHECK=true
PERFORM_CLANG_FORMAT=true
PERFORM_PEP8=true

# The following command line parameters indicate whether static code analysis error messages
# will cause the Travis CI build to fail or are ignored.
IGNORE_MSG_VERA=false
IGNORE_MSG_CPPCHECK=true
IGNORE_MSG_CLANG_FORMAT=false
IGNORE_MSG_PEP8=false

# The script is called within the Travis CI environment and cannot be run incremental.
RUNS_ON_TRAVIS=true
INCREMENTAL=false

chmod +x ./extras/static_code_analysis.sh
./extras/static_code_analysis.sh "$RUNS_ON_TRAVIS" "$INCREMENTAL" "$file_names" "$NEST_VPATH" \
"$VERA" "$CPPCHECK" "$CLANG_FORMAT" "$PEP8" \
"$PERFORM_VERA" "$PERFORM_CPPCHECK" "$PERFORM_CLANG_FORMAT" "$PERFORM_PEP8" \
"$IGNORE_MSG_VERA" "$IGNORE_MSG_CPPCHECK" "$IGNORE_MSG_CLANG_FORMAT" "$IGNORE_MSG_PEP8"

# End of Static code analysis.

cd "$NEST_VPATH"
cp ../examples/sli/nestrc.sli ~/.nestrc
Expand Down Expand Up @@ -241,13 +243,11 @@ echo "MSGBLD0270: Running make install."
make install
echo "MSGBLD0280: Make install completed."

echo
echo "+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"
echo "+ R U N N E S T T E S T S U I T E +"
echo "+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"
if [ "$xSTATIC_ANALYSIS" = "1" ] ; then
echo "MSGBLD0285: Static analysis is enabled; not running make installcheck."
else
if [ "$xRUN_TESTSUITE" = "1" ]; then
echo
echo "+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"
echo "+ R U N N E S T T E S T S U I T E +"
echo "+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"
echo "MSGBLD0290: Running make installcheck."
if [ "$TRAVIS_PYTHON_VERSION" == "2.7.13" ]; then
export PYTHONPATH=$HOME/.cache/csa.install/lib/python2.7/site-packages:$PYTHONPATH
Expand All @@ -258,6 +258,8 @@ else
fi
make installcheck
echo "MSGBLD0300: Make installcheck completed."
else
echo "MSGBLD0305: Skip installcheck."
fi

if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
Expand Down

0 comments on commit 540c885

Please sign in to comment.