Skip to content

Commit

Permalink
Merge pull request #9 from usdot-fhwa-stol/release/RX7
Browse files Browse the repository at this point in the history
Release/rx7
  • Loading branch information
darrelld05 authored Jul 17, 2019
2 parents 47e83f9 + a9dc407 commit 6983419
Show file tree
Hide file tree
Showing 21 changed files with 669 additions and 77 deletions.
97 changes: 97 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
version: 2

# Copyright (C) 2018-2019 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#

# Configuration file for Circle CI
# CI will report failure if any executed command returns and error status
# Operations performed are as follows
# Build source code
# Run unit tests for C++ and Java
# Run static code analyzer for SourceCloud
# Upload test results
# Every run command should start with source ${INIT_ENV} to ensure all default dependancies are available
jobs:
build:
# Pull docker image from docker hub
# XTERM used for better catkin_make output
docker:
- image: usdotfhwastol/carma-base-ci:2.8.4
user: carma
environment:
TERM: xterm
INIT_ENV: /home/carma/.base-image/init-env.sh
# Set working directory
working_directory: "/opt/carma/"
# Pull code and execute tests
# Name of each run command defines purpose use
steps:
- run:
name: Create src folder
command: |
source ${INIT_ENV}
mkdir src
cd src
mkdir CARMAAvtVimbaDriver
mkdir CARMAMsgs
# Checkout PR branch
- checkout:
path: src/CARMAAvtVimbaDriver
- run:
name: Pull CARMAMsgs
command: |
source ${INIT_ENV}
git clone -b develop --depth 1 git@github.com:usdot-fhwa-stol/CARMAMsgs.git src/CARMAMsgs
- run:
name: Build Driver
command: |
source ${INIT_ENV}
build-wrapper-linux-x86-64 --out-dir /opt/carma/bw-output bash make_with_coverage.bash -m -e /opt/carma/ -o ./coverage_reports/gcov
- run:
name: Run C++ Tests
command: |
source ${INIT_ENV}
bash make_with_coverage.bash -t -e /opt/carma/ -o ./coverage_reports/gcov
# Run SonarCloud analysis
# PR Branchs and number extracted from Circle variables and github api
# Circle CI seems to make a change to the base branch, so we must fetch --force to ensure correct git file change stats
# SONAR_SCANNER_TOKEN MUST be secured as an environment variable in Circle CI NOT in this file.
# The following sonar settings MUST be set in SonarCloud UI NOT in this file
# sonar.pullrequest.provider
# sonar.pullrequest.github.endpoint
# sonar.pullrequest.github.token.secured
# sonar.pullrequest.github.repository
# Use -X on sonar-scanner to enable debug output
- run:
name: Run Sonar Scanner
command: |
source ${INIT_ENV}
if [ -z "${CIRCLE_PULL_REQUEST}" ]; then
echo "Non-PR Build Detected. Running analysis on ${CIRCLE_BRANCH}"
cd src/CARMAAvtVimbaDriver
sonar-scanner -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN}
exit 0;
fi
echo "PR branch ${CIRCLE_BRANCH}"
echo "Repo name ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
echo "URL ${CIRCLE_PULL_REQUEST}"
export PR_NUM=`echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f7`
echo "PR number ${PR_NUM}"
export BASE_BRANCH_URL="https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${PR_NUM}"
export TARGET_BRANCH=$(curl "$BASE_BRANCH_URL" | jq '.base.ref' | tr -d '"')
echo "Target Branch = ${TARGET_BRANCH}"
cd src/CARMAAvtVimbaDriver
git fetch --force origin ${TARGET_BRANCH}:${TARGET_BRANCH}
sonar-scanner -Dproject.settings=.sonarqube/sonar-scanner.properties -Dsonar.login=${SONAR_SCANNER_TOKEN} -Dsonar.pullrequest.base=${TARGET_BRANCH} -Dsonar.pullrequest.branch=${CIRCLE_BRANCH} -Dsonar.pullrequest.key=${PR_NUM}
27 changes: 27 additions & 0 deletions .sonarqube/sonar-scanner.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (C) 2018-2019 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

