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

Add humble to Linux CI #98

Merged
46 changes: 32 additions & 14 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,64 @@ on:

jobs:
build-linux:
runs-on: ubuntu-20.04
strategy:
matrix:
ros_distribution:
- foxy
- humble
include:
# Foxy Fitzroy (June 2020 - May 2023)
- os: ubuntu-20.04
test_target_framework: net6.0
ros_distribution: foxy
ros_version: 2
# Humble Hawksbill (May 2022 - May 2027)
- os: ubuntu-22.04
test_target_framework: net6.0
ros_distribution: humble
ros_version: 2

runs-on: ${{ matrix.os }}
env:
RCLDOTNET_TEST_TARGET_FRAMEWORK: ${{ matrix.test_target_framework }}

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

# https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-ubuntu-1804
- name: Install .NET SDK v2.1
# https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#supported-distributions
- name: Install .NET SDK v6.0
if: matrix.os == 'ubuntu-20.04'
run: |
wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install -y apt-transport-https
rm packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y dotnet-sdk-2.1
sudo apt-get install -y dotnet-sdk-6.0

- name: Setup ROS2
uses: ros-tooling/setup-ros@v0.2
uses: ros-tooling/setup-ros@v0.6
with:
required-ros-distributions: foxy
required-ros-distributions: ${{ matrix.ros_distribution }}

- name: Configure ros2_dotnet workspace
run: |
mkdir -p ~/ros2_dotnet_ws/src
cd ~/ros2_dotnet_ws
cp ${{github.workspace}}/ros2_dotnet.repos .
vcs import src < ros2_dotnet.repos
cp ${{github.workspace}}/ros2_dotnet_${{ matrix.ros_distribution }}.repos .
vcs import src < ros2_dotnet_${{ matrix.ros_distribution }}.repos
rm -rf src/ros2_dotnet/ros2_dotnet
cp -r ${{github.workspace}} src/ros2_dotnet/ros2_dotnet
vcs branch

- name: Build ros2_dotnet source
run: |
source /opt/ros/foxy/setup.bash
source /opt/ros/${{ matrix.ros_distribution }}/setup.bash
cd ~/ros2_dotnet_ws
colcon build --event-handlers console_cohesion+ console_package_list+

- name: Run tests
run: |
source /opt/ros/foxy/setup.bash
source /opt/ros/${{ matrix.ros_distribution }}/setup.bash
cd ~/ros2_dotnet_ws
colcon test --event-handlers console_cohesion+ --return-code-on-test-failure --packages-select rcldotnet
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
ROS2 for .NET
=============

Build status
------------

