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

Implement automatic Tests #52

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
67 changes: 67 additions & 0 deletions .github/workflows/test_ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Test on Ubuntu
on:
workflow_dispatch:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test_ubuntu:
strategy:
matrix:
os: [ubuntu-22.04]
ros-distribution: [humble]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout source
uses: actions/checkout@v3

- name: Install .NET SDK 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "6"

- name: Update apt sources
run: sudo apt update

- name: Set locale
run: |
sudo apt install -y locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

- name: Setup ROS2 apt sources
run: |
sudo apt install -y software-properties-common curl
sudo add-apt-repository universe
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update

- name: Setup ROS2
env:
LANG: en_US.UTF-8
run: |
sudo apt install -y \
ros-${{ matrix.ros-distribution }}-ros-base ros-dev-tools ros-${{ matrix.ros-distribution }}-test-msgs \
ros-${{ matrix.ros-distribution }}-fastrtps ros-${{ matrix.ros-distribution }}-rmw-fastrtps-cpp \
ros-${{ matrix.ros-distribution }}-cyclonedds ros-${{ matrix.ros-distribution }}-rmw-cyclonedds-cpp \
python3-vcstool

- name: Invoke build script
env:
LANG: en_US.UTF-8
run: |
source /opt/ros/humble/setup.bash
./get_repos.sh
./build.sh --with-tests

- name: Invoke test script
env:
LANG: en_US.UTF-8
run: |
source /opt/ros/humble/setup.bash
./test.sh
85 changes: 85 additions & 0 deletions .github/workflows/test_windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Test on Windows
on:
workflow_dispatch:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test_windows:
strategy:
matrix:
os: [windows-2019]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout source
uses: actions/checkout@v3

- name: Install .NET SDK 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: "6"

# setup with colcon fails
# (probably since it is already installed in the toolscache)
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.8"

- name: Install dependencies
shell: pwsh
run: | # junction is required since Python path is hardcoded
New-Item -ItemType Junction -Path "C:\Python38" -Target $Env:Python3_ROOT_DIR
choco install --no-progress -y vcredist2013 vcredist140 openssl cmake wget

- name: Install ROS2 dependencies
run: |
wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/asio.1.12.1.nupkg
wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/bullet.3.17.nupkg
wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/cunit.2.1.3.nupkg
wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/eigen.3.3.4.nupkg
wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/tinyxml-usestl.2.6.2.nupkg
wget.exe --quiet https://github.com/ros2/choco-packages/releases/download/2022-03-15/tinyxml2.6.0.0.nupkg
choco install --no-progress -y --source . asio bullet cunit eigen tinyxml-usestl tinyxml2

- name: Install Python Packages
run: |
python -m pip install -U pip setuptools==59.6.0
python -m pip install -U catkin_pkg cryptography empy importlib-metadata lark==1.1.1 lxml matplotlib netifaces numpy opencv-python PyQt5 pillow psutil pycairo pydot pyparsing==2.4.7 pyyaml rosdistro rosdep vcstool colcon-common-extensions

- name: Setup ROS2
shell: pwsh
run: |
wget.exe --quiet https://github.com/ros2/ros2/releases/download/release-humble-20230213/ros2-humble-20230127-windows-release-amd64.zip
Expand-Archive -Path ros2-humble-20230127-windows-release-amd64.zip -DestinationPath C:\dev

- name: Invoke Windows build
shell: pwsh
run: | # prevent cmake from searching for higher Python versions in the toolscache
. C:/dev/ros2-windows/setup.ps1
./get_repos.ps1
colcon build `
--merge-install `
--event-handlers console_direct+ `
--cmake-args `
-DCMAKE_BUILD_TYPE=Release `
-DBUILD_TESTING=1 `
-DPython3_ROOT_DIR=C:/Python38 `
-DPython3_FIND_STRATEGY=LOCATION `
-DPython3_FIND_REGISTRY=NEVER `
--no-warn-unused-cli `
--packages-up-to ros2cs_tests
env:
VisualStudioVersion: "16.0"

