ci: update tests workflow with gazebo headless setup #10
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: ROS 2 Launch Tests | |
| on: | |
| push: | |
| branches: [main, testing] | |
| pull_request: | |
| branches: [main, testing] | |
| workflow_dispatch: | |
| env: | |
| WORLDS_DIR: /opt/jderobot | |
| ROS_DISTRO: humble | |
| jobs: | |
| launch-tests: | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Create checkout directory with proper permissions | |
| run: | | |
| sudo mkdir -p ${{ env.WORLDS_DIR }} | |
| sudo chmod -R 777 ${{ env.WORLDS_DIR }} | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: copy worlds | |
| run: | | |
| sudo cp -r ${{ github.workspace }}/Worlds ${{ env.WORLDS_DIR }} | |
| - name: Setup ROS 2 Humble | |
| run: | | |
| # Add the ROS 2 apt repository with updated key | |
| sudo apt-get update && sudo apt-get install -y curl gnupg lsb-release | |
| 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-get update | |
| # Install ROS 2 packages | |
| sudo apt-get install -y ros-humble-ros-base python3-colcon-common-extensions | |
| - name: Install Gazebo and dependencies | |
| run: | | |
| # First install libunwind-dev to satisfy dependency requirements | |
| sudo apt-get update | |
| sudo apt-get install -y libunwind-dev | |
| # Then install the rest of the packages | |
| sudo apt-get install -y python3-pip python3-pytest-timeout python3-pytest-cov \ | |
| ros-humble-launch-testing ros-humble-launch-testing-ament-cmake \ | |
| ros-humble-gazebo-ros-pkgs ros-humble-gazebo-ros ros-humble-xacro \ | |
| ros-humble-joint-state-publisher ros-humble-robot-state-publisher \ | |
| ros-humble-nav2-msgs ros-humble-turtlebot3-msgs | |
| # Install Gazebo separately with --fix-broken option | |
| sudo apt-get install -y --fix-broken gazebo libgazebo-dev | |
| - name: Setup Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| if [ -f test/requirements.txt ]; then | |
| pip install -r test/requirements.txt | |
| fi | |
| pip install pytest pytest-timeout pytest-cov | |
| - name: Configure Gazebo for headless rendering | |
| run: | | |
| echo "export GAZEBO_IP=127.0.0.1" >> $GITHUB_ENV | |
| echo "export OGRE_RTT_MODE=Copy" >> $GITHUB_ENV | |
| echo "export DISPLAY=:1" >> $GITHUB_ENV | |
| # Set up virtual framebuffer | |
| sudo apt-get install -y xvfb | |
| Xvfb :1 -screen 0 1280x1024x24 & | |
| - name: Build workspace | |
| run: | | |
| source /opt/ros/humble/setup.bash | |
| source /usr/share/gazebo/setup.sh | |
| colcon build --symlink-install --packages-up-to custom_robots | |
| # - name: Set timeout for launch tests in CMakeLists.txt | |
| # run: | | |
| # sed -i 's/add_launch_test(${test_file} TIMEOUT 90)/add_launch_test(${test_file} TIMEOUT 180)/g' src/RoboticsInfrastructure/CustomRobots/CMakeLists.txt | |
| # # Rebuild with new timeout settings | |
| # source /opt/ros/humble/setup.bash | |
| # source /usr/share/gazebo/setup.sh | |
| # colcon build --symlink-install --packages-select custom_robots | |
| - name: Run launch tests | |
| run: | | |
| source /opt/ros/humble/setup.bash | |
| source install/setup.bash | |
| source /usr/share/gazebo/setup.bash | |
| colcon test --packages-select custom_robots --event-handlers console_direct+ --return-code-on-test-failure | |
| - name: Show test results | |
| if: always() | |
| run: | | |
| colcon test-result --verbose |