| Target | Status |
|----------|--------|
| **Universal Windows Platform (x86/x64)** | ![Build (UWP)](https://github.com/ros2-dotnet/ros2_dotnet/workflows/Build%20(UWP)/badge.svg) |
| **Windows Desktop (x64)** | ![Build (Desktop)](https://github.com/ros2-dotnet/ros2_dotnet/workflows/Build%20(Desktop)/badge.svg) |
| **Linux** | ![Build (Desktop)](https://github.com/ros2-dotnet/ros2_dotnet/workflows/Build%20(Linux)/badge.svg) |
| **Linux** | [![Build (Linux)](https://github.com/ros2-dotnet/ros2_dotnet/actions/workflows/build_linux.yml/badge.svg)](https://github.com/ros2-dotnet/ros2_dotnet/actions/workflows/build_linux.yml) |
| **Windows Desktop** | [![Build (Desktop)](https://github.com/ros2-dotnet/ros2_dotnet/actions/workflows/build_desktop.yml/badge.svg)](https://github.com/ros2-dotnet/ros2_dotnet/actions/workflows/build_desktop.yml) |

_Windows UWP CI Builds are currently disabled, see [this issue](https://github.com/ros2-dotnet/ros2_dotnet/issues/92) for more information._

Introduction
------------
Expand Down Expand Up @@ -47,12 +45,12 @@ see the relevant section below): https://github.com/ros2/ros2/wiki/Installation#

Next make sure you've either installed .Net Core (preferred)
https://www.microsoft.com/net/learn/get-started or Mono
https://www.mono-project.com/. (**NOTE**: For building unit tests, .NET 2.1 is
https://www.mono-project.com/. (**NOTE**: For building unit tests, .NET 6 is
required).

For running on Linux or Windows Desktop, one can build `ros2_dotnet` (along with
all desired packages containing interface definitions) as an overlay on top
of an existing ROS2 installation. The `ros2_dotnet.repos` contains all
of an existing ROS2 installation. The `ros2_dotnet_foxy.repos` contains all
necessary repositories to build the core `ros2_dotnet` project along with all
standard ROS2 interface packages. If you are using other packages which provide
interface definitions, those must also be included in the `ros2_dotnet` workspace
Expand All @@ -65,7 +63,7 @@ core of ROS2 must be compiled for UWP compatibility.
Windows (Desktop)
-----------------
Assuming you've installed ROS2 (pre-built binary packages) to the directory
c:\dev\ros2_eloquent per the official [installation instructions](https://index.ros.org/doc/ros2/Installation/Eloquent/Windows-Install-Binary/),
c:\dev\ros2_foxy per the official [installation instructions](https://index.ros.org/doc/ros2/Installation/Foxy/Windows-Install-Binary/),
run the following from an Administrator Visual Studio 2019 Developer Command
Prompt:

Expand All @@ -76,25 +74,25 @@ This is done for you below in the line preceding `colcon build`. This step
can/should be omitted if building on top of a built-from-source ROS2 workspace)

```
call \dev\ros2_eloquent\local_setup.bat
call \dev\ros2_foxy\local_setup.bat
md \dev\ros2_dotnet_ws\src
cd \dev\ros2_dotnet_ws
curl -sk https://raw.githubusercontent.com/ros2-dotnet/ros2_dotnet/master/ros2_dotnet.repos -o ros2_dotnet.repos
vcs import \dev\ros2_dotnet_ws\src < ros2_dotnet.repos
git clone --branch eloquent https://github.com/ros2/rosidl src\ros2\rosidl
curl -sk https://raw.githubusercontent.com/ros2-dotnet/ros2_dotnet/master/ros2_dotnet_foxy.repos -o ros2_dotnet_foxy.repos
vcs import \dev\ros2_dotnet_ws\src < ros2_dotnet_foxy.repos
git clone --branch foxy https://github.com/ros2/rosidl src\ros2\rosidl
colcon build --merge-install
```


Linux
-----
Assuming ROS2 eloquent installed to the standard location, run the following commands:
Assuming ROS2 foxy installed to the standard location, run the following commands:
```
source /opt/ros/eloquent/setup.bash
source /opt/ros/foxy/setup.bash
mkdir -p ~/ros2_dotnet_ws/src
cd ~/ros2_dotnet_ws
wget https://raw.githubusercontent.com/ros2-dotnet/ros2_dotnet/master/ros2_dotnet.repos
vcs import ~/ros2_dotnet_ws/src < ros2_dotnet.repos
wget https://raw.githubusercontent.com/ros2-dotnet/ros2_dotnet/master/ros2_dotnet_foxy.repos
vcs import ~/ros2_dotnet_ws/src < ros2_dotnet_foxy.repos
colcon build
```

Expand Down
10 changes: 10 additions & 0 deletions rcldotnet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,17 @@ if(BUILD_TESTING)
${builtin_interfaces_ASSEMBLIES_DLL}
)

# Used by CI to test the different target frameworks in a matrix.
if(DEFINED ENV{RCLDOTNET_TEST_TARGET_FRAMEWORK})
set(RCLDOTNET_TEST_TARGET_FRAMEWORK $ENV{RCLDOTNET_TEST_TARGET_FRAMEWORK})
else()
set(RCLDOTNET_TEST_TARGET_FRAMEWORK "net6.0")
endif()

add_dotnet_test(test_messages
TARGET_FRAMEWORK
${RCLDOTNET_TEST_TARGET_FRAMEWORK}
SOURCES
${CS_SOURCES}
test/test_messages.cs
INCLUDE_DLLS
Expand Down
14 changes: 7 additions & 7 deletions rcldotnet_common/DllLoadUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public class DllLoadUtilsFactory {
[DllImport ("kernel32.dll", EntryPoint = "FreeLibrary", SetLastError = true, ExactSpelling = true)]
private static extern int FreeLibraryDesktop (IntPtr handle);

[DllImport ("libdl.so", EntryPoint = "dlopen")]
[DllImport ("libdl.so.2", EntryPoint = "dlopen")]
private static extern IntPtr dlopen_unix (String fileName, int flags);

[DllImport ("libdl.so", EntryPoint = "dlclose")]
[DllImport ("libdl.so.2", EntryPoint = "dlclose")]
private static extern int dlclose_unix (IntPtr handle);

[DllImport ("libdl.dylib", EntryPoint = "dlopen")]
Expand Down Expand Up @@ -106,7 +106,7 @@ private static bool IsWindowsDesktop () {

private static bool IsUnix () {
try {
IntPtr ptr = dlopen_unix ("libdl.so", RTLD_NOW);
IntPtr ptr = dlopen_unix ("libdl.so.2", RTLD_NOW);
dlclose_unix (ptr);
return true;
} catch (TypeLoadException) {
Expand Down Expand Up @@ -205,16 +205,16 @@ IntPtr DllLoadUtils.LoadLibrary (string fileName) {

internal class DllLoadUtilsUnix : DllLoadUtils {

[DllImport ("libdl.so", ExactSpelling = true)]
[DllImport ("libdl.so.2", ExactSpelling = true)]
private static extern IntPtr dlopen (String fileName, int flags);

[DllImport ("libdl.so", ExactSpelling = true)]
[DllImport ("libdl.so.2", ExactSpelling = true)]
private static extern IntPtr dlsym (IntPtr handle, String symbol);

[DllImport ("libdl.so", ExactSpelling = true)]
[DllImport ("libdl.so.2", ExactSpelling = true)]
private static extern int dlclose (IntPtr handle);

[DllImport ("libdl.so", ExactSpelling = true)]
[DllImport ("libdl.so.2", ExactSpelling = true)]
private static extern IntPtr dlerror ();

const int RTLD_NOW = 2;
Expand Down
File renamed without changes.
33 changes: 33 additions & 0 deletions ros2_dotnet_humble.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repositories:
ament_dotnet/ament_cmake_export_assemblies:
type: git
url: https://github.com/esteve/ament_cmake_export_assemblies.git
version: master
ros2/common_interfaces:
type: git
url: https://github.com/ros2/common_interfaces.git
version: humble
ros2/rcl_interfaces:
type: git
url: https://github.com/ros2/rcl_interfaces.git
version: humble
ros2/rosidl_defaults:
type: git
url: https://github.com/ros2/rosidl_defaults.git
version: humble
ros2/test_interface_files:
type: git
url: https://github.com/ros2/test_interface_files.git
version: humble
ros2/unique_identifier_msgs:
type: git
url: https://github.com/ros2/unique_identifier_msgs.git
version: humble
ros2_dotnet/dotnet_cmake_module:
type: git
url: https://github.com/ros2-dotnet/dotnet_cmake_module.git
version: master
ros2_dotnet/ros2_dotnet:
type: git
url: https://github.com/ros2-dotnet/ros2_dotnet.git
version: master