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
5 changes: 3 additions & 2 deletions vinca/generate_gha.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,11 @@ def dump_for_gha(doc, f):


def get_stage_name(batch):
legacy_prefix = f"ros-{config.ros_distro}-"
stage_name = []
for pkg in batch:
if len(pkg.split("-")) > 2:
stage_name.append("-".join(pkg.split("-")[2:]))
if pkg.startswith(legacy_prefix):
stage_name.append(pkg[len(legacy_prefix) :])
else:
stage_name.append(pkg)
return " ".join(stage_name)
Expand Down
34 changes: 34 additions & 0 deletions vinca/test_generate_gha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Tests for the GitHub Actions pipeline generation."""

import pytest

from vinca import config
from vinca.generate_gha import get_stage_name


@pytest.fixture(autouse=True)
def rolling_distro():
previous = config.ros_distro
config.ros_distro = "rolling"
yield
config.ros_distro = previous


@pytest.mark.parametrize(
"package,expected",
[
("ros-rolling-rclcpp", "rclcpp"),
("ros-rolling-ament-package", "ament-package"),
("ros2-rclcpp", "ros2-rclcpp"),
("ros2-ament-package", "ros2-ament-package"),
("ros2-distro-mutex", "ros2-distro-mutex"),
("ros-humble-rclcpp", "ros-humble-rclcpp"),
],
)
def test_get_stage_name_strips_only_the_legacy_prefix(package, expected):
assert get_stage_name([package]) == expected


def test_get_stage_name_joins_a_batch():
batch = ["ros-rolling-rclcpp", "ros2-ament-package"]
assert get_stage_name(batch) == "rclcpp ros2-ament-package"