Skip to content

Commit

Permalink
Merge pull request #990 from ruffsl/rmw
Browse files Browse the repository at this point in the history
Extend CI Workflow to test multiple RMW
  • Loading branch information
ruffsl committed Aug 21, 2019
2 parents 8b239fb + 618e642 commit 5c0dfbe
Show file tree
Hide file tree
Showing 12 changed files with 550 additions and 251 deletions.
556 changes: 361 additions & 195 deletions .circleci/config.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .dockerhub/debug/Dockerfile
12 changes: 12 additions & 0 deletions .dockerhub/debug/dummy.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This is a dummy Dockerfile for setting repository links on Docker Hub.
# Build rules on Docker Hub can trigger whenever the base image updates.
# Base images are specified in the FROM: directive in the tracked Dockerfile.
# However, build args are used by the build hooks to adjust the base image
# so a single Dockerfile can be reused for multiple CI jobs, reducing maintenance.
# To re-enable repository linking when using build args in the FROM: directive,
# this dummy Dockerfile explicitly conveys the base image/repo to link against
# while build rules that target this still use the same hook in this directory.
# Note: This only works for non-official images.

FROM osrf/ros2:nightly
RUN echo "This is a dummy Dockerfile."
14 changes: 14 additions & 0 deletions .dockerhub/debug/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -ex

FROM_IMAGE=osrf/ros2:nightly
FAIL_ON_BUILD_FAILURE=""
UNDERLAY_MIXINS="debug ccache"
OVERLAY_MIXINS="debug ccache coverage-gcc"
docker build \
--tag ${IMAGE_NAME} \
--build-arg FROM_IMAGE \
--build-arg FAIL_ON_BUILD_FAILURE \
--build-arg UNDERLAY_MIXINS \
--build-arg OVERLAY_MIXINS \
--file ./Dockerfile ../../.
1 change: 1 addition & 0 deletions .dockerhub/devel/Dockerfile
10 changes: 10 additions & 0 deletions .dockerhub/devel/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -ex

ROS_DISTRO=${SOURCE_BRANCH%"-devel"}
FROM_IMAGE=ros:${ROS_DISTRO}
docker build \
--tag ${IMAGE_NAME} \
--build-arg FROM_IMAGE \
--build-arg FAIL_ON_BUILD_FAILURE="" \
--file ./Dockerfile ../../.
1 change: 1 addition & 0 deletions .dockerhub/release/Dockerfile
12 changes: 12 additions & 0 deletions .dockerhub/release/dummy.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This is a dummy Dockerfile for repository links on Docker Hub.
# Build rules on Docker Hub can trigger whenever the base image updates.
# Base images are specified in the FROM: directive in the tracked Dockerfile.
# However, build args are used by the build hooks to adjust the base image
# so a single Dockerfile can be reused for multiple CI jobs, reducing maintenance.
# To re-enable repository linking when using build args in the FROM: directive,
# this dummy Dockerfile explicitly conveys the base image/repo to link against
# while build rules that target this still use the same hook in this directory.
# Note: This only works for non-official images.

FROM osrf/ros2:nightly-rmw-nonfree
RUN echo "This is a dummy Dockerfile."
14 changes: 14 additions & 0 deletions .dockerhub/release/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -ex

FROM_IMAGE=osrf/ros2:nightly-rmw-nonfree
FAIL_ON_BUILD_FAILURE=""
UNDERLAY_MIXINS="release ccache"
OVERLAY_MIXINS="release ccache"
docker build \
--tag ${IMAGE_NAME} \
--build-arg FROM_IMAGE \
--build-arg FAIL_ON_BUILD_FAILURE \
--build-arg UNDERLAY_MIXINS \
--build-arg OVERLAY_MIXINS \
--file ./Dockerfile ../../.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
################################################################################
# Repo

