Coverity scan (#1479)

Added a basic Travis integration and added configuration details for coverity scans. Travis could be refined though.
This commit is contained in:
Jorrit Wronski
2017-04-21 16:47:20 +02:00
committed by GitHub
parent f5fd54537d
commit 44172d1df0
6 changed files with 373 additions and 2 deletions

95
.travis.yml Normal file
View File

@@ -0,0 +1,95 @@
notifications:
email:
on_success: never
on_failure: change
language:
- cpp
#os: linux
#dist: trusty
#
#compiler:
# - clang
# - gcc
#
#addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# - llvm-toolchain-trusty
# packages:
# - cmake
# - gcc-6
# - g++-6
# - clang-3.7
matrix:
include:
- os: linux
dist: trusty
branches:
only:
- master
- release
- travis_integration
before_script:
# Check compiler and cmake versions
- cmake --version; gcc -v; clang -v
- echo "$CXX" && "$CXX" -v
# Run your build commands next
- cmake . -DCMAKE_BUILD_TYPE=Release -DCOOLPROP_STATIC_LIBRARY=ON
script:
- cmake --build . --config Release
- os: linux
dist: trusty
branches:
only:
- coverity_scan
# before_install:
# - echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
addons:
coverity_scan:
project:
name: "CoolProp/CoolProp"
description: "Build submitted via Travis CI"
notification_email: jowr@ipu.dk
build_command_prepend: "cmake . -DCOOLPROP_MY_MAIN=dev/coverity/main.cxx"
build_command: "cmake --build . --target Main"
branch_pattern: coverity_scan
before_script: cmake . -DCOOLPROP_MY_MAIN=dev/coverity/main.cxx
script: cmake --build . --target Main
#branches:
# only:
# - master
# - release
# - coverity_scan
# - travis_integration
# # Build all branches
# # - /.*/
env:
global:
- secure: "XGfICTnfFv9xpVDBbNwJIkXV0OZCAcOT46aeFYmODm3jl+ya60k0C91G9zlZ9fEYiQwAEBTO2Y/Ge0AMaoFqtu3H3vu7S5JjAbpMV3ZRDJqampScy550yPpziOuxvB6h23PZRfLOBVEsUGHnCO5rLb20iPM94XsHSBL3Smn2o9c="
#install:
# - if [ "$CXX" = "g++" ]; then export CXX="g++-6" CC="gcc-6"; fi
# - if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi
# before_script:
# # Check compiler and cmake versions
# - cmake --version; gcc -v; clang -v
# - echo "$CXX" && "$CXX" -v
# # Run your build commands next
# - mkdir build && pushd build
# - echo "${TRAVIS_BUILD_DIR}"
# - cmake .. -DCMAKE_BUILD_TYPE=Release # Same as "${TRAVIS_BUILD_DIR}"
# - popd
# script:
# - cmake --build build --config Release

View File

@@ -0,0 +1,192 @@
notifications:
email:
on_success: never
on_failure: change
language: python
#os:
# - linux
# - osx
matrix:
include:
- os: linux
dist: trusty
sudo: required # false or required, use required to get docker
env: BUILD_TARGET="PYTHON_LINUX"
# - os: linux
# dist: precise
# sudo: required # false or required
# env: BUILD_TARGET="PYTHON_LINUX"
# - os: linux
# dist: trusty
# sudo: false # false or required
# env: BUILD_TARGET="PYTHON_LINUX"
# - os: linux
# dist: precise
# sudo: false # false or required
# env: BUILD_TARGET="PYTHON_LINUX"
# - os: osx
# language: generic
# osx_image: xcode8.3 # Xcode 8.3 OS X 10.12
# env: BUILD_TARGET="PYTHON_APPLE"
# - os: osx
# language: generic
# osx_image: xcode8.2 # Xcode 8.2 OS X 10.12
# env: BUILD_TARGET="PYTHON_APPLE"
# - os: osx
# language: generic
# osx_image: xcode8.1 # Xcode 8.1 OS X 10.12
# env: BUILD_TARGET="PYTHON_APPLE"
# - os: osx
# language: generic
# osx_image: xcode8 # Xcode 8gm OS X 10.11
# env: BUILD_TARGET="PYTHON_APPLE"
# - os: osx
# language: generic
# osx_image: xcode7.3 # Default Xcode 7.3.1 OS X 10.11
# env: BUILD_TARGET="PYTHON_APPLE"
# The old image does not have pip available ...
# - os: osx
# language: generic
# osx_image: xcode6.4 # Xcode 6.4 OS X 10.10
# Build the Linux wheels based on https://github.com/pypa/python-manylinux-demo
# - os: linux
# dist: trusty
# sudo: required
# services:
# - docker
# env: BUILD_TARGET="PYTHON_LINUX_WHEELS_CUSTOM"
# BITNESS="32"
- os: linux
dist: trusty
sudo: required
services:
- docker
env: BUILD_TARGET="PYTHON_LINUX_WHEELS"
DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
DOCKER_IMAGE=dockcross/manylinux-x64
PRE_CMD=""
SETUP_PY_ARGS="cmake=default,64"
- os: linux
dist: trusty
sudo: required
services:
- docker
env: BUILD_TARGET="PYTHON_LINUX_WHEELS"
DOCKER_IMAGE=quay.io/pypa/manylinux1_i686
DOCKER_IMAGE=dockcross/manylinux-x86
PRE_CMD=linux32
SETUP_PY_ARGS="cmake=default,32"
- os: osx
language: generic
env: BUILD_TARGET="PYTHON_APPLE"
PYTHON_VERSION="2.7.13"
- os: osx
language: generic
env: BUILD_TARGET="PYTHON_APPLE"
PYTHON_VERSION="3.3.5"
- os: osx
language: generic
env: BUILD_TARGET="PYTHON_APPLE"
PYTHON_VERSION="3.4.5"
- os: osx
language: generic
env: BUILD_TARGET="PYTHON_APPLE"
PYTHON_VERSION="3.5.3"
- os: osx
language: generic
env: BUILD_TARGET="PYTHON_APPLE"
PYTHON_VERSION="3.6.1"
# - os: linux
# dist: trusty
# sudo: required
# - os: osx
# osx_image: xcode7.2
#addons:
# apt:
# packages:
# - cmake
#before_install:
# - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update ; fi
# - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install cmake; fi
# - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update ; fi
# - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install cmake; fi
#See: http://stackoverflow.com/questions/41916656/how-to-use-travis-ci-to-build-modern-c-using-modern-cmake
#dist: trusty
#sudo: required
#language:
# - cpp
#compiler:
# - gcc
#language:
# - python
install:
# Commands for building the Python packages
- if [ "$BUILD_TARGET" = "PYTHON_APPLE" ]; then git clone --recursive https://github.com/MacPython/terryfy.git; fi
- if [ "$BUILD_TARGET" = "PYTHON_APPLE" ]; then source terryfy/travis_tools.sh; fi
- if [ "$BUILD_TARGET" = "PYTHON_APPLE" ]; then get_python_environment macpython "${PYTHON_VERSION}" venv; fi
- if [ "$BUILD_TARGET" = "PYTHON_APPLE" ]; then pip install cython wheel; fi
- if [ "$BUILD_TARGET" = "PYTHON_LINUX" ]; then pip install cython wheel auditwheel; fi
# Commands for building the Python wheel
# - if [ "$DOCKER_IMAGE" == *"manylinux"* ]; then docker pull $DOCKER_IMAGE; fi
- if [ "$BUILD_TARGET" = "PYTHON_LINUX_WHEELS" ]; then docker pull $DOCKER_IMAGE; fi
#addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - gcc-6
# - g++-6
# - cmake
# Build all branches
branches:
only:
- /.*/
script:
# # Link gcc-6 and g++-6 to their standard commands
# - ln -s /usr/bin/gcc-6 /usr/local/bin/gcc
# - ln -s /usr/bin/g++-6 /usr/local/bin/g++
# # Export CC and CXX to tell cmake which compiler to use
# - export CC=/usr/bin/gcc-6
# - export CXX=/usr/bin/g++-6
# # Check versions of gcc, g++ and cmake
# - gcc -v && g++ -v && cmake --version
# # Run your build commands next
# - git clone --recursive https://github.com/CoolProp/CoolProp.git
# - cd CoolProp
# - mkdir build
# - cd build
# - cmake .. -DCOOLPROP_SHARED_LIBRARY=ON
# - cmake --build . --config Release
- |
if [ "$BUILD_TARGET" = "PYTHON_LINUX" -o "$BUILD_TARGET" = "PYTHON_APPLE" ]; then
cd wrappers/Python
python setup.py bdist_wheel
pip install dist/*.whl
if [ "$BUILD_TARGET" = "PYTHON_LINUX" ]; then mkdir -p dist_audit; auditwheel repair dist/*.whl -w dist_audit/; fi
cd ../..
python -c 'from CoolProp.CoolProp import get_global_param_string; print("CoolProp gitrevision:", get_global_param_string("gitrevision"))'
fi
# Commands for building the Python wheels
- |
if [ "$BUILD_TARGET" = "PYTHON_LINUX_WHEELS_CUSTOM" ]; then
pushd wrappers/Python/manylinux/
chmod +x 00_prepare_docker.sh
./00_prepare_docker.sh "${BITNESS}"
fi
- |
if [ "$BUILD_TARGET" = "PYTHON_LINUX_WHEELS" ]; then
chmod +x .travis/build_wheels.sh
docker run --rm -v `pwd`:/io $DOCKER_IMAGE $PRE_CMD /io/.travis/build_wheels.sh "${SETUP_PY_ARGS}"
fi
# - if [ "$BUILD_TARGET" = *"PYTHON_LINUX_WHEELS"* ]; then ls wheelhouse/; fi

63
.travis/build_wheels.sh Normal file
View File

@@ -0,0 +1,63 @@
#!/bin/bash
SETUP_PY_ARGS="$1"
# https://github.com/pypa/python-manylinux-demo/blob/master/travis/build-wheels.sh
set -e -x
# Get the directory containing this script
# see http://stackoverflow.com/a/246128/1360263
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Install a system package required by our library
#yum install -y atlas-devel
#yum install -y cmake
#if [ "$SETUP_PY_ARGS" = *"32" ]; then
# CMAKE_URL="https://cmake.org/files/v3.6/cmake-3.6.3-Linux-i386.tar.gz"
#else
# CMAKE_URL="https://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz"
#fi
#mkdir cmake && wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
#export PATH=${DIR}/cmake/bin:${PATH}
mkdir -p /io/wheelhouse_tmp
mkdir -p /io/wheelhouse
OLD_PATH=${PATH}
# Compile wheels
for PYBIN in /opt/python/*/bin; do
PYV_MAJOR=`"${PYBIN}/python" -c "import sys;print(list(sys.version_info[:2])[0])";`
PYV_MINOR=`"${PYBIN}/python" -c "import sys;print(list(sys.version_info[:2])[1])";`
echo Detected Python ${PYV_MAJOR}.${PYV_MINOR}
if [ "${PYV_MAJOR}" -le "2" -a "${PYV_MINOR}" -lt "7" ]; then
continue
fi
export PATH="${PYBIN}:$OLD_PATH"
#ls -lh "${PYBIN}"
pip install cython wheel
#"${PYBIN}/pip" install scikit-build cmake
pushd /io/wrappers/Python
python setup.py bdist_wheel ${SETUP_PY_ARGS}
cp dist/*.whl /io/wheelhouse_tmp/
popd
#deactivate
#"${PYBIN}/pip" install cython wheel
#"${PYBIN}/pip" wheel /io/wrappers/Python --wheel-dir /io/wheelhouse_tmp/ --build-options ${SETUP_PY_ARGS}
#"${PYBIN}/pip" wheel /io/wrappers/Python -w /io/wheelhouse_tmp/
done
export PATH="$OLD_PATH"
# Bundle external shared libraries into the wheels
for whl in /io/wheelhouse_tmp/*.whl; do
auditwheel repair "$whl" -w /io/wheelhouse/
done
## Install packages and test
#for PYBIN in /opt/python/*/bin/; do
# "${PYBIN}/pip" install python-manylinux-demo --no-index -f /io/wheelhouse
# (cd "$HOME"; "${PYBIN}/nosetests" pymanylinuxdemo)
#done

View File

@@ -1,5 +1,6 @@
#include "CoolProp.h"
#include <iostream>
#include <stdlib.h>
using namespace CoolProp;
int main()
{
@@ -7,7 +8,7 @@ int main()
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane[0.5]&Ethane[0.5]") << std::endl; // Default backend is HEOS
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane[0.5]&Ethane[0.5]") << std::endl;
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane[0.5]&Ethane[0.5]") << std::endl;
// Vector example
std::vector<double> z(2,0.5);
// Second type (C++ only, a bit faster, allows for vector inputs and outputs)
std::vector<std::string> fluids; fluids.push_back("Propane"); fluids.push_back("Ethane");
@@ -17,6 +18,6 @@ int main()
std::cout << PropsSImulti(outputs,"T", T, "P", p, "HEOS", fluids, z)[0][0] << std::endl;
// Comment me out if REFPROP is not installed
std::cout << PropsSImulti(outputs,"T", T, "P", p, "REFPROP", fluids, z)[0][0] << std::endl;
// All done return
return EXIT_SUCCESS;
}

View File

@@ -3,6 +3,10 @@
Diagnostics and Testing
***********************
Travis Builds
-------------
Coverity Scan
-------------
@@ -23,6 +27,11 @@ Coverity Scan
4. Upload to coverity scan
.. note::
In April 2017, the upload to Coverity Scan has been automated and all you have to do is to merge and push new code to the branch coverity_scan, Travis CI will do the rest.
Address Sanitizer
-----------------

11
dev/coverity/main.cxx Normal file
View File

@@ -0,0 +1,11 @@
#include "CoolProp.h"
#include <iostream>
#include <stdlib.h>
using namespace CoolProp;
int main()
{
// First type (slowest, due to most string processing, exposed in DLL)
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane[0.5]&Ethane[0.5]") << std::endl; // Default backend is HEOS
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane[0.5]&Ethane[0.5]") << std::endl;
return EXIT_SUCCESS;
}