Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CI build environment with code coverage, static analysis, valgrind #72

Merged
merged 1 commit into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
codecov:
disable_default_path_fixes: true

fixes:
- home/travis/build/boost/::include/boost/
- home/travis/build/*/*/::

coverage:
range: "85...100"

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no
184 changes: 146 additions & 38 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,172 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright 2016 Peter Dimov
# Copyright 2017, 2018 James E. King III
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)

language: cpp
#
# Generic Travis CI build script for boostorg repositories
#
# Instructions for customizing this script for your library:
#
# 1. Copy the ci/ directory from the same source into your project:
# ci/build.sh runs the build
# ci/codecov.sh is used to run a profiling build and upload results to codecov.io
# ci/coverity.sh is used to run a coverity build and upload results coverity scan
# 2. Customize the compilers and language levels you want. Default is C++03.
# 3. Update the global B2 environment settings to your liking.
# 4. If you have more than include/, src/, and test/ directories then
# add them to the depinst.py line as "--include tools" for tools/ (you
# can put multiple --include on the command line).
# 5. If you want to enable Coverity Scan, you need to provide the environment
# variables COVERITY_SCAN_TOKEN and COVERITY_SCAN_NOTIFICATION_EMAIL in
# your github settings.
# 6. Enable pull request builds in your boostorg/<library> account.
# 7. Change the default C++ version in ci/*.sh (search for CXXSTD)
#
# That's it - the scripts will do everything else for you.

sudo: false
dist: trusty
language: cpp

python: "2.7"
env:
global:
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# to use the default for a given environment, comment it out; recommend you build debug and release however..
# - B2_ADDRESS_MODEL=address-model=64,32
# - B2_LINK=link=shared,static
# - B2_THREADING=threading=multi,single
- B2_VARIANT=variant=release,debug

install:
- export SELF=`basename $TRAVIS_BUILD_DIR`
- cd ..
- git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update -q --init tools/boostdep
- git submodule update -q --init tools/build
- git submodule update -q --init tools/inspect
- cp -r $TRAVIS_BUILD_DIR/* libs/$SELF
- export BOOST_ROOT="`pwd`"
- export PATH="`pwd`":$PATH
- python tools/boostdep/depinst/depinst.py $SELF --include example
- ./bootstrap.sh
- ./b2 headers

addons:
apt:
packages:
- binutils-gold
- gdb
- libc6-dbg

branches:
only:
- master
- develop
- /feature\/.*/

env:
matrix:
- BOGUS_JOB=true

matrix:

exclude:
- env: BOGUS_JOB=true
- master

script:
- cd libs/$SELF
- ci/build.sh

jobs:
include:
#################### Jobs to run on every pull request ####################
- os: linux
env:
- COMMENT="C++03"
- TOOLSET=gcc,gcc-7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g++ 7 is -std=gnu++14 by default if you don't pass anything; if you really want c++03, need cxxstd=03.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw that you're setting it to 03 in ci/build.sh if not set; you can ignore that then :-) although I'd still use CXXSTD: 03 here. Testing without -std= set is a legitimate scenario that you might wish to enable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is handled in the ci/build.sh script.
CXXSTD=03 is used if not set otherwise for this particular repo.

addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++
env: TOOLSET=gcc CXXSTD=03,11
env:
- COMMENT="C++11"
- TOOLSET=clang
- CXXSTD=11
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
env:
- COMMENT=valgrind
- TOOLSET=clang
- B2_VARIANT=variant=debug
- TESTFLAGS=testing.launcher=valgrind
addons:
apt:
packages:
- clang-5.0
- libstdc++-7-dev
- valgrind
sources:
- llvm-toolchain-trusty-5.0
- ubuntu-toolchain-r-test

- os: linux
env:
- COMMENT=cppcheck
script:
- libs/$SELF/ci/cppcheck.sh

- os: linux
compiler: clang++
env: TOOLSET=clang CXXSTD=03,11
env:
- COMMENT=UBSAN
- B2_VARIANT=variant=debug
- TOOLSET=gcc-7
- CXXFLAGS="cxxflags=-fno-omit-frame-pointer cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined"
- LINKFLAGS="linkflags=-fsanitize=undefined linkflags=-fno-sanitize-recover=undefined"
- UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libstdc++-4.9-dev
- g++-7
sources:
- ubuntu-toolchain-r-test

# the backlog of macos builds is too long to justify waiting a day for this
# - os: osx
# compiler: clang++
# env: TOOLSET=clang CXXSTD=03,11
- os: linux
env:
- COMMENT=CodeCov
- TOOLSET=gcc-7
addons:
apt:
packages:
- gcc-7
- g++-7
- lcov
sources:
- ubuntu-toolchain-r-test
script:
- cd libs/$SELF
- ci/codecov.sh

install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/date_time
- python tools/boostdep/depinst/depinst.py date_time
- ./bootstrap.sh
- ./b2 headers
# osx was disabled because it is very slow to start (can delay builds by 30 minutes)
# - os: osx
# osx_image: xcode9
# env:
# - TOOLSET=clang
# - CXXSTD=03,11

script:
- ./b2 libs/date_time/test toolset=$TOOLSET cxxstd=$CXXSTD
#################### Jobs to run on master merges only ###################

# Coverity Scan
- os: linux
if: branch = master
env:
- COMMENT="Coverity Scan"
- TOOLSET=gcc
script:
- echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
- cd libs/$SELF
- ci/coverity.sh

notifications:
email:
on_success: always
false

63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
DateTime, part of the collection of [Boost C++ Libraries](http://github.com/boostorg), makes programming with dates and times as simple and natural as programming with strings and integers.

### License

Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).

### Properties

* C++03
* Requires Linking

