Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing vendor package installation #20

Closed
wants to merge 2 commits into from
Closed
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.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,30 @@ jobs:
source /opt/ros/humble/setup.bash
ros2 pkg list | grep ros_gz
ign gazebo --version | grep 'version 6.*'

test_install_ros_gz_vendor:
name: 'Install Harmonic on Jazzy through vendor packages'
env:
ROS_DISTROS: 'jazzy'
runs-on: ubuntu-latest
container:
image: ubuntu:noble
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
node-version: '20.x'
- name: 'Install ROS 2 Jazzy'
uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ env.ROS_DISTROS }}
- name: 'Install Gazebo with ros_gz'
uses: ./
with:
required-gazebo-distributions: 'harmonic'
install-ros-gz: ${{ env.ROS_DISTROS }}
- name: Test Jazzy ros_gz installation
run: |
source /opt/ros/jazzy/setup.bash
ros2 pkg list | grep ros_gz
gz sim --version | grep 'version 8.[0-9*].[0-9*]'
31 changes: 31 additions & 0 deletions __test__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ describe("validate ROS 2 distribution test", () => {
it("test valid distro", async () => {
await expect(utils.validateROSDistro(["humble"])).toBe(true);
await expect(utils.validateROSDistro(["iron"])).toBe(true);
await expect(utils.validateROSDistro(["jazzy"])).toBe(true);
await expect(utils.validateROSDistro(["rolling"])).toBe(true);
await expect(utils.validateROSDistro(["humble", "iron"])).toBe(true);
});
it("test invalid distro", async () => {
Expand Down Expand Up @@ -185,5 +187,34 @@ describe("generate APT package names for ros_gz", () => {
await expect(
utils.generateROSAptPackageNames(["iron"], ["fortress", "garden"]),
).toEqual(["ros-iron-ros-gz", "ros-iron-ros-gzgarden"]);
await expect(
utils.generateROSAptPackageNames(["jazzy"], ["harmonic"]),
).toEqual(["ros-jazzy-ros-gz"]);
await expect(
utils.generateROSAptPackageNames(["rolling"], ["harmonic"]),
).toEqual(["ros-rolling-ros-gz"]);
});
});

describe("check for Gazebo vendor packages for ROS 2 distribution", () => {
it("test for Gazebo vendor packages", async () => {
await expect(
utils.checkForROSGzVendorPackages("garden", ["humble"]),
).toEqual(false);
await expect(
utils.checkForROSGzVendorPackages("harmonic", ["iron"]),
).toEqual(false);
await expect(
utils.checkForROSGzVendorPackages("harmonic", ["jazzy"]),
).toEqual(true);
await expect(
utils.checkForROSGzVendorPackages("harmonic", ["rolling"]),
).toEqual(true);
await expect(
utils.checkForROSGzVendorPackages("fortress", ["humble", "iron"]),
).toEqual(false);
await expect(
utils.checkForROSGzVendorPackages("harmonic", ["rolling", "jazzy"]),
).toEqual(true);
});
});
31 changes: 29 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26489,10 +26489,12 @@ function runLinux() {
yield addAptRepo(ubuntuCodename);
const gazeboDistros = yield utils.getRequiredGazeboDistributions();
yield utils.checkUbuntuCompatibility(gazeboDistros, ubuntuCodename);
const rosGzDistros = utils.checkForROSGz();
for (const gazeboDistro of gazeboDistros) {
yield apt.runAptGetInstall([`gz-${gazeboDistro}`]);
if (!utils.checkForROSGzVendorPackages(gazeboDistro, rosGzDistros)) {
yield apt.runAptGetInstall([`gz-${gazeboDistro}`]);
}
}
const rosGzDistros = utils.checkForROSGz();
if (rosGzDistros.length > 0) {
const rosAptPackageNames = utils.generateROSAptPackageNames(rosGzDistros, gazeboDistros);
yield apt.runAptGetInstall(rosAptPackageNames);
Expand Down Expand Up @@ -26800,6 +26802,7 @@ exports.checkUbuntuCompatibility = checkUbuntuCompatibility;
exports.checkForUnstableAptRepos = checkForUnstableAptRepos;
exports.checkForROSGz = checkForROSGz;
exports.generateROSAptPackageNames = generateROSAptPackageNames;
exports.checkForROSGzVendorPackages = checkForROSGzVendorPackages;
const actions_exec = __importStar(__nccwpck_require__(1514));
const core = __importStar(__nccwpck_require__(2186));
const yaml_1 = __nccwpck_require__(4083);
Expand All @@ -26813,11 +26816,25 @@ const validROSGzDistrosList = [
rosDistro: "humble",
officialROSGzWrappers: ["fortress"],
unofficialROSGzWrappers: ["garden", "harmonic"],
vendorPackagesAvailable: false,
},
{
rosDistro: "iron",
officialROSGzWrappers: ["fortress"],
unofficialROSGzWrappers: ["garden", "harmonic"],
vendorPackagesAvailable: false,
},
{
rosDistro: "jazzy",
officialROSGzWrappers: ["harmonic"],
unofficialROSGzWrappers: [],
vendorPackagesAvailable: true,
},
{
rosDistro: "rolling",
officialROSGzWrappers: ["harmonic"],
unofficialROSGzWrappers: [],
vendorPackagesAvailable: true,
},
];
/**
Expand Down Expand Up @@ -27020,6 +27037,16 @@ function generateROSAptPackageNames(rosGzDistrosList, requiredGazeboDistribution
}
return rosAptPackageNames;
}
function checkForROSGzVendorPackages(gazeboDistro, rosGzDistrosList) {
for (const rosDistro of rosGzDistrosList) {
const distroInfo = validROSGzDistrosList.find((distro) => distro.rosDistro === rosDistro);
if (distroInfo.vendorPackagesAvailable &&
distroInfo.officialROSGzWrappers.indexOf(gazeboDistro) > -1) {
return true;
}
}
return false;
}


/***/ }),
Expand Down
7 changes: 5 additions & 2 deletions src/setup-gazebo-linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,14 @@ export async function runLinux(): Promise<void> {

await utils.checkUbuntuCompatibility(gazeboDistros, ubuntuCodename);

const rosGzDistros = utils.checkForROSGz();

for (const gazeboDistro of gazeboDistros) {
await apt.runAptGetInstall([`gz-${gazeboDistro}`]);
if (!utils.checkForROSGzVendorPackages(gazeboDistro, rosGzDistros)) {
await apt.runAptGetInstall([`gz-${gazeboDistro}`]);
}
}

const rosGzDistros = utils.checkForROSGz();
if (rosGzDistros.length > 0) {
const rosAptPackageNames = utils.generateROSAptPackageNames(
rosGzDistros,
Expand Down
33 changes: 33 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,31 @@ const validROSGzDistrosList: {
rosDistro: string;
officialROSGzWrappers: string[];
unofficialROSGzWrappers: string[];
vendorPackagesAvailable: boolean;
}[] = [
{
rosDistro: "humble",
officialROSGzWrappers: ["fortress"],
unofficialROSGzWrappers: ["garden", "harmonic"],
vendorPackagesAvailable: false,
},
{
rosDistro: "iron",
officialROSGzWrappers: ["fortress"],
unofficialROSGzWrappers: ["garden", "harmonic"],
vendorPackagesAvailable: false,
},
{
rosDistro: "jazzy",
officialROSGzWrappers: ["harmonic"],
unofficialROSGzWrappers: [],
vendorPackagesAvailable: true,
},
{
rosDistro: "rolling",
officialROSGzWrappers: ["harmonic"],
unofficialROSGzWrappers: [],
vendorPackagesAvailable: true,
},
];

Expand Down Expand Up @@ -262,3 +277,21 @@ export function generateROSAptPackageNames(
}
return rosAptPackageNames;
}

export function checkForROSGzVendorPackages(
gazeboDistro: string,
rosGzDistrosList: string[],
): boolean {
for (const rosDistro of rosGzDistrosList) {
const distroInfo = validROSGzDistrosList.find(
(distro) => distro.rosDistro === rosDistro,
);
if (
distroInfo!.vendorPackagesAvailable &&
distroInfo!.officialROSGzWrappers.indexOf(gazeboDistro) > -1
) {
return true;
}
}
return false;
}
Loading