Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare CI for ROS2 #681

Merged
merged 9 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.10.5
1.11.0
28 changes: 26 additions & 2 deletions ci/build-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 @@ -45,5 +47,27 @@ fi

# Use docker environment variables in all exec commands instead of script variables
# Compile the package
echo -e "\e[35m\e[1mCompile the package (catkin build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCATKIN_ENABLE_TESTING=OFF)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "$TUE_SYSTEM_DIR"/src/"$PACKAGE" && catkin build --this --no-status -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCATKIN_ENABLE_TESTING=OFF'
if [[ "${ROS_VERSION}" == 1 ]]
then
echo -e "\e[35m\e[1mCompile the package (catkin build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCATKIN_ENABLE_TESTING=OFF)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}"/src/"${PACKAGE}" && catkin build --this --no-status -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCATKIN_ENABLE_TESTING=OFF'
else
echo -e "\e[35m\e[1mCheck for default mixin repo (colcon mixin list)\e[0m"
MIXIN_REPOS=$(docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}" && colcon mixin list | grep -v "^- "' | tr -d '\r' | awk -F ": " '{print $1}')
if ! echo -e "${MIXIN_REPOS}" | grep "^default$" -q
then
echo -e "\e[35m\e[1mAdd the default mixin repo (colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}" && colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml'
else
echo -e "\e[35m\e[1mDefault mixin repo already exists\e[0m"
fi

echo -e "\e[35m\e[1mUpdate colcon mixins (colcon mixin update)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}" && colcon mixin update'

echo -e "\e[35m\e[1mDeleting the merged install directory\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}" && rm -rf install'

echo -e "\e[35m\e[1mCompile the package (colcon build --mixin rel-with-deb-info build-testing-off)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}" && colcon build --packages-up-to "${PACKAGE}" --mixin rel-with-deb-info build-testing-off --event-handlers desktop_notification- status- terminal_title-'
fi
9 changes: 9 additions & 0 deletions ci/main/action.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
name: 'TUe CI'
description: 'Install, build and test package in tue-env environment'
inputs:
image:
default: 'ghcr.io/tue-robotics/tue-env-ros-noetic'
description: 'Container Image to be used'
required: false
type: string
package:
description: 'Package name'
required: true
type: string
ssh-key:
description: 'SSH key used during install process'
required: false
type: string
ssh-known-hosts:
description: 'Hosts to be added known_hosts'
required: false
type: string
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -69,6 +77,7 @@ runs:
done
fi
${{ github.action_path }}/../install-package.sh \
--image=${{ inputs.image }} \
--package=${{ inputs.package }} \
--branch="${BRANCH}" \
--commit="${GITHUB_SHA}" \
Expand Down
2 changes: 2 additions & 0 deletions ci/modified-packages/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ inputs:
commit-range:
description: 'Range of commits to determine modified files'
required: true
type: string
ignored-packages:
description: 'Packages to be ignored at all times'
required: false
type: string
outputs:
packages:
description: 'Modified packages'
Expand Down
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 --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} --executor sequential)\e[0m"
docker exec -t tue-env bash -c 'source ~/.bashrc; cd "${TUE_SYSTEM_DIR}" && colcon test --packages-select "${PACKAGE}" --executor sequential --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
4 changes: 2 additions & 2 deletions installer/tue-install-impl.bash
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ function _try_branch_git
local repo branch _checkout_error_code
repo="$1"
branch="$2"
tue-install-debug "git -C $repo checkout $branch --"
_try_branch_res=$(git -C "$repo" checkout "$branch" -- 2>&1) # _try_branch_res is a "global" variable from tue-install-git
tue-install-debug "git -C ${repo} checkout ${branch} --recurse-submodules --"
_try_branch_res=$(git -C "${repo}" checkout "${branch}" --recurse-submodules -- 2>&1) # _try_branch_res is a "global" variable from tue-install-git
MatthijsBurgh marked this conversation as resolved.
Show resolved Hide resolved
_checkout_error_code=$?
tue-install-debug "_try_branch_res(${_checkout_error_code}): ${_try_branch_res}"

Expand Down
2 changes: 1 addition & 1 deletion installer/tue-install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ then
then
echo -en "Already on branch ${branch}"
else
git -C "${TUE_ENV_TARGETS_DIR}" checkout "${branch}" -- 2>&1
git -C "${TUE_ENV_TARGETS_DIR}" checkout "${branch}" --recurse-submodules -- 2>&1
git -C "${TUE_ENV_TARGETS_DIR}" submodule sync --recursive 2>&1
git -C "${TUE_ENV_TARGETS_DIR}" submodule update --init --recursive 2>&1
echo -e "Switched to branch ${branch}"
Expand Down