### Build Status

Branch | Travis | Appveyor | Coverity Scan | codecov.io | Documentation | Regression Tests
--------------- | ------ | -------- | ------------- | ---------- | ------------- | ----------------
[master](https://github.com/boostorg/date_time/tree/master) | [![Build Status](https://travis-ci.org/boostorg/date_time.svg?branch=master)](https://travis-ci.org/boostorg/date_time) | [![Build status](https://ci.appveyor.com/api/projects/status/upf5c528fy09fudk?svg=true)](https://ci.appveyor.com/project/jeking3/date-time-1evbf) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/14908/badge.svg)](https://scan.coverity.com/projects/boostorg-date_time) | [![codecov](https://codecov.io/gh/boostorg/date_time/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/date_time/branch/master) | [![Documentation](https://img.shields.io/badge/documentation-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/date_time.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/date_time.html)
[develop](https://github.com/boostorg/date_time/tree/develop) | [![Build Status](https://travis-ci.org/boostorg/date_time.svg?branch=develop)](https://travis-ci.org/boostorg/date_time) | [![Build status](https://ci.appveyor.com/api/projects/status/upf5c528fy09fudk/branch/develop?svg=true)](https://ci.appveyor.com/project/boostorg/date_time/branch/develop) | | [![codecov](https://codecov.io/gh/boostorg/date_time/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/date_time/branch/develop) | [![Documentation](https://img.shields.io/badge/documentation-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/date_time.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/date_time.html)

### Dependencies

This is a list of other Boost libraries that are required by Boost.DateTime:

* algorithm
* assert
* config
* core
* io
* lexical_cast
* mpl
* numeric
* range
* serialization
* smart_ptr
* static_assert
* throw_exception
* test (for running unit tests only)
* tokenizer
* type_traits
* utility
* winapi

### Directories

| Name | Purpose |
| --------- | ------------------------------ |
| `build` | build script for link library |
| `ci` | continuous integration scripts |
| `data` | timezone database |
| `doc` | documentation |
| `example` | use case examples |
| `include` | headers |
| `src` | source code for link library |
| `test` | unit tests |
| `xmldoc` | additional documentation |

### More information

* [Documentation](http://boost.org/libs/date_time)
* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-date_time): Be sure to read the documentation first to see if it answers your question.
* [Report bugs](https://github.com/boostorg/date_time/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* [Submit Pull Requests](https://github.com/boostorg/date_time/pulls) against the **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). Be sure to include tests proving your changes work properly.
* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[date_time]` tag at the beginning of the subject line.

4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ environment:
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARCH: i686
B2_ADDRESS_MODEL: address-model=32
SCRIPT: build\mingw.bat
SCRIPT: ci\mingw.bat
- FLAVOR: mingw64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARCH: x86_64
B2_ADDRESS_MODEL: address-model=64
SCRIPT: build\mingw.bat
SCRIPT: ci\mingw.bat

install:
- set SELF=date_time
Expand Down
21 changes: 21 additions & 0 deletions build/finddeps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# A script to find direct depenedencies (for documentation)
#
# Copyright (c) 2018 James E. King III
#
# Use, modification, and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#!/bin/bash

set -e

# takes one or more arguments - subdirectories to calculate depenedencies for
function finddeps
{
local hdrs=`find $* -type f -exec grep 'include' {} \; | grep 'boost/' | grep -v 'date_time' | sed 's/</\"/g' | sed 's/>/\"/g' | cut -d\" -f2 | sort | uniq`
local deps=`for hdr in $hdrs; do local hdronly=${hdr##*/}; find .. -name $hdronly -print | grep $hdr | cut -d'/' -f2; done`
echo $deps | xargs -n1 | sort -u
}

finddeps $*
19 changes: 19 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/bash
#
# Copyright 2017 James E. King III
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# Bash script to run in travis to perform a bjam build
# cwd should be $BOOST_ROOT/libs/$SELF before running
#

set -ex

# default language level: c++03
if [[ -z "$CXXSTD" ]]; then
CXXSTD=03
fi

$BOOST_ROOT/b2 . toolset=$TOOLSET cxxstd=$CXXSTD $CXXFLAGS $DEFINES $LINKFLAGS $TESTFLAGS $B2_ADDRESS_MODEL $B2_LINK $B2_THREADING $B2_VARIANT -j3 $*
44 changes: 44 additions & 0 deletions ci/codecov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#! /bin/bash
#
# Copyright 2017 James E. King III
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# Bash script to run in travis to perform codecov.io integration
#

###
### NOTE: Make sure you grab and customize .codecov.yml
###

# assumes cwd is the top level directory of the boost project
# assumes an environment variable $SELF is the boost project name

set -ex

B2_VARIANT=debug
ci/build.sh cxxflags=-fprofile-arcs cxxflags=-ftest-coverage linkflags=-fprofile-arcs linkflags=-ftest-coverage

# switch back to the original source code directory
# this ensures codecov doesn't get confused
cd $TRAVIS_BUILD_DIR

# get the version of lcov
lcov --version

# coverage files are in ../../b2 from this location
lcov --gcov-tool=gcov-7 --rc lcov_branch_coverage=1 --base-directory `pwd` --directory "$BOOST_ROOT" --capture --output-file all.info

# all.info contains all the coverage info for all projects - limit to ours
lcov --gcov-tool=gcov-7 --extract all.info "*/boost/$SELF/*" --output-file coverage.info

# dump a summary just for grins
lcov --gcov-tool=gcov-7 --list coverage.info

#
# upload to codecov.io
#
curl -s https://codecov.io/bash > .codecov
chmod +x .codecov
./.codecov -f coverage.info -X gcov -x "gcov-7"
Loading