# Configuration file for Sonar Scanner used for CI

sonar.projectKey=usdot-fhwa-stol_CARMAAvtVimbaDriver
sonar.organization=usdot-fhwa-stol
sonar.cfamily.build-wrapper-output=/opt/carma/bw-output
sonar.host.url=https://sonarcloud.io
sonar.sources=src/
sonar.cfamily.gcov.reportsPath=/opt/carma/coverage_reports/gcov
sonar.tests=test/
# Set Git as SCM sensor
sonar.scm.disabled=false
sonar.scm.enabled=true
sonar.scm.provider=git
25 changes: 20 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ project(avt_vimba_camera)

find_package(catkin REQUIRED COMPONENTS
#libvimba
cav_msgs
camera_info_manager
diagnostic_updater
dynamic_reconfigure
Expand All @@ -28,8 +29,9 @@ generate_dynamic_reconfigure_options(
)

catkin_package(
#LIBRARIES ${PROJECT_NAME}
INCLUDE_DIRS include
CATKIN_DEPENDS camera_info_manager diagnostic_updater dynamic_reconfigure image_geometry image_transport roscpp sensor_msgs std_msgs polled_camera
CATKIN_DEPENDS camera_info_manager diagnostic_updater dynamic_reconfigure image_geometry image_transport roscpp sensor_msgs std_msgs polled_camera cav_msgs
)

###########
Expand Down Expand Up @@ -58,6 +60,7 @@ function(add_dependencies_and_linkings arg)
add_dependencies(${arg}
${PROJECT_NAME}_gencfg
#${libvimba_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
)

if("${ARCH}" STREQUAL i386)
Expand Down Expand Up @@ -94,7 +97,8 @@ add_executable(mono_camera_node
src/mono_camera.cpp
src/avt_vimba_camera.cpp
src/frame_observer.cpp
)
src/status_camera.cpp
)

add_dependencies_and_linkings(mono_camera_node)

Expand All @@ -103,23 +107,29 @@ add_executable(stereo_camera_node
src/stereo_camera.cpp
src/avt_vimba_camera.cpp
src/frame_observer.cpp
)
)

add_dependencies_and_linkings(stereo_camera_node)

add_executable(sync_node
src/nodes/sync_node.cpp
src/sync.cpp
)
)

add_dependencies_and_linkings(sync_node)

add_library(avt_vimba_camera_lib
src/status_camera.cpp
)
add_dependencies(avt_vimba_camera_lib ${catkin_EXPORTED_TARGETS})

add_library(avt_camera_nodelets
src/nodes/mono_camera_nodelet.cpp
src/nodes/stereo_camera_nodelet.cpp
src/stereo_camera.cpp
src/avt_vimba_camera.cpp
src/frame_observer.cpp)

add_dependencies_and_linkings(avt_camera_nodelets)