- name: Invoke Windows test script
shell: pwsh
run: |
. C:/dev/ros2-windows/setup.ps1
./test.ps1
env:
VisualStudioVersion: "16.0"
4 changes: 2 additions & 2 deletions README-UBUNTU.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ sudo apt install patchelf
- Clone this project
- Source your ROS2 installation
```bash
# Change foxy to whatever version you are using
source /opt/ros/foxy/setup.bash
# Change humble to whatever version you are using
source /opt/ros/humble/setup.bash
```
- Navigate to the top project folder and pull required repositories
```bash
Expand Down
4 changes: 2 additions & 2 deletions README-WINDOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Prerequisites

* ROS2 installed on the system (additionally you should go to [Building ROS2 section](https://docs.ros.org/en/foxy/Installation/Windows-Development-Setup.html) and check if all `pip` [Install dependencies](https://docs.ros.org/en/foxy/Installation/Windows-Development-Setup.html#install-dependencies) and [Developer tools](https://docs.ros.org/en/foxy/Installation/Windows-Development-Setup.html#install-developer-tools) are installed)
* ROS2 installed on the system (additionally you should go to [Building ROS2 section](https://docs.ros.org/en/humble/Installation/Windows-Development-Setup.html) and check if all [Prerequisites](https://docs.ros.org/en/humble/Installation/Windows-Development-Setup.html#installing-prerequisites) are installed.
* vcstool package - [see here](https://github.com/dirk-thomas/vcstool)
* .NET 6.0 sdk - [see here](https://dotnet.microsoft.com/download/dotnet/6.0)
* For tests only: xUnit testing framework - [see here](https://xunit.net/)
Expand All @@ -24,7 +24,7 @@
### Steps

- Clone this project.
- Source your ROS2 installation (`C:\dev\ros2_foxy\local_setup.ps1`)
- Source your ROS2 installation (`C:\dev\ros2_humble\local_setup.ps1`)
- Navigate to the top project folder and pull required repositories (`get_repos.ps1`)
- You can run script with `--get-custom-messages` argument to fetch extra messages from `custom_messages.repos` file.
- It will use `vcstool` to download required ROS2 packages. By default, this will get repositories as set in `${ROS_DISTRO}`.
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Supported OSes:
- Ubuntu 22.04 (bash)
- Ubuntu 20.04 (bash)
- Windows 10 (powershell)
- Windows 11* (powershel)
- Windows 11* (powershell)

> \* ROS2 Galactic and Humble support only Windows 10 ([ROS 2 Windows system requirements](https://docs.ros.org/en/humble/Installation/Windows-Install-Binary.html#system-requirements)), but it is proven that it also works fine on Windows 11.

Expand All @@ -36,7 +36,7 @@ Supported ROS2 distributions:

### Generating custom messages

After cloning the project and importing .repos, you can simply put your message package next to other packages in the `src/ros2` sub-folder. Then, build your project, and you have all messages generated. You can also modify and use the `custom_message.repos` template to automate the process with the `get_repos` script.
After cloning the project and importing .repos, you can simply put your message package next to other packages in the `src/custom_packages` directory. Then, build your project, and you have all messages generated. You can also modify and use the `custom_messages.repos` template to automate the process with the `get_repos` script.

### Build instructions

Expand All @@ -45,6 +45,12 @@ Please follow the OS-specific instructions for your build:
- [Ubuntu 20.04 Instructions](README-UBUNTU.md)
- [Windows 10 Instructions](README-WINDOWS.md)

## Examples

To built the examples pass the `--with-examples` flag to the OS-specific build script.
After sourcing your ROS2 workspace you can execute examples with `ros2 run ros2cs_examples <example>`.
Example commands are shown in the testing section.

## Testing

Make sure your NuGet repositories can resolve `xUnit` dependency. You can call `dotnet nuget list source` to see your current sources for NuGet packages. Please note that `Microsoft Visual Studio Offline Packages` are usually insufficient. You can fix it by adding `nuget.org` repository: `dotnet nuget add source --name nuget.org https://api.nuget.org/v3/index.json`.
Expand All @@ -59,7 +65,7 @@ Make sure your NuGet repositories can resolve `xUnit` dependency. You can call `
```powershell
test.sp1
```
- Run a manual test with basic listener/publisher examples (you have to source your ROS2 first):
- Run a manual test with basic listener/publisher examples (you have to source your ROS2 first and built with examples):
- ubuntu
```bash
ros2 run ros2cs_examples ros2cs_talker
Expand All @@ -70,7 +76,7 @@ Make sure your NuGet repositories can resolve `xUnit` dependency. You can call `
ros2 run ros2cs_examples ros2cs_talker.exe
ros2 run ros2cs_examples ros2cs_listener.exe
```
- Run a manual performance test (you have to source your ROS2 first):
- Run a manual performance test (you have to source your ROS2 first and built with examples):
- ubuntu
```bash
ros2 run ros2cs_examples ros2cs_performance_talker
Expand Down
23 changes: 21 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,42 @@
build with tests
.PARAMETER standalone
standalone build
.PARAMETER with_examples
build with examples
#>
Param (
[Parameter(Mandatory=$false)][switch]$with_tests=$false,
[Parameter(Mandatory=$false)][switch]$standalone=$false
[Parameter(Mandatory=$false)][switch]$standalone=$false,
[Parameter(Mandatory=$false)][switch]$with_examples=$false
)

$msg="Build started."
$packages=,"ros2cs_core"
$tests_switch=0
if($with_tests) {
$msg+=" (with tests)"
$packages+="ros2cs_tests"
$tests_switch=1
}
$standalone_switch=0
if($standalone) {
$msg+=" (standalone)"
$standalone_switch=1
}
if ($with_examples) {
$msg+=" (with examples)"
$packages+="ros2cs_examples"
}

Write-Host $msg -ForegroundColor Green
colcon build --merge-install --event-handlers console_direct+ --cmake-args -DSTANDALONE_BUILD:int=$standalone_switch -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING:int=$tests_switch --no-warn-unused-cli
&"colcon" build `
--merge-install `
--event-handlers console_direct+ `
--cmake-args `
-DSTANDALONE_BUILD:int=$standalone_switch `
-DCMAKE_BUILD_TYPE=Release `
-DBUILD_TESTING:int=$tests_switch `
--no-warn-unused-cli `
--packages-up-to `
@packages `
@(colcon list --names-only --base-paths src/custom_packages)
23 changes: 16 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@

display_usage() {
echo "Usage: "
echo "build.sh [--with-tests] [--standalone]"
echo "build.sh [--with-tests] [--standalone] [--with-examples]"
echo ""
echo "Options:"
echo "--with-tests - build with tests."
echo "--standalone - standalone version"
echo "--with-examples - built with examples"
}

if [ -z "${ROS_DISTRO}" ]; then
echo "Source your ros2 distro first (foxy, galactic, humble or rolling are supported)"
echo "Source your ros2 distro first (galactic, humble or rolling)"
exit 1
fi

TESTS=0
MSG="Build started."
STANDALONE=OFF
PACKAGES="ros2cs_core"
MSG="Build started."

while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-t|--with-tests)
TESTS=1
PACKAGES="$PACKAGES ros2cs_tests"
MSG="$MSG (with tests)"
shift # past argument
;;
Expand All @@ -31,24 +34,30 @@ while [[ $# -gt 0 ]]; do
MSG="$MSG (standalone)"
shift # past argument
;;
-e|--with-examples)
PACKAGES="$PACKAGES ros2cs_examples"
MSG="$MSG (with examples)"
shift # past argument
;;
-h|--help)
display_usage
exit 0
shift # past argument
;;
*) # unknown option
shift # past argument
;;
esac
done

echo $MSG
colcon build \
echo "$MSG"
colcon list --names-only --base-paths src/custom_packages \
| xargs -P 1 -d "\n" colcon build \
--merge-install \
--event-handlers console_direct+ \
--cmake-args \
-DCMAKE_BUILD_TYPE=Release \
-DSTANDALONE_BUILD=$STANDALONE \
-DBUILD_TESTING=$TESTS \
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-rpath,'\$ORIGIN',-rpath=.,--disable-new-dtags" \
--no-warn-unused-cli
--no-warn-unused-cli \
--packages-up-to $PACKAGES
6 changes: 3 additions & 3 deletions custom_messages.repos
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# NOTE: Use this file if you want to build with custom messages that reside in a separate remote repo.
# NOTE: Use this file if you want to build with custom packages that reside in a separate remote repo.
# NOTE: use the following format

#repositories:
# custom_messages/<package_name>:
# custom_packages/<package_name>:
# type: git
# url: <repo_url>
# version: <repo_branch>
# custom_messages/<package2_name>:
# custom_packages/<package2_name>:
# ...
# ...
Loading