Skip to content

Commit

Permalink
(CI)(test) extend to handle ROS2
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh committed Sep 5, 2023
1 parent ce6f1cb commit b66ddff
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions ci/test-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ do
done

echo -e "\e[35m\e[1mPACKAGE = ${PACKAGE}\e[0m"
ROS_VERSION=$(docker exec -t tue-env bash -c 'source ~/.bashrc; echo "${ROS_VERSION}"' | tr -d '\r')
echo -e "\e[35m\e[1mROS_VERSION = ${ROS_VERSION}\e[0m"

# If packages is non-zero, this is a multi-package repo. In multi-package repo, check if this package needs CI.
# If a single-package repo, CI is always needed.
Expand All @@ -43,10 +45,26 @@ then
exit 0
fi

# Build test targets
echo -e "\e[35m\e[1mBuild test targets of this package (catkin build --this --no-deps -DCATKIN_ENABLE_TESTING=ON)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "$TUE_SYSTEM_DIR"/src/"$PACKAGE" && catkin build --this --no-status --no-deps -DCATKIN_ENABLE_TESTING=ON'
# Use docker environment variables in all exec commands instead of script variables
if [[ "${ROS_VERSION}" == 1 ]]
then
# Build test targets
echo -e "\e[35m\e[1mBuild test targets of this package (catkin build --this --no-deps -DCATKIN_ENABLE_TESTING=ON)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}"/src/"${PACKAGE}" && catkin build --this --no-status --no-deps -DCATKIN_ENABLE_TESTING=ON'

# Run unit tests
echo -e "\e[35m\e[1mRun tests on this package (catkin test --this --no-deps -DCATKIN_ENABLE_TESTING=ON)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}"/src/"${PACKAGE}" && catkin test --this --no-status --no-deps -DCATKIN_ENABLE_TESTING=ON'
else
# Build test targets
echo -e "\e[35m\e[1mBuild test targets of this package (colcon build --packages-select ${PACKAGE} --mixin rel-with-deb-info build-testing-on)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}" && colcon build --packages-select "${PACKAGE}" --mixin rel-with-deb-info build-testing-on'

# Run unit tests
echo -e "\e[35m\e[1mRun tests on this package (catkin test --this --no-deps -DCATKIN_ENABLE_TESTING=ON)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "$TUE_SYSTEM_DIR"/src/"$PACKAGE" && catkin test --this --no-status --no-deps -DCATKIN_ENABLE_TESTING=ON'
# Run unit tests
echo -e "\e[35m\e[1mRun tests on this package (colcon test --packages-select ${PACKAGE})\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}" && colcon test --packages-select "${PACKAGE}"'

# Check test results
echo -e "\e[35m\e[1mCheck test results (colcon test-result --verbose)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}" && colcon test-result --verbose'
fi

0 comments on commit b66ddff

Please sign in to comment.