|
| 1 | +name: ROS 2 Launch Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, testing] |
| 6 | + pull_request: |
| 7 | + branches: [main, testing] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +env: |
| 11 | + WORLDS_DIR: /opt/jderobot |
| 12 | + ROS_DISTRO: humble |
| 13 | + |
| 14 | +jobs: |
| 15 | + launch-tests: |
| 16 | + runs-on: ubuntu-22.04 |
| 17 | + timeout-minutes: 30 |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Create checkout directory with proper permissions |
| 21 | + run: | |
| 22 | + sudo mkdir -p ${{ env.WORLDS_DIR }} |
| 23 | + sudo chmod -R 777 ${{ env.WORLDS_DIR }} |
| 24 | +
|
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v3 |
| 27 | + |
| 28 | + - name: copy worlds |
| 29 | + run: | |
| 30 | + sudo cp -r ${{ github.workspace }}/Worlds ${{ env.WORLDS_DIR }} |
| 31 | +
|
| 32 | + - name: Setup ROS 2 Humble |
| 33 | + run: | |
| 34 | + # Add the ROS 2 apt repository with updated key |
| 35 | + sudo apt-get update && sudo apt-get install -y curl gnupg lsb-release |
| 36 | + sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg |
| 37 | + 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 |
| 38 | + sudo apt-get update |
| 39 | + # Install ROS 2 packages |
| 40 | + sudo apt-get install -y ros-humble-ros-base python3-colcon-common-extensions |
| 41 | +
|
| 42 | + - name: "Setup Gazebo" |
| 43 | + uses: gazebo-tooling/setup-gazebo@v0.3.0 |
| 44 | + with: |
| 45 | + required-gazebo-distributions: harmonic |
| 46 | + - name: "Test Gazebo installation" |
| 47 | + run: "gz sim --versions" |
| 48 | + |
| 49 | + # - name: Install Gazebo and dependencies |
| 50 | + # run: | |
| 51 | + # # First install libunwind-dev to satisfy dependency requirements |
| 52 | + # sudo apt-get update |
| 53 | + # sudo apt-get install -y libunwind-dev |
| 54 | + |
| 55 | + # # Then install the rest of the packages |
| 56 | + # sudo apt-get install -y python3-pip python3-pytest-timeout python3-pytest-cov \ |
| 57 | + # ros-humble-launch-testing ros-humble-launch-testing-ament-cmake \ |
| 58 | + # ros-humble-gazebo-ros-pkgs ros-humble-gazebo-ros ros-humble-xacro \ |
| 59 | + # ros-humble-joint-state-publisher ros-humble-robot-state-publisher \ |
| 60 | + # ros-humble-nav2-msgs ros-humble-turtlebot3-msgs |
| 61 | + |
| 62 | + # # Install Gazebo separately with --fix-broken option |
| 63 | + # sudo apt-get install -y --fix-broken gazebo libgazebo-dev |
| 64 | + |
| 65 | + - name: Setup Python dependencies |
| 66 | + run: | |
| 67 | + python -m pip install --upgrade pip |
| 68 | + if [ -f test/requirements.txt ]; then |
| 69 | + pip install -r test/requirements.txt |
| 70 | + fi |
| 71 | + pip install pytest pytest-timeout pytest-cov |
| 72 | +
|
| 73 | + - name: Configure Gazebo for headless rendering |
| 74 | + run: | |
| 75 | + # Configure display for headless rendering |
| 76 | + echo "export GAZEBO_IP=127.0.0.1" >> $GITHUB_ENV |
| 77 | + echo "export OGRE_RTT_MODE=Copy" >> $GITHUB_ENV |
| 78 | + echo "export DISPLAY=:1" >> $GITHUB_ENV |
| 79 | +
|
| 80 | + # Configure audio to use null devices |
| 81 | + echo "export AUDIODEV=null" >> $GITHUB_ENV |
| 82 | + echo "export SDL_AUDIODRIVER=dummy" >> $GITHUB_ENV |
| 83 | +
|
| 84 | + # Create dummy ALSA config |
| 85 | + echo 'pcm.!default { type null; }' > ~/.asoundrc |
| 86 | + echo 'ctl.!default { type null; }' >> ~/.asoundrc |
| 87 | +
|
| 88 | + # Set up virtual framebuffer for visual rendering |
| 89 | + sudo apt-get install -y xvfb |
| 90 | + Xvfb :1 -screen 0 1280x1024x24 & |
| 91 | +
|
| 92 | + # Give Xvfb and audio config time to initialize |
| 93 | + sleep 3 |
| 94 | +
|
| 95 | + - name: add only Harmonic tests to ros package |
| 96 | + run: sed -i 's|file(GLOB TEST_FILES "${RI_ROOT_DIR}/test/test\*\.py")|file(GLOB TEST_FILES "${RI_ROOT_DIR}/test/harmonic/test_*.py")|' CustomRobots/CMakeLists.txt |
| 97 | + |
| 98 | + - name: Build workspace |
| 99 | + run: | |
| 100 | + source /opt/ros/humble/setup.bash |
| 101 | + source /usr/share/gazebo/setup.sh |
| 102 | + colcon build --symlink-install --packages-up-to custom_robots |
| 103 | +
|
| 104 | + - name: Run launch tests |
| 105 | + run: | |
| 106 | + source /opt/ros/humble/setup.bash |
| 107 | + source install/setup.bash |
| 108 | + source /usr/share/gazebo/setup.bash |
| 109 | + colcon test --packages-select custom_robots --event-handlers console_direct+ --return-code-on-test-failure |
| 110 | +
|
| 111 | + - name: Show test results |
| 112 | + if: always() |
| 113 | + run: | |
| 114 | + colcon test-result --verbose |
0 commit comments