From b321f9c3a20b89b8de378199854ddb45c06de28f Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Tue, 5 Sep 2023 09:47:31 +0200 Subject: [PATCH] (CI)(test) extend to handle ROS2 --- ci/test-package.sh | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/ci/test-package.sh b/ci/test-package.sh index 696816c43..1e02a40fc 100755 --- a/ci/test-package.sh +++ b/ci/test-package.sh @@ -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. @@ -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 --event-handlers desktop_notification- status- terminal_title-' -# 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}" --event-handlers desktop_notification- status- terminal_title- console_cohesion+' + + # 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