diff --git a/ci/test-package.sh b/ci/test-package.sh index 696816c43..06f2ff067 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' -# 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