From d4ba0732bbf9ceefc43da31f0ebf92b566e3d130 Mon Sep 17 00:00:00 2001 From: Thomas Moulard Date: Mon, 9 Dec 2019 14:44:38 -0800 Subject: [PATCH] Add support for installing ROS using APT (#30) Signed-off-by: Thomas Moulard --- .github/workflows/test.yml | 19 +++++++++++++++++++ action.yml | 22 ++++++++++++++++++++++ dist/index.js | 12 ++++++++++++ src/setup-ros2-linux.ts | 15 +++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c7852b52b..6171d036c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,3 +36,22 @@ jobs: - run: which colcon - run: which rosdep - run: which vcs + + test_binary_install: + name: "ROS and ROS 2 Binary Install Test Suite (Linux only)" + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: '12.x' + - run: npm ci + - run: npm run build + + - uses: ./ # Uses an action in the root directory + with: + required-ros-distributions: melodic dashing + - run: test -f /opt/ros/dashing/setup.sh + name: "Check that dashing setup.sh has been installed." + - run: test -f /opt/ros/melodic/setup.sh + name: "Check that melodic setup.sh has been installed." diff --git a/action.yml b/action.yml index 7b4db2ae8..970160aa2 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,28 @@ author: 'ROS Tooling Working Group' branding: icon: 'box' color: 'gray-dark' +inputs: + required-ros-distributions: + description: | + List of binary ROS distributions to be installed. + + Support for non-Linux platform is not implemented yet, so this + parameter is ignored on Mac OS X and Windows. + + Allowed ROS distributions + - "" (no value) - no ROS binary installation + - kinetic + - melodic + - dashing + - eloquent + - source + + Multiple values can be passed using a whitespace delimited list + "melodic dashing". + + For each passed ROS distribution, its desktop variant will be installed. + required: false + default: "" runs: using: 'node12' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index f6b894eb6..52bc326e7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1049,6 +1049,11 @@ function runLinux() { "--recv-keys", "C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654" ]); + yield utils.exec("sudo", [ + "bash", + "-c", + `echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list` + ]); yield utils.exec("sudo", [ "bash", "-c", @@ -1063,6 +1068,13 @@ function runLinux() { yield pip.installPython3Dependencies(); // Initializes rosdep yield utils.exec("sudo", ["rosdep", "init"]); + const requiredRosDistributions = core.getInput("required-ros-distributions"); + if (requiredRosDistributions) { + const requiredRosDistributionsList = requiredRosDistributions.split(RegExp("\\s")); + for (let rosDistro of requiredRosDistributionsList) { + yield apt.runAptGetInstall([`ros-${rosDistro}-desktop`]); + } + } }); } exports.runLinux = runLinux; diff --git a/src/setup-ros2-linux.ts b/src/setup-ros2-linux.ts index 7c36f9804..5f950c78b 100644 --- a/src/setup-ros2-linux.ts +++ b/src/setup-ros2-linux.ts @@ -35,6 +35,11 @@ export async function runLinux() { "--recv-keys", "C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654" ]); + await utils.exec("sudo", [ + "bash", + "-c", + `echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list` + ]); await utils.exec("sudo", [ "bash", "-c", @@ -50,4 +55,14 @@ export async function runLinux() { await pip.installPython3Dependencies(); // Initializes rosdep await utils.exec("sudo", ["rosdep", "init"]); + + const requiredRosDistributions = core.getInput("required-ros-distributions"); + if (requiredRosDistributions) { + const requiredRosDistributionsList = requiredRosDistributions.split( + RegExp("\\s") + ); + for (let rosDistro of requiredRosDistributionsList) { + await apt.runAptGetInstall([`ros-${rosDistro}-desktop`]); + } + } }