Skip to content
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
27 changes: 27 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ci
on:
pull_request:
push:
branches:
- main

permissions:
contents: read
packages: read
issues: write # posting and hiding bot comments
pull-requests: write # posting and hiding bot comments

jobs:
test:
strategy:
fail-fast: false
matrix:
ALPINE_VERSION: ["3.20"]
ROS_DISTRO: ["humble", "jazzy"]
uses: alpine-ros/alpine-ros-ci-workflows/.github/workflows/ros2.yaml@support-ros2
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repository has a mutual dependence with alpine-ros-ci-workflows, so I want to merge this PR with specifing support-ros2 branch for now.

with:
enable-bot-comment: true
alpine-version: ${{ matrix.ALPINE_VERSION }}
ros-distro: ${{ matrix.ROS_DISTRO }}
secrets:
bot-comment-token: ${{ secrets.GITHUB_TOKEN }}
30 changes: 30 additions & 0 deletions sample_ros2_pkg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.8)
project(sample_ros2_pkg)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()

find_package(ament_cmake_gtest REQUIRED)
ament_add_gtest(test_sample
test/src/test_sample.cpp
src/sample.cpp)
target_include_directories(test_sample PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
endif()

install(
DIRECTORY include
DESTINATION include/${PROJECT_NAME}
)

ament_package()
4 changes: 4 additions & 0 deletions sample_ros2_pkg/include/sample_ros2_pkg/sample.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

int sum(const int a, const int b);
int mul(const int a, const int b);
21 changes: 21 additions & 0 deletions sample_ros2_pkg/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<?xml-model
href="http://download.ros.org/schema/package_format3.xsd"
schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>sample_ros2_pkg</name>
<version>0.0.0</version>
<description>Sample ROS 2 package for testing</description>
<maintainer email="17446116+Taka-Kazu@users.noreply.github.com">Kazuki Takahashi</maintainer>
<license>N/A</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_cmake_gtest</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
13 changes: 13 additions & 0 deletions sample_ros2_pkg/src/sample.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
int sum(const int a, const int b)
{
// covered
const int c = a + b;
return c;
}

int mul(const int a, const int b)
{
// not covered
const int c = a * b;
return c;
}
15 changes: 15 additions & 0 deletions sample_ros2_pkg/test/src/test_sample.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <gtest/gtest.h>

#include <sample_ros2_pkg/sample.h>

TEST(Sum, Sum)
{
ASSERT_EQ(sum(1, 2), 3);
}

int main(int argc, char ** argv)
{
testing::InitGoogleTest(&argc, argv);

return RUN_ALL_TESTS();
}
Loading