Skip to content

Commit

Permalink
Added pkg name generation test
Browse files Browse the repository at this point in the history
Signed-off-by: Saurabh Kamat <kamatsaurabh01@gmail.com>
  • Loading branch information
sauk2 committed Aug 25, 2024
1 parent 2483d0c commit be715e8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ jobs:
gz sim --versions
test_install_ros_gz:
name: 'Install ROS 2 side-by-side Gazebo'
name: 'Install ROS 2 and Gazebo side-by-side'
runs-on: ubuntu-latest
container:
image: ubuntu:jammy
Expand Down
8 changes: 8 additions & 0 deletions __test__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,11 @@ describe("check for unstable repositories input", () => {
await expect(linux.runLinux()).resolves.not.toThrow();
});
});

describe("generate APT package names for ros_gz", () => {
it("test ROS 2 and gazebo combination", async () => {
await expect(
utils.generateRosAptPackageNames(["rolling", "iron"], ["harmonic"]),
).toEqual(["ros-rolling-ros-gz", "ros-iron-ros-gzharmonic"]);
});
});
12 changes: 10 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26810,7 +26810,9 @@ const validGazeboDistroList = [
"harmonic",
"ionic",
];
// List of valid ROS 2 distributions
// List of valid ROS 2 distributions and compatible Gazebo mapping
// For more information check the following link
// https://gazebosim.org/docs/latest/ros_installation/#summary-of-compatible-ros-and-gazebo-combinations
const validRosGzDistrosList = [
{
rosDistro: "humble",
Expand Down Expand Up @@ -26990,7 +26992,6 @@ function checkForUnstableAptRepos() {
function checkForRosGz() {
let requiredRosDistroList = [];
const installRosGz = core.getInput("install-ros-gz");
console.log(installRosGz);
if (installRosGz) {
requiredRosDistroList = installRosGz.split(RegExp("\\s"));
if (!validateRosDistro(requiredRosDistroList)) {
Expand All @@ -26999,6 +27000,13 @@ function checkForRosGz() {
}
return requiredRosDistroList;
}
/**
* Generate APT package name from ROS 2 and Gazebo distribution names
*
* @param rosGzDistrosList ROS 2 distro ros_gz packages to be installed
* @param requiredGazeboDistributionsList Installed Gazebo distributions
* @returns string [] List of APT package names
*/
function generateRosAptPackageNames(rosGzDistrosList, requiredGazeboDistributionsList) {
const rosAptPackageNames = [];
for (const rosDistro of rosGzDistrosList) {
Expand Down
12 changes: 10 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const validGazeboDistroList: string[] = [
"ionic",
];

// List of valid ROS 2 distributions
// List of valid ROS 2 distributions and compatible Gazebo mapping
// For more information check the following link
// https://gazebosim.org/docs/latest/ros_installation/#summary-of-compatible-ros-and-gazebo-combinations
const validRosGzDistrosList: {
rosDistro: string;
compatibleGazeboDistros: string[];
Expand Down Expand Up @@ -227,7 +229,6 @@ export function checkForUnstableAptRepos(): string[] {
export function checkForRosGz(): string[] {
let requiredRosDistroList: string[] = [];
const installRosGz = core.getInput("install-ros-gz");
console.log(installRosGz);
if (installRosGz) {
requiredRosDistroList = installRosGz.split(RegExp("\\s"));
if (!validateRosDistro(requiredRosDistroList)) {
Expand All @@ -237,6 +238,13 @@ export function checkForRosGz(): string[] {
return requiredRosDistroList;
}

/**
* Generate APT package name from ROS 2 and Gazebo distribution names
*
* @param rosGzDistrosList ROS 2 distro ros_gz packages to be installed
* @param requiredGazeboDistributionsList Installed Gazebo distributions
* @returns string [] List of APT package names
*/
export function generateRosAptPackageNames(
rosGzDistrosList: string[],
requiredGazeboDistributionsList: string[],
Expand Down

0 comments on commit be715e8

Please sign in to comment.