Update README.md #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build-and-test | |
| on: | |
| pull_request: | |
| types: | |
| - labeled | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build-and-test: | |
| if: ${{ github.event.label.name == 'run-build-test' }} | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Set PR fetch depth | |
| run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: ${{ env.PR_FETCH_DEPTH }} | |
| - name: Check for .cpp or .hpp file changes | |
| id: check_diff_cpp | |
| run: | | |
| set -e | |
| if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \ | |
| | grep -qE '*\.(cpp|hpp)$'; then | |
| echo "cpp_changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "cpp_changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup ROS 2 environment | |
| if: steps.check_diff_cpp.outputs.cpp_changed == 'true' | |
| run: | | |
| sudo apt update | |
| sudo apt install -y software-properties-common curl gcovr | |
| 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 $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null | |
| sudo apt update | |
| sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y | |
| sudo apt install -y ros-humble-desktop python3-colcon-common-extensions ros-humble-ament-cmake python3-colcon-mixin | |
| - name: Install dependencies | |
| if: steps.check_diff_cpp.outputs.cpp_changed == 'true' | |
| run: | | |
| source /opt/ros/humble/setup.bash | |
| sudo apt install -y python3-rosdep | |
| sudo rosdep init | |
| rosdep update | |
| rosdep install -y --from-paths . --ignore-src --rosdistro $ROS_DISTRO | |
| - name: Build | |
| if: steps.check_diff_cpp.outputs.cpp_changed == 'true' | |
| run: | | |
| source /opt/ros/humble/setup.bash | |
| colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1 | |
| # TODO: run tests |