fix github ci #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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: Generate packages | |
run: | | |
copier copy --trust --defaults -d template=ros2_cpp_pkg -d auto_shutdown=true -d package_name=pkg_default . packages | |
copier copy --trust --defaults -d template=ros2_cpp_pkg -d auto_shutdown=true -d package_name=pkg_component -d is_component=true . packages | |
copier copy --trust --defaults -d template=ros2_cpp_pkg -d auto_shutdown=true -d package_name=pkg_lifecycle -d is_lifecycle=true . packages | |
copier copy --trust --defaults -d template=ros2_cpp_pkg -d auto_shutdown=true -d package_name=pkg_service -d has_service_server=true . packages | |
copier copy --trust --defaults -d template=ros2_cpp_pkg -d auto_shutdown=true -d package_name=pkg_action -d has_action_server=true . packages | |
copier copy --trust --defaults -d template=ros2_cpp_pkg -d auto_shutdown=true -d package_name=pkg_timer -d has_timer=true . packages | |
copier copy --trust --defaults -d template=ros2_cpp_pkg -d auto_shutdown=true -d package_name=pkg_no_params -d has_params=false . packages | |
copier copy --trust --defaults -d template=ros2_cpp_pkg -d auto_shutdown=true -d package_name=pkg_no_launch_file -d has_launch_file=false . packages | |
copier copy --trust --defaults -d template=ros2_cpp_pkg -d auto_shutdown=true -d package_name=pkg_all -d is_component=true -d is_lifecycle=true -d has_service_server=true -d has_action_server=true -d has_timer=true . packages | |
copier copy --trust --defaults -d template=ros2_interfaces_pkg -d package_name=pkg_interfaces . packages | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: packages | |
path: packages/ | |
build-and-test: | |
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:latest | |
options: --rm | |
needs: generate | |
strategy: | |
matrix: | |
include: | |
- package: pkg_default | |
command: ros2 launch pkg_default pkg_default_launch.py | |
- package: pkg_component | |
command: ros2 launch pkg_component pkg_component_launch.py | |
- package: pkg_lifecycle | |
command: ros2 launch pkg_lifecycle pkg_lifecycle_launch.py | |
- package: pkg_service | |
command: ros2 launch pkg_service pkg_service_launch.py | |
- package: pkg_action | |
command: ros2 launch pkg_action pkg_action_launch.py | |
- package: pkg_timer | |
command: ros2 launch pkg_timer pkg_timer_launch.py | |
- package: pkg_no_params | |
command: ros2 launch pkg_no_params pkg_no_params_launch.py | |
- package: pkg_no_launch_file | |
command: ros2 run pkg_no_launch_file pkg_no_launch_file --ros-args -p param:=1.0 | |
- package: pkg_all | |
command: ros2 launch pkg_all pkg_all_launch.py | |
- package: pkg_interfaces | |
command: | | |
ros2 interface show pkg_interfaces/msg/Message && \ | |
ros2 interface show pkg_interfaces/srv/Service && \ | |
ros2 interface show pkg_interfaces/action/Action | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
- name: Build and test package ${{ matrix.package }} | |
run: | | |
set -e | |
colcon build --packages-up-to ${{ matrix.package }} | |
source install/setup.bash | |
${{ matrix.command }} |