feat(#81): add snapshot capture for fault debugging (#119) #349
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: CI | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ubuntu:noble | |
| timeout-minutes: 60 | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Install Git | |
| run: | | |
| apt-get update | |
| apt-get install -y git | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up ROS 2 Jazzy | |
| uses: ros-tooling/[email protected] | |
| with: | |
| required-ros-distributions: jazzy | |
| - name: Install dependencies | |
| run: | | |
| apt-get update | |
| apt-get install -y clang-format clang-tidy ros-jazzy-test-msgs | |
| source /opt/ros/jazzy/setup.bash | |
| rosdep update | |
| rosdep install --from-paths src --ignore-src -r -y | |
| - name: Build packages | |
| run: | | |
| source /opt/ros/jazzy/setup.bash | |
| colcon build --symlink-install \ | |
| --cmake-args -DCMAKE_BUILD_TYPE=Release \ | |
| --event-handlers console_direct+ \ | |
| --packages-ignore test_dynmsg dynmsg_demo | |
| - name: Run linters (clang-format, clang-tidy, etc.) | |
| run: | | |
| source /opt/ros/jazzy/setup.bash | |
| source install/setup.bash | |
| colcon test --return-code-on-test-failure \ | |
| --ctest-args -L linter \ | |
| --event-handlers console_direct+ \ | |
| --packages-ignore test_dynmsg dynmsg_demo | |
| - name: Run unit and integration tests | |
| timeout-minutes: 15 | |
| run: | | |
| source /opt/ros/jazzy/setup.bash | |
| source install/setup.bash | |
| colcon test --return-code-on-test-failure \ | |
| --ctest-args -LE linter \ | |
| --event-handlers console_direct+ \ | |
| --packages-ignore test_dynmsg dynmsg_demo | |
| - name: Show test results | |
| if: always() | |
| run: colcon test-result --verbose | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: | | |
| log/ | |
| build/*/test_results/ | |
| coverage: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ubuntu:noble | |
| timeout-minutes: 30 | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Install Git | |
| run: | | |
| apt-get update | |
| apt-get install -y git | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set up ROS 2 Jazzy | |
| uses: ros-tooling/[email protected] | |
| with: | |
| required-ros-distributions: jazzy | |
| - name: Install dependencies | |
| run: | | |
| apt-get update | |
| apt-get install -y lcov ros-jazzy-test-msgs | |
| source /opt/ros/jazzy/setup.bash | |
| rosdep update | |
| rosdep install --from-paths src --ignore-src -r -y | |
| - name: Build packages with coverage | |
| run: | | |
| source /opt/ros/jazzy/setup.bash | |
| colcon build --symlink-install \ | |
| --cmake-args -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON \ | |
| --event-handlers console_direct+ \ | |
| --packages-ignore test_dynmsg dynmsg_demo | |
| - name: Run unit and integration tests for coverage | |
| run: | | |
| source /opt/ros/jazzy/setup.bash | |
| source install/setup.bash | |
| colcon test \ | |
| --ctest-args -LE linter \ | |
| --event-handlers console_direct+ \ | |
| --packages-ignore test_dynmsg dynmsg_demo | |
| - name: Generate coverage report | |
| run: | | |
| lcov --capture --directory build --output-file coverage.raw.info \ | |
| --ignore-errors mismatch,negative,empty,gcov | |
| if [ ! -s coverage.raw.info ] || ! grep -q 'SF:' coverage.raw.info; then | |
| echo "::error::No valid coverage data found in coverage.raw.info" | |
| exit 1 | |
| fi | |
| lcov --extract coverage.raw.info \ | |
| '*/ros2_medkit/src/*/src/*' \ | |
| '*/ros2_medkit/src/*/include/*' \ | |
| --output-file coverage.info \ | |
| --ignore-errors unused,empty | |
| if [ ! -s coverage.info ]; then | |
| echo "::error::Filtered coverage.info is empty - no source files matched" | |
| exit 1 | |
| fi | |
| lcov --list coverage.info | |
| genhtml coverage.info --output-directory coverage_html --ignore-errors source | |
| - name: Upload coverage HTML report as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage_html/ | |
| - name: Upload coverage to Codecov | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: coverage.info | |
| flags: unittests,integration | |
| name: ros2_medkit-coverage | |
| fail_ci_if_error: true | |
| verbose: true |