|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - wip-ros-humble |
| 9 | + - fix-pr-history |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + default: |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + distro: [humble, jazzy] |
| 24 | + render_backend: [GLFW, OSMESA, DISABLE] # EGL currently removed due to issues with the local CI runners |
| 25 | + mujoco: [3.2.0] |
| 26 | + include: |
| 27 | + - distro: humble |
| 28 | + mujoco: 3.2.0 |
| 29 | + env: |
| 30 | + CCOV: true |
| 31 | + - distro: humble |
| 32 | + mujoco: 3.2.0 |
| 33 | + env: |
| 34 | + CLANG_TIDY: pedantic |
| 35 | + |
| 36 | + env: |
| 37 | + BUILDER: colcon |
| 38 | + MUJOCO_DIR: /vol/mujoco/mujoco-${{ matrix.mujoco }} # for self-hosted runners |
| 39 | + DOCKER_RUN_OPTS: -e MUJOCO_DIR=/root/mujoco/${{ matrix.mujoco }} -e DISPLAY=:99.0 |
| 40 | + DOCKER_IMAGE: ubiagni/mujoco_ros:${{ matrix.distro }}-ci |
| 41 | + |
| 42 | + # For now we have flags defined in the CMakeLists, using all flags makes the build break |
| 43 | + # I'll fix this once I find some time to do it |
| 44 | + # CXXFLAGS: -Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls |
| 45 | + CXXFLAGS: -Wwrite-strings -Wunreachable-code -Wpointer-arith # rosidl triggers this in non-user code, so let's leave it out for now -Wredundant-decls |
| 46 | + CLANG_TIDY_ARGS: --fix --fix-errors --format-style=file |
| 47 | + # UPSTREAM_WORKSPACE: .github/workflows/upstream.ros2.rosinstall |
| 48 | + # Install and start xvfb for GLFW |
| 49 | + AFTER_INIT: ${{ matrix.render_backend == 'GLFW' && 'apt-get install -qy xvfb; Xvfb :99 &' || '' }} |
| 50 | + # Pull any updates to the upstream workspace |
| 51 | + # AFTER_SETUP_UPSTREAM_WORKSPACE: vcs pull $BASEDIR/upstream_ws/src |
| 52 | + AFTER_SETUP_DOWNSTREAM_WORKSPACE: vcs pull $BASEDIR/downstream_ws/src |
| 53 | + # Clear ccache stats before and log the stats after the build |
| 54 | + AFTER_SETUP_CCACHE: ccache --zero-stats --max-size=10.0G |
| 55 | + AFTER_BUILD_TARGET_WORKSPACE: ccache --show-stats |
| 56 | + AFTER_BUILD_DOWNSTREAM_WORKSPACE: ccache --show-stats |
| 57 | + # Compile CCOV with Debug. Enable -Werror. |
| 58 | + TARGET_CMAKE_ARGS: > |
| 59 | + -DCMAKE_BUILD_TYPE=${{ matrix.env.CCOV && 'Debug' || 'Release'}} |
| 60 | + -DCMAKE_CXX_FLAGS="-Werror $CXXFLAGS${{ matrix.env.CCOV && ' --coverage -O2 -fno-omit-frame-pointer'}}" |
| 61 | + -DRENDER_BACKEND=${{ matrix.render_backend }} |
| 62 | + # UPSTREAM_CMAKE_ARGS: -DCMAKE_CXX_FLAGS= -DCMAKE_CXX_STANDARD=17 |
| 63 | + |
| 64 | + CCACHE_DIR: ${{ github.workspace }}/.ccache |
| 65 | + BASEDIR: ${{ github.workspace }}/.work |
| 66 | + CLANG_TIDY_BASE_REF: ${{ github.event_name != 'workflow_dispatch' && (github.base_ref || github.ref) || '' }} |
| 67 | + BEFORE_CLANG_TIDY_CHECKS: | |
| 68 | + # Show list of applied checks |
| 69 | + (cd $TARGET_REPO_PATH; clang-tidy --list-checks) |
| 70 | + CC: ${{ matrix.env.CLANG_TIDY && 'clang' }} |
| 71 | + CXX: ${{ matrix.env.CLANG_TIDY && 'clang++' }} |
| 72 | + CLANG_TIDY: ${{ matrix.env.CLANG_TIDY || 'false' }} |
| 73 | + CATKIN_LINT: ${{ matrix.env.CATKIN_LINT || 'false' }} |
| 74 | + CCOV: ${{ matrix.env.CCOV || 'false' }} |
| 75 | + |
| 76 | + name: "${{ matrix.distro }} mj-${{ matrix.mujoco }} ${{ matrix.render_backend }} ${{ matrix.env.CATKIN_LINT && ' + catkin_lint' || ''}}${{ matrix.env.CCOV && ' + ccov' || ''}}${{ matrix.env.CLANG_TIDY && (github.event_name != 'workflow_dispatch' && ' + clang-tidy (delta)' || ' + clang-tidy (all)') || '' }}" |
| 77 | + runs-on: ${{ matrix.render_backend == 'EGL' && matrix.distro || 'ubuntu-latest' }} |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v4 |
| 80 | + # - name: Cache upstream workspace |
| 81 | + # uses: rhaschke/cache@main |
| 82 | + # with: |
| 83 | + # path: ${{ env.BASEDIR }}/upstream_ws |
| 84 | + # key: ${{ env.CACHE_PREFIX }}-${{ github.run_id }} |
| 85 | + # restore-keys: ${{ env.CACHE_PREFIX }} |
| 86 | + # env: |
| 87 | + # GHA_CACHE_SAVE: always |
| 88 | + # CACHE_PREFIX: upstream_ws-${{ matrix.distro }}-${{ hashFiles('.github/workflows/upstream.rosinstall', '.github/workflows/ci.ros2.yaml') }} |
| 89 | + # The target directory cache doesn't include the source directory because |
| 90 | + # that comes from the checkout. See "prepare target_ws for cache" task below |
| 91 | + - name: Cache target workspace |
| 92 | + if: matrix.env.CCOV != true |
| 93 | + uses: rhaschke/cache@main |
| 94 | + with: |
| 95 | + path: ${{ env.BASEDIR }}/target_ws |
| 96 | + key: ${{ env.CACHE_PREFIX }}-${{ github.run_id }} |
| 97 | + restore-keys: ${{ env.CACHE_PREFIX }} |
| 98 | + env: |
| 99 | + GHA_CACHE_SAVE: always |
| 100 | + CACHE_PREFIX: target_ws${{ matrix.env.CCOV && '-ccov' || '' }}-${{ matrix.distro }}-${{ hashFiles('**/CMakeLists.txt', '**/package.xml', '.github/workflows/ci.ros2.yaml') }} |
| 101 | + - name: Cache ccache |
| 102 | + uses: rhaschke/cache@main |
| 103 | + with: |
| 104 | + path: ${{ env.CCACHE_DIR }} |
| 105 | + key: ${{ env.CACHE_PREFIX }}-${{ github.sha }}-${{ github.run_id }} |
| 106 | + restore-keys: | |
| 107 | + ${{ env.CACHE_PREFIX }}-${{ github.sha }} |
| 108 | + ${{ env.CACHE_PREFIX }} |
| 109 | + env: |
| 110 | + GHA_CACHE_SAVE: always |
| 111 | + CACHE_PREFIX: ccache-${{ matrix.distro }}${{ matrix.env.CCOV && '-ccov' || '' }} |
| 112 | + |
| 113 | + - id: ici |
| 114 | + name: Run industrial_ci |
| 115 | + uses: ros-industrial/industrial_ci@master |
| 116 | + |
| 117 | + - name: Upload test artifacts (on failure) |
| 118 | + uses: actions/upload-artifact@v4 |
| 119 | + if: failure() && (steps.ici.outputs.run_target_test || steps.ici.outputs.target_test_results) |
| 120 | + with: |
| 121 | + name: test-results-${{ matrix.distro }}-${{ matrix.render_backend }} |
| 122 | + path: ${{ env.BASEDIR }}/target_ws/**/test_results/**/*.xml |
| 123 | + - name: Generate codecov report |
| 124 | + uses: rhaschke/lcov-action@main |
| 125 | + if: always() && matrix.env.CCOV && steps.ici.outputs.target_test_results == '0' |
| 126 | + with: |
| 127 | + docker: ${{ matrix.render_backend != 'EGL' && '$DOCKER_IMAGE' || '' }} |
| 128 | + workdir: ${{ env.BASEDIR }}/target_ws |
| 129 | + ignore: '"*/target_ws/build/*" "*/target_ws/install/*" "*/test/*"' |
| 130 | + output: ${{ env.BASEDIR }}/target_ws/coverage-${{ matrix.distro }}-${{ matrix.render_backend }}.info |
| 131 | + - name: Upload codecov report |
| 132 | + uses: codecov/codecov-action@v5 |
| 133 | + if: always() && matrix.env.CCOV && steps.ici.outputs.target_test_results == '0' |
| 134 | + with: |
| 135 | + files: ${{ env.BASEDIR }}/target_ws/coverage-${{ matrix.distro }}-${{ matrix.render_backend }}.info |
| 136 | + - name: Upload clang-tidy changes |
| 137 | + uses: rhaschke/upload-git-patch-action@main |
| 138 | + if: always() && matrix.env.CLANG_TIDY |
| 139 | + with: |
| 140 | + name: clang-tidy |
| 141 | + path: ${{ env.BASEDIR }}/target_ws/src/$(basename $(pwd)) |
| 142 | + - name: Prepare target_ws for cache |
| 143 | + if: always() && !matrix.env.CCOV |
| 144 | + run: | |
| 145 | + du -sh ${{ env.BASEDIR }}/target_ws |
| 146 | + sudo find ${{ env.BASEDIR }}/target_ws -wholename '*/test_results/*' -delete |
| 147 | + sudo rm -rf ${{ env.BASEDIR }}/target_ws/src ${{ env.BASEDIR }}/target_ws/logs |
| 148 | + du -sh ${{ env.BASEDIR }}/target_ws |
0 commit comments