|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, dev ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, dev ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + lint: |
| 11 | + name: Lint |
| 12 | + runs-on: ubuntu-latest |
| 13 | + container: |
| 14 | + image: osrf/ros:humble-desktop |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Install dependencies |
| 19 | + run: | |
| 20 | + apt-get update && apt-get install -y \ |
| 21 | + python3-pip \ |
| 22 | + python3-pytest \ |
| 23 | + python3-pytest-mock \ |
| 24 | + python3-opencv \ |
| 25 | + gstreamer1.0-tools \ |
| 26 | + gstreamer1.0-plugins-base \ |
| 27 | + gstreamer1.0-plugins-good \ |
| 28 | + gstreamer1.0-plugins-bad \ |
| 29 | + gstreamer1.0-plugins-ugly \ |
| 30 | + v4l-utils \ |
| 31 | + build-essential \ |
| 32 | + cmake \ |
| 33 | + git \ |
| 34 | + && rm -rf /var/lib/apt/lists/* |
| 35 | + |
| 36 | + - name: Setup workspace structure |
| 37 | + run: | |
| 38 | + mkdir -p ws/src |
| 39 | + cp -r camera_ros lucy_bringup ws/src/ |
| 40 | + |
| 41 | + - name: Build workspace |
| 42 | + working-directory: /__w/lucy_ros_packages/lucy_ros_packages/ws |
| 43 | + shell: bash |
| 44 | + run: | |
| 45 | + source /opt/ros/humble/setup.bash |
| 46 | + colcon build --packages-select camera_ros lucy_bringup --cmake-args -DBUILD_TESTING=ON |
| 47 | + |
| 48 | + - name: Run linters |
| 49 | + working-directory: /__w/lucy_ros_packages/lucy_ros_packages/ws |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + source /opt/ros/humble/setup.bash |
| 53 | + source install/setup.bash |
| 54 | + colcon test --packages-select camera_ros lucy_bringup --event-handlers console_direct+ || true |
| 55 | + |
| 56 | + - name: Check lint results |
| 57 | + working-directory: /__w/lucy_ros_packages/lucy_ros_packages/ws |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + source /opt/ros/humble/setup.bash |
| 61 | + source install/setup.bash |
| 62 | + colcon test-result --verbose || true |
| 63 | +
|
| 64 | + test: |
| 65 | + name: Unit Tests |
| 66 | + runs-on: ubuntu-latest |
| 67 | + container: |
| 68 | + image: osrf/ros:humble-desktop |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: Install dependencies |
| 73 | + run: | |
| 74 | + apt-get update && apt-get install -y \ |
| 75 | + python3-pip \ |
| 76 | + python3-pytest \ |
| 77 | + python3-pytest-mock \ |
| 78 | + python3-pytest-cov \ |
| 79 | + python3-opencv \ |
| 80 | + gstreamer1.0-tools \ |
| 81 | + gstreamer1.0-plugins-base \ |
| 82 | + gstreamer1.0-plugins-good \ |
| 83 | + gstreamer1.0-plugins-bad \ |
| 84 | + gstreamer1.0-plugins-ugly \ |
| 85 | + v4l-utils \ |
| 86 | + build-essential \ |
| 87 | + cmake \ |
| 88 | + git \ |
| 89 | + && rm -rf /var/lib/apt/lists/* |
| 90 | + |
| 91 | + - name: Install Python test dependencies |
| 92 | + run: | |
| 93 | + pip3 install --no-cache-dir pytest pytest-mock pytest-cov |
| 94 | + |
| 95 | + - name: Setup workspace structure |
| 96 | + run: | |
| 97 | + mkdir -p ws/src |
| 98 | + cp -r camera_ros lucy_bringup ws/src/ |
| 99 | + |
| 100 | + - name: Build workspace with tests |
| 101 | + working-directory: /__w/lucy_ros_packages/lucy_ros_packages/ws |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + source /opt/ros/humble/setup.bash |
| 105 | + colcon build --packages-select camera_ros lucy_bringup --cmake-args -DBUILD_TESTING=ON |
| 106 | + |
| 107 | + - name: Run unit tests |
| 108 | + working-directory: /__w/lucy_ros_packages/lucy_ros_packages/ws |
| 109 | + shell: bash |
| 110 | + run: | |
| 111 | + source /opt/ros/humble/setup.bash |
| 112 | + source install/setup.bash |
| 113 | + colcon test --packages-select camera_ros lucy_bringup --event-handlers console_direct+ |
| 114 | + |
| 115 | + - name: Check test results |
| 116 | + working-directory: /__w/lucy_ros_packages/lucy_ros_packages/ws |
| 117 | + shell: bash |
| 118 | + run: | |
| 119 | + source /opt/ros/humble/setup.bash |
| 120 | + source install/setup.bash |
| 121 | + colcon test-result --verbose |
| 122 | + # Fail if any tests failed |
| 123 | + if colcon test-result --verbose | grep -q "failed"; then |
| 124 | + echo "Some tests failed!" |
| 125 | + exit 1 |
| 126 | + fi |
| 127 | + |
| 128 | + - name: Generate coverage report |
| 129 | + working-directory: /__w/lucy_ros_packages/lucy_ros_packages/ws |
| 130 | + shell: bash |
| 131 | + run: | |
| 132 | + source /opt/ros/humble/setup.bash |
| 133 | + source install/setup.bash |
| 134 | + cd build/camera_ros |
| 135 | + python3 -m pytest ../../src/camera_ros/test/ \ |
| 136 | + --cov=../../src/camera_ros/scripts \ |
| 137 | + --cov-report=xml:coverage.xml \ |
| 138 | + --cov-report=html:htmlcov \ |
| 139 | + --cov-report=term-missing \ |
| 140 | + --cov-branch || true |
| 141 | + |
| 142 | + - name: Upload coverage to Codecov |
| 143 | + uses: codecov/codecov-action@v3 |
| 144 | + with: |
| 145 | + file: ${{ github.workspace }}/ws/build/camera_ros/coverage.xml |
| 146 | + flags: unittests |
| 147 | + name: codecov-umbrella |
| 148 | + fail_ci_if_error: false |
| 149 | + |
| 150 | + - name: Upload coverage HTML report |
| 151 | + uses: actions/upload-artifact@v4 |
| 152 | + if: always() |
| 153 | + with: |
| 154 | + name: coverage-report |
| 155 | + path: ${{ github.workspace }}/ws/build/camera_ros/htmlcov/ |
| 156 | + retention-days: 30 |
0 commit comments