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

add codecov.io support #91

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1c8ab53
add codecov.io support
Oct 31, 2019
3ff0dce
fixup! add codecov.io support
Oct 31, 2019
dbf01a5
fixup! add codecov.io support
Nov 2, 2019
2750095
fixup! add codecov.io support
Nov 5, 2019
f5e3725
cleanup (#1)
rhaschke Nov 9, 2019
4e9301b
code build support from ros package
tylerjw Nov 15, 2019
89c2671
travis test for code-coverage
tylerjw Nov 15, 2019
0581d2c
fixup! travis test for code-coverage
tylerjw Nov 15, 2019
93bb2a5
Update README.md
tylerjw Nov 15, 2019
a860246
Update README.md
tylerjw Nov 16, 2019
be93423
add support for TEST_WHITELIST
Nov 16, 2019
a95ddd7
fixup! add support for TEST_WHITELIST
Nov 16, 2019
21a7ecb
fixup! add support for TEST_WHITELIST
Nov 16, 2019
2448440
fixup! add support for TEST_WHITELIST
Nov 16, 2019
248c635
fixup! add support for TEST_WHITELIST
Nov 17, 2019
974df38
Update README.md
tylerjw Nov 17, 2019
522ed45
Update README.md
tylerjw Nov 17, 2019
5bd9305
make unit test cmake match example in README
Nov 17, 2019
bfe4b2f
respond to review
Nov 17, 2019
54b8ba0
add .codecov.yml back into readme
Nov 18, 2019
8515b98
Update test_pkgs/valid/CMakeLists.txt
tylerjw Nov 18, 2019
1b4273f
Update test_pkgs/valid/CMakeLists.txt
tylerjw Nov 18, 2019
28c9091
gcov ignore files in test directory
tylerjw Nov 19, 2019
098f5dd
remove codecov.yml instructions from README.md
tylerjw Nov 19, 2019
50302b7
test whitelist applied to build
tylerjw Nov 19, 2019
fa69f0a
fixup! test whitelist applied to build
tylerjw Nov 19, 2019
81bac21
redirect output of codecov script to avoid filling logs
Nov 20, 2019
7a6be1e
fixup! redirect output of codecov script to avoid filling logs
Nov 20, 2019
e370f5c
fixup! redirect output of codecov script to avoid filling logs
Nov 20, 2019
6d04961
set compile flag to improve ccache hit rate
Nov 20, 2019
949b5ed
add support for ccache enviroment variables
Nov 20, 2019
09db83a
reduce complexity of catkin build line
Nov 20, 2019
38e96b4
set ccache base dir
Nov 20, 2019
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
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ It's also possible to run the script without using docker. To this end, issue th

## Enabling codecov.io reporting

For codecov to work you need to build and link your C++ code with specific parameters. To enable this we use the ROS package [code_coverage](https://github.com/mikeferguson/code_coverage). Using the `code-coverage` test in your repo requires the following three changes:
For codecov to work you need to build and link your C++ code with specific parameters. To enable this we use the ROS package [code_coverage](https://github.com/mikeferguson/code_coverage). Using the `code-coverage` test in your repo requires the following two changes:

1. Add `<test_depend>code_coverage</test_depend>` to your package.xml
2. Add this to your `CMakeLists.txt`:
Expand All @@ -161,13 +161,6 @@ if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING)
endif()
```

3. Add a `.codecov.yml` file to your project root to specifiy what codecov.io's script should ignore:

```yaml
ignore:
- "**/test/.*"
```

Then you can use the `code-coverage` test and it will run the script provided by [codecov.io](codecov.io) which runs `gcov` to generate the reports and then compiles them into a report and uploads them to their servers.

If you are using this on a private github repo you will need to set the `CODECOV_TOKEN` enviroment variable in the `global` section of your `.travis.yml` file to the value you can find on the settings page of your project on codecov.io.
3 changes: 1 addition & 2 deletions test_pkgs/valid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ include_directories(
${catkin_INCLUDE_DIRS}
)

if (CATKIN_ENABLE_TESTING)
if(CATKIN_ENABLE_TESTING)
catkin_add_gtest(${PROJECT_NAME} test.cpp)
endif()

# to run: catkin_make -DENABLE_COVERAGE_TESTING=ON package_name_coverage
if(CATKIN_ENABLE_TESTING AND ENABLE_COVERAGE_TESTING)
find_package(code_coverage REQUIRED) # catkin package ros-*-code-coverage
include(CodeCoverage)
Expand Down
21 changes: 18 additions & 3 deletions travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ function run_docker() {
-e CXX=${CXX_FOR_BUILD:-${CXX:-c++}} \
-e CFLAGS \
-e CXXFLAGS \
-e CCACHE_SLOPPINESS \
tylerjw marked this conversation as resolved.
Show resolved Hide resolved
-e CCACHE_MAXSIZE \
$CI_ENV_PARAMS \
-v $(pwd):/root/$REPOSITORY_NAME \
-v ${CCACHE_DIR:-$HOME/.ccache}:/root/.ccache \
Expand Down Expand Up @@ -282,8 +284,18 @@ function build_workspace() {
# Console output fix for: "WARNING: Could not encode unicode characters"
export PYTHONIOENCODING=UTF-8

# For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait
travis_run_wait 60 --title "catkin build" catkin build --no-status --summarize
# Set compile flag to improve ccache hit rate
export CXXFLAGS="$CXXFLAGS -fdebug-prefix-map=$(pwd)=."
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious: How does this effect ccache? Isn't this a debugging option of gcc?

Copy link
Member Author

Choose a reason for hiding this comment

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

That idea came from this: https://cppisland.wordpress.com/2018/12/30/ccache-quick-guide/

The basics is that with a Debug build there is a chance the hit rate is low because of paths in the debug symbols and this is one way to fix that. This should have no affect on non-debug builds.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for providing the link. However, their use case is different: They are building the same stuff in different folders, while for us all files reside in the very same folder between build attempts. Hence, there shouldn't be a cache miss due to cwd.
Did you look into the log files generated with export CCACHE_DEBUG=1 between to consecutive (local) builds?

echo "CXXFLAGS = $CXXFLAGS"

# If test whitelist is set, explicitly build that project
if [ "${TEST_WHITELIST:-}" ]; then
tylerjw marked this conversation as resolved.
Show resolved Hide resolved
# For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait
travis_run_wait 60 --title "catkin build ${TEST_WHITELIST}" catkin build $TEST_WHITELIST --no-status --summarize
else
# For a command that doesn’t produce output for more than 10 minutes, prefix it with travis_run_wait
travis_run_wait 60 --title "catkin build" catkin build --no-status --summarize
fi

# Allow to verify ccache usage
travis_run --title "ccache statistics" ccache -s
Expand Down Expand Up @@ -390,7 +402,10 @@ for t in $(unify_list " ,;" "$TEST") ; do
test $? -eq 0 || result=$(( ${result:-0} + 1 ))
;;
code-coverage)
travis_run --title "codecov.io report upload" bash <(curl -s https://codecov.io/bash) -s $ROS_WS -R $ROS_WS/src/$REPOSITORY_NAME
# redirect output to avoid failures due to filling up logs
travis_run --title "codeco1v.io report upload" \
bash <(curl -s https://codecov.io/bash) -s $ROS_WS \
-R $ROS_WS/src/$REPOSITORY_NAME -g '*/test/*' > /dev/null
;;
esac
done
Expand Down