From 8e7e064582bf5be14e80db9f7b213ddcec1281e9 Mon Sep 17 00:00:00 2001 From: Jakub Delicat <109142865+delihus@users.noreply.github.com> Date: Mon, 20 Jan 2025 08:34:56 +0100 Subject: [PATCH] Build fix (#5) * build fix? Signed-off-by: Jakub Delicat * unit tests on push Signed-off-by: Jakub Delicat * fix CI Signed-off-by: Jakub Delicat --------- Signed-off-by: Jakub Delicat --- .github/workflows/run-unit-tests.yaml | 93 ++++++-------------- wibotic_connector_can/cmake/SuperBuild.cmake | 7 +- 2 files changed, 31 insertions(+), 69 deletions(-) diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/run-unit-tests.yaml index 7f23a7f..647359f 100644 --- a/.github/workflows/run-unit-tests.yaml +++ b/.github/workflows/run-unit-tests.yaml @@ -2,78 +2,41 @@ name: Run unit tests on: + push: workflow_dispatch: - # TODO: ENABLE WHEN READY - # pull_request: - # branches: - # - ros2-devel jobs: - test: + build-and-test: name: Run unit tests - runs-on: self-hosted - env: - HUSARION_ROS_BUILD_TYPE: hardware - ROS_DISTRO: humble - TEST_RESULT_FILENAME: last_run_results.txt - COVERAGE_RESULT_FILENAME: coverage_results.log - steps: - - name: Prepare filesystem - working-directory: ${{ runner.temp }} - run: | - touch ${{ env.TEST_RESULT_FILENAME }} - touch ${{ env.COVERAGE_RESULT_FILENAME }} + runs-on: ubuntu-22.04 + steps: - name: Checkout repository - uses: actions/checkout@v3 - with: - ref: ${{ github.ref }} - path: ros2_ws/src/wibotic_ros - - - name: Resolve dependencies - working-directory: ros2_ws - run: | - sudo apt update - rosdep update --rosdistro $ROS_DISTRO - rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y - - - name: Build - working-directory: ros2_ws - run: | - source /opt/ros/$ROS_DISTRO/setup.bash - if [ -f install/setup.bash ]; then source install/setup.bash; fi - colcon build --symlink-install --parallel-workers $(nproc) --packages-up-to panther --cmake-args -DCMAKE_CXX_FLAGS='-fprofile-arcs -ftest-coverage' - - - name: Test - working-directory: ros2_ws - run: | - source install/setup.bash - colcon test --packages-up-to panther --retest-until-pass 10 --event-handlers console_cohesion+ --return-code-on-test-failure - echo "result=$?" >> ${{ runner.temp }}/${{ env.TEST_RESULT_FILENAME }} - colcon lcov-result --packages-up-to panther --verbose >> ${{ runner.temp }}/${{ env.COVERAGE_RESULT_FILENAME }} - lines_cov=$(cat ${{ runner.temp }}/${{ env.COVERAGE_RESULT_FILENAME }} | grep -E 'lines' | head -1) - functions_cov=$(cat ${{ runner.temp }}/${{ env.COVERAGE_RESULT_FILENAME }} | grep -E 'functions' | head -1) - branches_cov=$(cat ${{ runner.temp }}/${{ env.COVERAGE_RESULT_FILENAME }} | grep -E 'branches' | head -1) - echo "lines_cov=$lines_cov">> ${{ runner.temp }}/${{ env.TEST_RESULT_FILENAME }} - echo "functions_cov=$functions_cov" >> ${{ runner.temp }}/${{ env.TEST_RESULT_FILENAME }} - echo "branches_cov=$branches_cov" >> ${{ runner.temp }}/${{ env.TEST_RESULT_FILENAME }} - - - name: Collect unit tests output - working-directory: ${{ runner.temp }} - id: unit-tests-output - run: cat ${{ env.TEST_RESULT_FILENAME }} >> "$GITHUB_OUTPUT" + uses: actions/checkout@v4 - - name: Validate tests result - uses: nick-fields/assert-action@v1 + - name: Setup ROS + uses: ros-tooling/setup-ros@v0.7 with: - expected: 0 - actual: ${{ steps.unit-tests-output.outputs.result }} + use-ros2-testing: true - - name: Comment PR - uses: thollander/actions-comment-pull-request@v2 + - name: Build and test + uses: ros-tooling/action-ros-ci@v0.3 with: - message: | - **Test coverage of modified packages:** - ${{ steps.unit-tests-output.outputs.lines_cov }} - ${{ steps.unit-tests-output.outputs.functions_cov }} - ${{ steps.unit-tests-output.outputs.branches_cov }} + target-ros2-distro: humble + colcon-defaults: | + { + "build": { + "packages-up-to": [ + "wibotic_connector_can" + ], + "cmake-args": [ + "-DCMAKE_BUILD_TYPE=Release", + "-DTEST_INTEGRATION=OFF" + ] + }, + "test": { + "packages-up-to": [ + "wibotic_connector_can" + ] + } + } diff --git a/wibotic_connector_can/cmake/SuperBuild.cmake b/wibotic_connector_can/cmake/SuperBuild.cmake index 3676904..be054f9 100644 --- a/wibotic_connector_can/cmake/SuperBuild.cmake +++ b/wibotic_connector_can/cmake/SuperBuild.cmake @@ -14,8 +14,6 @@ include(ExternalProject) -set(DEPENDENCIES ep_libuavcan ep_platform_specific_components) - ExternalProject_Add( ep_libuavcan SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/ep_libuavcan/upstream @@ -31,6 +29,7 @@ ExternalProject_Add( ExternalProject_Add( ep_platform_specific_components + DEPENDS ep_libuavcan GIT_REPOSITORY https://github.com/OpenCyphal-Garage/platform_specific_components/ GIT_TAG 4745ef59f57b7e1c34705b127ea8c7a35e3874c1 @@ -40,13 +39,13 @@ ExternalProject_Add( INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/ep_platform_specific_components/src/ep_platform_specific_components/linux/libuavcan/include - ${CMAKE_INSTALL_PREFIX}/include ${INSTALL_DIR}) + ${CMAKE_INSTALL_PREFIX}/include) install(DIRECTORY ${INSTALL_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}) ExternalProject_Add( ep_wibotic_connector_can - DEPENDS ${DEPENDENCIES} + DEPENDS ep_platform_specific_components SOURCE_DIR ${PROJECT_SOURCE_DIR} CMAKE_ARGS -DUSE_SUPERBUILD=OFF INSTALL_COMMAND ""