Skip to content

Commit

Permalink
Merge pull request #1 from ika-rwth-aachen/readme
Browse files Browse the repository at this point in the history
Preparation of GitHub Release | Python Templates | Samples | Local/Remote Flag
  • Loading branch information
lreiher authored Nov 7, 2024
2 parents 43036e0 + dc87b99 commit c8f3be7
Show file tree
Hide file tree
Showing 104 changed files with 4,283 additions and 232 deletions.
132 changes: 132 additions & 0 deletions .github/workflows/check-samples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Check samples

# avoiding duplicate jobs on push with open pull_request: https://github.com/orgs/community/discussions/26940#discussioncomment-6656489
on: [push, pull_request]

jobs:

check:
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork)
runs-on: ubuntu-latest
strategy:
matrix:
include:
- package_name: ros2_cpp_pkg
template: ros2_cpp_pkg
node_name: ros2_cpp_node
is_component: false
is_lifecycle: false
has_launch_file: true
has_params: true
has_subscriber: true
has_publisher: true
has_service_server: false
has_action_server: false
has_timer: false
has_docker_ros: true
- package_name: ros2_cpp_component_pkg
template: ros2_cpp_pkg
node_name: ros2_cpp_node
is_component: true
is_lifecycle: false
has_launch_file: true
has_params: true
has_subscriber: true
has_publisher: true
has_service_server: false
has_action_server: false
has_timer: false
has_docker_ros: true
- package_name: ros2_cpp_lifecycle_pkg
template: ros2_cpp_pkg
node_name: ros2_cpp_node
is_component: false
is_lifecycle: true
has_launch_file: true
has_params: true
has_subscriber: true
has_publisher: true
has_service_server: false
has_action_server: false
has_timer: false
has_docker_ros: true
- package_name: ros2_cpp_all_pkg
template: ros2_cpp_pkg
node_name: ros2_cpp_node
is_component: true
is_lifecycle: true
has_launch_file: true
has_params: true
has_subscriber: true
has_publisher: true
has_service_server: true
has_action_server: true
has_timer: true
has_docker_ros: true
- package_name: ros2_python_pkg
template: ros2_python_pkg
node_name: ros2_python_node
is_lifecycle: false
has_launch_file: true
has_params: true
has_subscriber: true
has_publisher: true
has_service_server: false
has_action_server: false
has_timer: false
has_docker_ros: true
- package_name: ros2_python_all_pkg
template: ros2_python_pkg
node_name: ros2_python_node
is_lifecycle: false
has_launch_file: true
has_params: true
has_subscriber: true
has_publisher: true
has_service_server: true
has_action_server: true
has_timer: true
has_docker_ros: true
- package_name: ros2_interfaces_pkg
template: ros2_interfaces_pkg
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install "copier~=9.2.0" "jinja2-strcase~=0.0.2"
- name: Configure git to run copier
run: |
git config --global user.name "dummy"
git config --global user.email "[email protected]"
- name: Generate packages
run: |
copier copy --trust --defaults \
-d template=${{ matrix.template }} \
-d package_name=${{ matrix.package_name }} \
-d node_name=${{ matrix.node_name }} \
-d is_component=${{ matrix.is_component }} \
-d is_lifecycle=${{ matrix.is_lifecycle }} \
-d has_launch_file=${{ matrix.has_launch_file }} \
-d has_params=${{ matrix.has_params }} \
-d has_subscriber=${{ matrix.has_subscriber }} \
-d has_publisher=${{ matrix.has_publisher }} \
-d has_service_server=${{ matrix.has_service_server }} \
-d has_action_server=${{ matrix.has_action_server }} \
-d has_timer=${{ matrix.has_timer }} \
-d has_docker_ros=${{ matrix.has_docker_ros }} \
. packages
- name: Check for repository changes
run: |
rm -rf samples/${{ matrix.package_name }}*
mv packages/${{ matrix.package_name }}* samples/
if [[ ! -z "$(git status --porcelain)" ]]; then
echo "Sample generation resulted in changes to the repository"
git status
git diff
exit 1
fi
179 changes: 179 additions & 0 deletions .github/workflows/generate-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: Generate and test packages

# avoiding duplicate jobs on push with open pull_request: https://github.com/orgs/community/discussions/26940#discussioncomment-6656489
on: [push, pull_request]

jobs:

generate:
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork)
runs-on: ubuntu-latest
strategy:
matrix:
include:
- package_name: default_cpp_pkg
template: ros2_cpp_pkg
auto_shutdown: true
- package_name: component_cpp_pkg
template: ros2_cpp_pkg
is_component: true
auto_shutdown: true
- package_name: lifecycle_cpp_pkg
template: ros2_cpp_pkg
is_lifecycle: true
auto_shutdown: true
- package_name: service_cpp_pkg
template: ros2_cpp_pkg
has_service_server: true
auto_shutdown: true
- package_name: action_cpp_pkg
template: ros2_cpp_pkg
has_action_server: true
auto_shutdown: true
- package_name: timer_cpp_pkg
template: ros2_cpp_pkg
has_timer: true
auto_shutdown: true
- package_name: no_params_cpp_pkg
template: ros2_cpp_pkg
has_params: false
auto_shutdown: true
- package_name: no_launch_file_cpp_pkg
template: ros2_cpp_pkg
has_launch_file: false
auto_shutdown: true
- package_name: all_cpp_pkg
template: ros2_cpp_pkg
is_component: true
is_lifecycle: true
has_service_server: true
has_action_server: true
has_timer: true
auto_shutdown: true
- package_name: default_python_pkg
template: ros2_python_pkg
auto_shutdown: true
- package_name: service_python_pkg
template: ros2_python_pkg
has_service_server: true
auto_shutdown: true
- package_name: action_python_pkg
template: ros2_python_pkg
has_action_server: true
auto_shutdown: true
- package_name: timer_python_pkg
template: ros2_python_pkg
has_timer: true
auto_shutdown: true
- package_name: no_params_python_pkg
template: ros2_python_pkg
has_params: false
auto_shutdown: true
- package_name: no_launch_file_python_pkg
template: ros2_python_pkg
has_launch_file: false
auto_shutdown: true
- package_name: all_python_pkg
template: ros2_python_pkg
is_lifecycle: true
has_service_server: true
has_action_server: true
has_timer: true
auto_shutdown: true
- package_name: interfaces_pkg
template: ros2_interfaces_pkg
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install "copier~=9.2.0" "jinja2-strcase~=0.0.2"
- name: Configure git to run copier
run: |
git config --global user.name "dummy"
git config --global user.email "[email protected]"
- name: Generate packages
run: |
copier copy --trust --defaults \
-d template=${{ matrix.template }} \
-d auto_shutdown=${{ matrix.auto_shutdown }} \
-d package_name=${{ matrix.package_name }} \
$( [ "${{ matrix.is_component }}" = "true" ] && echo "-d is_component=true" ) \
$( [ "${{ matrix.is_lifecycle }}" = "true" ] && echo "-d is_lifecycle=true" ) \
$( [ "${{ matrix.has_service_server }}" = "true" ] && echo "-d has_service_server=true" ) \
$( [ "${{ matrix.has_action_server }}" = "true" ] && echo "-d has_action_server=true" ) \
$( [ "${{ matrix.has_timer }}" = "true" ] && echo "-d has_timer=true" ) \
$( [ "${{ matrix.has_params }}" = "false" ] && echo "-d has_params=false" ) \
$( [ "${{ matrix.has_launch_file }}" = "false" ] && echo "-d has_launch_file=false" ) \
. packages
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package_name }}
path: "packages/${{ matrix.package_name }}*"

build:
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork)
runs-on: ubuntu-latest
container:
image: rwthika/ros2:jazzy
needs: generate
strategy:
matrix:
include:
- package: default_cpp_pkg
command: ros2 launch default_cpp_pkg default_cpp_pkg_launch.py
- package: component_cpp_pkg
command: ros2 launch component_cpp_pkg component_cpp_pkg_launch.py
- package: lifecycle_cpp_pkg
command: ros2 launch lifecycle_cpp_pkg lifecycle_cpp_pkg_launch.py
- package: service_cpp_pkg
command: ros2 launch service_cpp_pkg service_cpp_pkg_launch.py
- package: action_cpp_pkg
command: ros2 launch action_cpp_pkg action_cpp_pkg_launch.py
- package: timer_cpp_pkg
command: ros2 launch timer_cpp_pkg timer_cpp_pkg_launch.py
- package: no_params_cpp_pkg
command: ros2 launch no_params_cpp_pkg no_params_cpp_pkg_launch.py
- package: no_launch_file_cpp_pkg
command: ros2 run no_launch_file_cpp_pkg no_launch_file_cpp_pkg --ros-args -p param:=1.0
- package: all_cpp_pkg
command: ros2 launch all_cpp_pkg all_cpp_pkg_launch.py
- package: default_python_pkg
command: ros2 launch default_python_pkg default_python_pkg_launch.py
- package: service_python_pkg
command: ros2 launch service_python_pkg service_python_pkg_launch.py
- package: action_python_pkg
command: ros2 launch action_python_pkg action_python_pkg_launch.py
- package: timer_python_pkg
command: ros2 launch timer_python_pkg timer_python_pkg_launch.py
- package: no_params_python_pkg
command: ros2 launch no_params_python_pkg no_params_python_pkg_launch.py
- package: no_launch_file_python_pkg
command: ros2 run no_launch_file_python_pkg no_launch_file_python_pkg --ros-args -p param:=1.0
- package: all_python_pkg
command: ros2 launch all_python_pkg all_python_pkg_launch.py
- package: interfaces_pkg
command: |
ros2 interface show interfaces_pkg/msg/Message && \
ros2 interface show interfaces_pkg/srv/Service && \
ros2 interface show interfaces_pkg/action/Action
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Build
shell: bash
run: |
source /opt/ros/$ROS_DISTRO/setup.bash
colcon build --packages-up-to ${{ matrix.package }}
- name: Run
shell: bash
run: |
source install/setup.bash
${{ matrix.command }}
45 changes: 45 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish to PyPI

on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main

jobs:
publish:
name: Publish ${{ matrix.package }}
runs-on: ubuntu-latest
strategy:
matrix:
package: [ros2-pkg-create]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.x"
- name: Install pypa/build
run: python3 -m pip install --user build
- name: Build wheel and tarball
run: python3 -m build --sdist --wheel --outdir dist/ ${{ matrix.package }}
- name: Publish to TestPyPI
uses: pypa/[email protected]
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true
# `continue-on-error` needed cause `skip-existing: true` is not honored
# https://github.com/pypa/gh-action-pypi-publish/issues/201
continue-on-error: true
Loading

0 comments on commit c8f3be7

Please sign in to comment.