|
| 1 | +name: ROS 2 Launch Tests (Gazebo Harmonic) |
| 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 | + sudo cp -r ${{ github.workspace }}/jderobot_drones ${{ env.WORLDS_DIR }} |
| 32 | +
|
| 33 | + - name: Setup ROS 2 Humble |
| 34 | + run: | |
| 35 | + # Add the ROS 2 apt repository with updated key |
| 36 | + sudo apt-get update && sudo apt-get install -y curl gnupg lsb-release |
| 37 | + sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg |
| 38 | + 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 |
| 39 | + sudo apt-get update |
| 40 | + # Install ROS 2 packages |
| 41 | + sudo apt-get install -y ros-humble-ros-base python3-colcon-common-extensions |
| 42 | +
|
| 43 | + - name: "Setup Gazebo" |
| 44 | + uses: gazebo-tooling/[email protected] |
| 45 | + with: |
| 46 | + required-gazebo-distributions: harmonic |
| 47 | + - name: "Test Gazebo installation" |
| 48 | + run: "gz sim --versions" |
| 49 | + |
| 50 | + - name: Install Gazebo classic and resolve version conflicts |
| 51 | + run: | |
| 52 | + sudo add-apt-repository ppa:openrobotics/gazebo11-gz-cli |
| 53 | + sudo apt update |
| 54 | + sudo apt-get install gazebo11 |
| 55 | +
|
| 56 | + # Resolve version conflicts |
| 57 | + sudo apt-get remove libgazebo11 |
| 58 | + sudo apt-get install libgazebo11=11.10.2+dfsg-1 |
| 59 | + sudo apt-get install libgazebo-dev |
| 60 | +
|
| 61 | + - name: Install aerostack2 and dependencies |
| 62 | + run: | |
| 63 | + sudo apt-get install -y ros-humble-xacro |
| 64 | + sudo apt-get install -y ros-humble-geographic-msgs libgeographic-dev ros-humble-mocap4r2-msgs |
| 65 | + sudo apt install git python3-rosdep python3-pip python3-colcon-common-extensions -y |
| 66 | +
|
| 67 | + mkdir -p ./aerostack2_ws/src/ && cd ./aerostack2_ws/src/ |
| 68 | + git clone https://github.com/aerostack2/aerostack2.git |
| 69 | + cd .. |
| 70 | + sudo rosdep init |
| 71 | + rosdep update |
| 72 | + rosdep install -y -r -q --from-paths src --ignore-src |
| 73 | + sudo apt install ros-humble-ros-gzharmonic |
| 74 | +
|
| 75 | + - name: "Test Gazebo installation" |
| 76 | + run: "gz sim --versions" |
| 77 | + |
| 78 | + - name: Setup Python dependencies |
| 79 | + run: | |
| 80 | + python -m pip install --upgrade pip |
| 81 | + if [ -f test/requirements.txt ]; then |
| 82 | + pip install -r test/requirements.txt |
| 83 | + fi |
| 84 | + pip install pytest pytest-timeout pytest-cov |
| 85 | +
|
| 86 | + - name: Configure Gazebo for headless rendering |
| 87 | + run: | |
| 88 | + # Configure display for headless rendering |
| 89 | + echo "export GAZEBO_IP=127.0.0.1" >> $GITHUB_ENV |
| 90 | + echo "export OGRE_RTT_MODE=Copy" >> $GITHUB_ENV |
| 91 | + echo "export DISPLAY=:1" >> $GITHUB_ENV |
| 92 | +
|
| 93 | + # Configure audio to use null devices |
| 94 | + echo "export AUDIODEV=null" >> $GITHUB_ENV |
| 95 | + echo "export SDL_AUDIODRIVER=dummy" >> $GITHUB_ENV |
| 96 | +
|
| 97 | + # Create dummy ALSA config |
| 98 | + echo 'pcm.!default { type null; }' > ~/.asoundrc |
| 99 | + echo 'ctl.!default { type null; }' >> ~/.asoundrc |
| 100 | +
|
| 101 | + # Set up virtual framebuffer for visual rendering |
| 102 | + sudo apt-get install -y xvfb |
| 103 | + Xvfb :1 -screen 0 1280x1024x24 & |
| 104 | +
|
| 105 | + # Give Xvfb and audio config time to initialize |
| 106 | + sleep 3 |
| 107 | +
|
| 108 | + - name: add only Harmonic tests to ros package |
| 109 | + 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 |
| 110 | + |
| 111 | + - name: Build workspace |
| 112 | + run: | |
| 113 | + source /opt/ros/humble/setup.bash |
| 114 | + colcon build --symlink-install |
| 115 | +
|
| 116 | + - name: Rename Launch Files |
| 117 | + run: | |
| 118 | + cp install/as2_state_estimator/share/as2_state_estimator/launch/ground_truth_state_estimator.launch.py install/as2_state_estimator/share/as2_state_estimator/launch/ground_truth-state_estimator.launch.py |
| 119 | + cp install/as2_motion_controller/share/as2_motion_controller/launch/pid_speed_controller.launch.py install/as2_motion_controller/share/as2_motion_controller/launch/pid_speed_controller-motion_controller.launch.py |
| 120 | +
|
| 121 | + - name: Run launch tests |
| 122 | + run: | |
| 123 | + source /opt/ros/humble/setup.bash |
| 124 | + source install/setup.bash |
| 125 | + colcon test --packages-select custom_robots --event-handlers console_direct+ --return-code-on-test-failure |
| 126 | +
|
| 127 | + - name: Show test results |
| 128 | + if: always() |
| 129 | + run: | |
| 130 | + colcon test-result --verbose |
0 commit comments