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

Test PR for ros_gz #16

Closed
wants to merge 4 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
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,21 @@ jobs:
run: |
conda activate
gz sim --versions

test_install_ros_gz:
name: 'Install ros_gz side-by-side Gazebo'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.0.3
with:
node-version: '20.x'
- name: 'Install ROS 2 Jazzy'
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: jazzy
- name: 'Install Gazebo with ros_gz'
uses: ./
with:
required-gazebo-distributions: 'harmonic'
install-ros-gz: 'true'
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ inputs:
Use nightly binaries from OSRF repository
required: false
default: 'false'
install-ros-gz:
description: |
Install ros_gz side-by-side with ROS 2 and Gazebo
required: false
default: 'false'
runs:
using: node20
main: dist/index.js
31 changes: 30 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26477,6 +26477,22 @@ function addAptRepo(ubuntuCodename) {
yield utils.exec("sudo", ["apt-get", "update"]);
});
}
function installRosGz() {
return __awaiter(this, void 0, void 0, function* () {
let rosDistroStr = "";
const options = {};
options.listeners = {
stdout: (data) => {
rosDistroStr += data.toString();
},
};
yield utils.exec("bash", ["-c", `distros=($(ls /opt/ros -1)) ; echo -n "$distros"`], options);
const rosDistros = rosDistroStr.split(" ");
for (const rosDistro of rosDistros) {
apt.runAptGetInstall([`ros-${rosDistro}-ros-gz`]);
}
});
}
/**
* Install Gazebo on a Linux worker.
*/
Expand All @@ -26489,9 +26505,12 @@ function runLinux() {
yield addAptRepo(ubuntuCodename);
const gazeboDistros = utils.getRequiredGazeboDistributions();
utils.checkUbuntuCompatibility(gazeboDistros, ubuntuCodename);
for (const gazeboDistro of utils.getRequiredGazeboDistributions()) {
for (const gazeboDistro of gazeboDistros) {
yield apt.runAptGetInstall([`gz-${gazeboDistro}`]);
}
if (utils.checkForRosGz()) {
yield installRosGz();
}
});
}

Expand Down Expand Up @@ -26790,6 +26809,7 @@ exports.validateDistro = validateDistro;
exports.getRequiredGazeboDistributions = getRequiredGazeboDistributions;
exports.checkUbuntuCompatibility = checkUbuntuCompatibility;
exports.checkForUnstableAptRepos = checkForUnstableAptRepos;
exports.checkForRosGz = checkForRosGz;
const actions_exec = __importStar(__nccwpck_require__(1514));
const core = __importStar(__nccwpck_require__(2186));
// List of Valid Gazebo distributions with compatible
Expand All @@ -26798,22 +26818,27 @@ const validGazeboDistroList = [
{
name: "citadel",
compatibleUbuntuDistros: ["focal"],
compatibleRosDistros: ["foxy"],
},
{
name: "fortress",
compatibleUbuntuDistros: ["focal", "jammy"],
compatibleRosDistros: ["humble", "iron"],
},
{
name: "garden",
compatibleUbuntuDistros: ["focal", "jammy"],
compatibleRosDistros: [],
},
{
name: "harmonic",
compatibleUbuntuDistros: ["jammy", "noble"],
compatibleRosDistros: ["jazzy", "rolling"],
},
{
name: "ionic",
compatibleUbuntuDistros: ["noble"],
compatibleRosDistros: [],
},
];
/**
Expand Down Expand Up @@ -26925,6 +26950,10 @@ function checkForUnstableAptRepos() {
}
return unstableRepos;
}
function checkForRosGz() {
const installRosGz = core.getInput("install-ros-gz") === "true";
return installRosGz;
}


/***/ }),
Expand Down
28 changes: 27 additions & 1 deletion src/setup-gazebo-linux.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as core from "@actions/core";
import * as io from "@actions/io";
import * as actions_exec from "@actions/exec";
import * as im from "@actions/exec/lib/interfaces";

import * as apt from "./package_manager/apt";
import * as utils from "./utils";
Expand Down Expand Up @@ -92,6 +94,26 @@ async function addAptRepo(ubuntuCodename: string): Promise<void> {
await utils.exec("sudo", ["apt-get", "update"]);
}

async function installRosGz(): Promise<void> {
let rosDistroStr: string = "";
const options: im.ExecOptions = {};
options.listeners = {
stdout: (data: Buffer) => {
rosDistroStr += data.toString();
},
};
await utils.exec(
"bash",
["-c", `distros=($(ls /opt/ros -1)) ; echo -n "$distros"`],
options,
);

const rosDistros: string[] = rosDistroStr.split(" ");
for (const rosDistro of rosDistros) {
apt.runAptGetInstall([`ros-${rosDistro}-ros-gz`]);
}
}

/**
* Install Gazebo on a Linux worker.
*/
Expand All @@ -107,7 +129,11 @@ export async function runLinux(): Promise<void> {

utils.checkUbuntuCompatibility(gazeboDistros, ubuntuCodename);

for (const gazeboDistro of utils.getRequiredGazeboDistributions()) {
for (const gazeboDistro of gazeboDistros) {
await apt.runAptGetInstall([`gz-${gazeboDistro}`]);
}

if (utils.checkForRosGz()) {
await installRosGz();
}
}
11 changes: 11 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,32 @@ import * as im from "@actions/exec/lib/interfaces";
const validGazeboDistroList: {
name: string;
compatibleUbuntuDistros: string[];
compatibleRosDistros: string[];
}[] = [
{
name: "citadel",
compatibleUbuntuDistros: ["focal"],
compatibleRosDistros: ["foxy"],
},
{
name: "fortress",
compatibleUbuntuDistros: ["focal", "jammy"],
compatibleRosDistros: ["humble", "iron"],
},
{
name: "garden",
compatibleUbuntuDistros: ["focal", "jammy"],
compatibleRosDistros: [],
},
{
name: "harmonic",
compatibleUbuntuDistros: ["jammy", "noble"],
compatibleRosDistros: ["jazzy", "rolling"],
},
{
name: "ionic",
compatibleUbuntuDistros: ["noble"],
compatibleRosDistros: [],
},
];

Expand Down Expand Up @@ -161,3 +167,8 @@ export function checkForUnstableAptRepos(): string[] {
}
return unstableRepos;
}

export function checkForRosGz(): boolean {
const installRosGz = core.getInput("install-ros-gz") === "true";
return installRosGz;
}
Loading