.circleci/*
.git/*
.dockerignore
.gitignore
**Dockerfile
codecov.yml
107 changes: 67 additions & 40 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
# This dockerfile expects proxies to be set via --build-arg if needed
# It also expects to be contained in the /navigation2 root folder for file copy
# This dockerfile can be configured via --build-arg
# Build context must be the /navigation2 root folder for COPY.
# Example build command:
# export CMAKE_BUILD_TYPE=Debug
# docker build -t nav2:latest --build-arg CMAKE_BUILD_TYPE ./
FROM osrf/ros2:nightly

# copy ros package repo
ENV NAV2_WS /opt/nav2_ws
RUN mkdir -p $NAV2_WS/src
WORKDIR $NAV2_WS/src
COPY ./ navigation2/

# clone dependency package repos
ENV ROS_WS /opt/ros_ws
RUN mkdir -p $ROS_WS/src
WORKDIR $ROS_WS
RUN vcs import src < $NAV2_WS/src/navigation2/tools/ros2_dependencies.repos

# install dependency package dependencies
# export UNDERLAY_MIXINS="debug ccache"
# export OVERLAY_MIXINS="debug ccache coverage"
# docker build -t nav2:latest \
# --build-arg UNDERLAY_MIXINS \
# --build-arg OVERLAY_MIXINS ./
ARG FROM_IMAGE=osrf/ros2:nightly
FROM $FROM_IMAGE

# install CI dependencies
RUN apt-get update && \
apt-get install -q -y \
ccache \
lcov \
python3-colcon-mixin \
&& rm -rf /var/lib/apt/lists/*

# setup colcon mixin / meta
RUN colcon mixin add upstream \
https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml && \
colcon mixin update && \
colcon metadata add upstream \
https://raw.githubusercontent.com/colcon/colcon-metadata-repository/master/index.yaml && \
colcon metadata update

# clone underlay source
ENV UNDERLAY_WS /opt/underlay_ws
RUN mkdir -p $UNDERLAY_WS/src
WORKDIR $UNDERLAY_WS
COPY ./tools/ros2_dependencies.repos ./
RUN vcs import src < ros2_dependencies.repos

# install underlay dependencies
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
apt-get update && \
rosdep install -q -y \
Expand All @@ -26,37 +41,49 @@ RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
--ignore-src \
&& rm -rf /var/lib/apt/lists/*

# build dependency package source
ARG CMAKE_BUILD_TYPE=Release

# build underlay source
ARG UNDERLAY_MIXINS="release ccache"
ARG FAIL_ON_BUILD_FAILURE=True
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \
colcon build \
--symlink-install \
--cmake-args \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE
--mixin \
$UNDERLAY_MIXINS \
|| touch build_failed && \
if [ -f build_failed ] && [ -n "$FAIL_ON_BUILD_FAILURE" ]; then \
exit 1; \
fi

# copy overlay source
ENV OVERLAY_WS /opt/overlay_ws
RUN mkdir -p $OVERLAY_WS/src
WORKDIR $OVERLAY_WS
COPY ./ src/navigation2/

# install navigation2 package dependencies
WORKDIR $NAV2_WS
RUN . $ROS_WS/install/setup.sh && \
# install overlay dependencies
RUN . $UNDERLAY_WS/install/setup.sh && \
apt-get update && \
rosdep install -q -y \
--from-paths \
$ROS_WS/src \
$UNDERLAY_WS/src \
src \
--ignore-src \
&& rm -rf /var/lib/apt/lists/*

# build navigation2 package source
RUN rm $NAV2_WS/src/navigation2/nav2_system_tests/COLCON_IGNORE
ARG COVERAGE_ENABLED=False
RUN . $ROS_WS/install/setup.sh && \
colcon build \
--symlink-install \
--cmake-args \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-DCOVERAGE_ENABLED=$COVERAGE_ENABLED

# source navigation2 workspace from entrypoint
# build overlay source
ARG OVERLAY_MIXINS="release ccache"
RUN rm $OVERLAY_WS/src/navigation2/nav2_system_tests/COLCON_IGNORE
RUN . $UNDERLAY_WS/install/setup.sh && \
colcon build \
--symlink-install \
--mixin \
$OVERLAY_MIXINS \
|| touch build_failed && \
if [ -f build_failed ] && [ -n "$FAIL_ON_BUILD_FAILURE" ]; then \
exit 1; \
fi

# source overlay from entrypoint
RUN sed --in-place \
's|^source .*|source "$NAV2_WS/install/setup.bash"|' \
's|^source .*|source "$OVERLAY_WS/install/setup.bash"|' \
/ros_entrypoint.sh
64 changes: 48 additions & 16 deletions tools/code_coverage_report.bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set -e
LCOVDIR=lcov
PWD=`pwd`

COVERAGE_REPORT=genhtml
COVERAGE_REPORT_VIEW="genhtml"

for opt in "$@" ; do
case "$opt" in
Expand All @@ -24,30 +24,62 @@ for opt in "$@" ; do
exit 0
;;
codecovio)
COVERAGE_REPORT=codecovio
COVERAGE_REPORT_VIEW=codecovio
;;
genhtml)
COVERAGE_REPORT_VIEW=genhtml
;;
ci)
COVERAGE_REPORT_VIEW=ci
;;
esac
done

set -o xtrace
mkdir -p $LCOVDIR

# Generate initial zero-coverage data. This adds files that were otherwise not run to the report
lcov -c --initial --rc lcov_branch_coverage=1 --directory build --output-file ${LCOVDIR}/initialcoverage.info
# Generate initial zero-coverage data.
# This adds files that were otherwise not run to the report
lcov --capture --initial \
--directory build \
--output-file ${LCOVDIR}/initial_coverage.info \
--rc lcov_branch_coverage=1

# Capture executed code data.
lcov -c --rc lcov_branch_coverage=1 --directory build --output-file ${LCOVDIR}/testcoverage.info
lcov --capture \
--directory build \
--output-file ${LCOVDIR}/test_coverage.info \
--rc lcov_branch_coverage=1

# Combine the initial zero-coverage report with the executed lines report
lcov -a ${LCOVDIR}/initialcoverage.info -a ${LCOVDIR}/testcoverage.info --rc lcov_branch_coverage=1 --o ${LCOVDIR}/fullcoverage.info
# Combine the initial zero-coverage report with the executed lines report.
lcov \
--add-tracefile ${LCOVDIR}/initial_coverage.info \
--add-tracefile ${LCOVDIR}/test_coverage.info \
--output-file ${LCOVDIR}/full_coverage.info \
--rc lcov_branch_coverage=1

# Only include files that are within this workspace (eg filter out stdio.h etc)
lcov -e ${LCOVDIR}/fullcoverage.info "${PWD}/*" --rc lcov_branch_coverage=1 --output-file ${LCOVDIR}/workspacecoverage.info
# Only include files that are within this workspace.
# (eg filter out stdio.h etc)
lcov \
--extract ${LCOVDIR}/full_coverage.info \
"${PWD}/*" \
--output-file ${LCOVDIR}/workspace_coverage.info \
--rc lcov_branch_coverage=1

# Remove files in the build subdirectory because they are generated files (like messages, services, etc)
lcov -r ${LCOVDIR}/workspacecoverage.info "${PWD}/build/*" --rc lcov_branch_coverage=1 --output-file ${LCOVDIR}/projectcoverage.info
# Remove files in the build subdirectory.
# Those are generated files (like messages, services, etc)
lcov \
--remove ${LCOVDIR}/workspace_coverage.info \
"${PWD}/build/*" \
--output-file ${LCOVDIR}/project_coverage.info \
--rc lcov_branch_coverage=1

if [ $COVERAGE_REPORT = codecovio ]; then
bash <(curl -s https://codecov.io/bash) -f ${LCOVDIR}/projectcoverage.info
else
genhtml ${LCOVDIR}/projectcoverage.info --output-directory ${LCOVDIR}/html --branch-coverage -p ${PWD}
fi
if [ $COVERAGE_REPORT_VIEW = codecovio ]; then
bash <(curl -s https://codecov.io/bash) \
-f ${LCOVDIR}/project_coverage.info \
-R src/navigation2
elif [ $COVERAGE_REPORT_VIEW = genhtml ]; then
genhtml ${LCOVDIR}/project_coverage.info \
--output-directory ${LCOVDIR}/html \
--branch-coverage -p ${PWD}
fi

0 comments on commit 5c0dfbe

Please sign in to comment.