#############
Expand All @@ -143,7 +153,7 @@ install(DIRECTORY include
## Mark other files for installation (e.g. launch and bag files, etc.)
install(FILES
plugins.xml
launch/mono_camera.launch
#launch/mono_camera.launch
launch/mono_camera_nodelet.launch
launch/stereo_camera_one_node.launch
launch/stereo_camera_two_nodes.launch
Expand Down Expand Up @@ -179,3 +189,8 @@ elseif("${ARCH}" STREQUAL armv8)
DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)
endif()
#Test
## gtest C++ Framework
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
catkin_add_gtest(${PROJECT_NAME}-test test/status_mako_camera_test.cpp)
target_link_libraries(${PROJECT_NAME}-test avt_vimba_camera_lib ${catkin_LIBRARIES})
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright (C) 2018-2019 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

FROM usdotfhwastol/carma-base:2.8.3 as setup

RUN mkdir ~/src
COPY --chown=carma . /home/carma/src/
RUN ~/src/docker/checkout.sh
RUN ~/src/docker/install.sh

FROM usdotfhwastol/carma-base:2.8.3

ARG BUILD_DATE="NULL"
ARG VERSION="NULL"
ARG VCS_REF="NULL"

LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.name="carma-avt-vimba-driver"
LABEL org.label-schema.description="AVT VIMBA vision driver + driver wrapper for the CARMA Platform"
LABEL org.label-schema.vendor="Leidos"
LABEL org.label-schema.version=${VERSION}
LABEL org.label-schema.url="https://highways.dot.gov/research/research-programs/operations/CARMA"
LABEL org.label-schema.vcs-url="https://github.com/usdot-fhwa-stol/CARMAAvtVimbaDriver/"
LABEL org.label-schema.vcs-ref=${VCS_REF}
LABEL org.label-schema.build-date=${BUILD_DATE}

COPY --from=setup /home/carma/install /opt/carma/app/bin
RUN sudo chmod -R +x /opt/carma/app/bin

CMD [ "wait-for-it.sh", "localhost:11311", "--", "roslaunch", "avt_vimba_camera", "mono_camera.launch", "remap_ns:=/saxton_cav/drivers" ]
80 changes: 80 additions & 0 deletions docker/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

# Copyright (C) 2018-2019 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

USERNAME=usdotfhwastol

cd "$(dirname "$0")"
IMAGE=$(./get-package-name.sh | tr '[:upper:]' '[:lower:]')

echo ""
echo "##### $IMAGE Docker Image Build Script #####"
echo ""

while [[ $# -gt 0 ]]; do
arg="$1"
case $arg in
-v|--version)
COMPONENT_VERSION_STRING="$2"
shift
shift
;;
--system-release)
SYSTEM_RELEASE=true
shift
;;
-p|--push)
PUSH=true
shift
;;
esac
done

if [[ -z "$COMPONENT_VERSION_STRING" ]]; then
COMPONENT_VERSION_STRING=$("./get-component-version.sh")
fi

echo "Building docker image for $IMAGE version: $COMPONENT_VERSION_STRING"
echo "Final image name: $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING"

cd ..
docker build --no-cache -t $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING \
--build-arg VERSION="$COMPONENT_VERSION_STRING" \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` .

TAGS=()
TAGS+=("$USERNAME/$IMAGE:$COMPONENT_VERSION_STRING")

docker tag $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING $USERNAME/$IMAGE:latest
TAGS+=("$USERNAME/$IMAGE:latest")

echo "Tagged $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING as $USERNAME/$IMAGE:latest"

if [ "$SYSTEM_RELEASE" = true ]; then
SYSTEM_VERSION_STRING=$("./get-system-version.sh")
docker tag $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING $USERNAME/$IMAGE:$SYSTEM_VERSION_STRING
echo "Tagged $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING as $USERNAME/$IMAGE:$SYSTEM_VERSION_STRING"
TAGS+=("$USERNAME/$IMAGE:$SYSTEM_VERSION_STRING")
fi

if [ "$PUSH" = true ]; then
for tag in $TAGS; do
docker push "${tag}"
done
fi

echo ""
echo "##### $IMAGE Docker Image Build Done! #####"
21 changes: 21 additions & 0 deletions docker/checkout.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Copyright (C) 2018-2019 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

# CARMA packages checkout script

set -ex

git clone https://github.com/usdot-fhwa-stol/CARMAMsgs.git ~/src/CARMAMsgs
21 changes: 21 additions & 0 deletions docker/get-component-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Copyright (C) 2018-2019 LEIDOS.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

cd "$(dirname "$0")"
cd ..
COMPONENT_TAG_PREFIX="${PWD##*/}"
git describe --all --match="$COMPONENT_TAG_PREFIX*" --always --dirty="-SNAPSHOT" | awk -F "/" '{print $NF}' | sed "s/$COMPONENT_TAG_PREFIX\_//"

Loading

0 comments on commit 6983419

Please sign in to comment.