From 6a82f0ac048aa8fb45d5ad245d3ed56afa463f2c Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 31 Oct 2023 21:25:23 +0700 Subject: [PATCH 1/2] refactor: move the content of `setup_dependencies.bash` to `action.yaml` --- action.yaml | 19 ++++++++++++++++--- scripts/setup-dependencies.bash | 18 ------------------ 2 files changed, 16 insertions(+), 21 deletions(-) delete mode 100644 scripts/setup-dependencies.bash diff --git a/action.yaml b/action.yaml index 764f430..c39e1cf 100644 --- a/action.yaml +++ b/action.yaml @@ -12,9 +12,22 @@ inputs: runs: using: composite steps: - - name: Setup dependencies - run: bash ${{ github.action_path }}/scripts/setup-dependencies.bash ${{ inputs.ros2-distro }} - shell: bash + - shell: bash + run: | + sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null + + - shell: bash + run: | + sudo apt update + sudo apt install -y python3-colcon-common-extensions python3-rosdep + + - shell: bash + run: | + sudo rosdep init + rosdep update + rosdep install -y --rosdistro ${{ inputs.ros2-distro }} --from-paths . + - name: Build and test workspace run: bash ${{ github.action_path }}/scripts/build-and-test.bash ${{ inputs.ros2-distro }} shell: bash diff --git a/scripts/setup-dependencies.bash b/scripts/setup-dependencies.bash deleted file mode 100644 index f4cf259..0000000 --- a/scripts/setup-dependencies.bash +++ /dev/null @@ -1,18 +0,0 @@ -ROS2_DISTRO="$1" - -# Add ROS 2 GPG key -sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg || exit $? - -# Add ROS 2 repository to the source list -echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null || exit $? - -# Install required tools -sudo apt update && sudo apt install -y \ - python3-colcon-common-extensions \ - python3-rosdep || exit $? - -# Initialize rosdep -sudo rosdep init || true - -# Install ROS 2 workspace dependencies -rosdep update && rosdep install -y --rosdistro "$ROS2_DISTRO" --from-paths . || exit $? From d6570e167e6e0a1e3defa21f3f87a6f9f880902e Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Wed, 1 Nov 2023 10:24:38 +0700 Subject: [PATCH 2/2] refactor: move the content of `build-and-test.bash` script to `action.yaml` --- action.yaml | 12 +++++++++--- scripts/build-and-test.bash | 18 ------------------ 2 files changed, 9 insertions(+), 21 deletions(-) delete mode 100644 scripts/build-and-test.bash diff --git a/action.yaml b/action.yaml index c39e1cf..ca342f4 100644 --- a/action.yaml +++ b/action.yaml @@ -28,6 +28,12 @@ runs: rosdep update rosdep install -y --rosdistro ${{ inputs.ros2-distro }} --from-paths . - - name: Build and test workspace - run: bash ${{ github.action_path }}/scripts/build-and-test.bash ${{ inputs.ros2-distro }} - shell: bash + - shell: bash + run: | + source /opt/ros/${{ inputs.ros2-distro }}/setup.bash + colcon build --event-handlers console_cohesion+ --cmake-args + + - shell: bash + run: | + source install/setup.bash + colcon test --event-handlers console_cohesion+ --pytest-with-coverage --return-code-on-test-failure diff --git a/scripts/build-and-test.bash b/scripts/build-and-test.bash deleted file mode 100644 index ee1d438..0000000 --- a/scripts/build-and-test.bash +++ /dev/null @@ -1,18 +0,0 @@ -ROS2_DISTRO="$1" - -# Source ROS 2 environment -source /opt/ros/$ROS2_DISTRO/setup.bash || exit $? - -# Build workspace -colcon build \ - --event-handlers console_cohesion+ \ - --cmake-args || exit $? - -# Source build result environment -source install/setup.bash || exit $? - -# Test workspace -colcon test \ - --event-handlers console_cohesion+ \ - --pytest-with-coverage \ - --return-code-on-test-failure || exit $?