|
| 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 | +jobs: |
| 11 | + launch-tests: |
| 12 | + runs-on: ubuntu-22.04 |
| 13 | + timeout-minutes: 30 |
| 14 | + |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + with: |
| 18 | + path: /opt/jderobot |
| 19 | + |
| 20 | + - name: Setup ROS 2 Humble |
| 21 | + uses: ros-tooling/setup-ros@v0.6 |
| 22 | + with: |
| 23 | + required-ros-distributions: humble |
| 24 | + |
| 25 | + - name: Install Gazebo and dependencies |
| 26 | + run: | |
| 27 | + sudo apt-get update |
| 28 | + sudo apt-get install -y python3-pip python3-pytest-timeout python3-pytest-cov \ |
| 29 | + ros-humble-launch-testing ros-humble-launch-testing-ament-cmake \ |
| 30 | + ros-humble-gazebo-ros-pkgs ros-humble-gazebo-ros ros-humble-xacro \ |
| 31 | + ros-humble-joint-state-publisher ros-humble-robot-state-publisher \ |
| 32 | + ros-humble-nav2-msgs ros-humble-turtlebot3* |
| 33 | + sudo apt-get install -y gazebo libgazebo-dev |
| 34 | + # Install any additional dependencies your project needs |
| 35 | +
|
| 36 | + - name: Setup Python dependencies |
| 37 | + run: | |
| 38 | + python -m pip install --upgrade pip |
| 39 | + if [ -f src/RoboticsInfrastructure/test/requirements.txt ]; then |
| 40 | + pip install -r src/RoboticsInfrastructure/test/requirements.txt |
| 41 | + fi |
| 42 | + pip install pytest pytest-timeout pytest-cov |
| 43 | +
|
| 44 | + - name: Build workspace |
| 45 | + run: | |
| 46 | + source /opt/ros/humble/setup.bash |
| 47 | + source /usr/share/gazebo/setup.sh |
| 48 | + colcon build --symlink-install --packages-up-to custom_robots |
| 49 | +
|
| 50 | + - name: Set timeout for launch tests in CMakeLists.txt |
| 51 | + run: | |
| 52 | + sed -i 's/add_launch_test(${test_file} TIMEOUT 90)/add_launch_test(${test_file} TIMEOUT 180)/g' src/RoboticsInfrastructure/CustomRobots/CMakeLists.txt |
| 53 | + # Rebuild with new timeout settings |
| 54 | + source /opt/ros/humble/setup.bash |
| 55 | + source /usr/share/gazebo/setup.sh |
| 56 | + colcon build --symlink-install --packages-select custom_robots |
| 57 | +
|
| 58 | + - name: Run launch tests |
| 59 | + run: | |
| 60 | + source /opt/ros/humble/setup.bash |
| 61 | + source /usr/share/gazebo/setup.sh |
| 62 | + source install/setup.bash |
| 63 | + colcon test --packages-select custom_robots --event-handlers console_direct+ --return-code-on-test-failure |
| 64 | +
|
| 65 | + - name: Show test results |
| 66 | + if: always() |
| 67 | + run: | |
| 68 | + colcon test-result --verbose |
| 69 | +
|
| 70 | + - name: Upload test logs |
| 71 | + if: always() |
| 72 | + uses: actions/upload-artifact@v3 |
| 73 | + with: |
| 74 | + name: test-logs |
| 75 | + path: | |
| 76 | + log/ |
| 77 | + build/custom_robots/test_results/ |
0 commit comments