name: ROS2 C++ tests

on:
  workflow_call:
    inputs:
      compiler-ref:
        required: false
        type: string
      runtime-ref:
        required: false
        type: string

jobs:
  cpp-ros2-tests:
    runs-on: ubuntu-24.04
    steps:
      - name: Check out lingua-franca repository
        uses: actions/checkout@v3
        with:
          repository: lf-lang/lingua-franca
          submodules: true
          ref: ${{ inputs.compiler-ref }}
          fetch-depth: 0
      - name: Prepare build environment
        uses: ./.github/actions/prepare-build-env
      - name: Check out specific ref of reactor-cpp
        uses: actions/checkout@v3
        with:
          repository: lf-lang/reactor-cpp
          path: core/src/main/resources/lib/cpp/reactor-cpp
          ref: ${{ inputs.runtime-ref }}
        if: ${{ inputs.runtime-ref }}
      - name: Setup ROS2
        uses: ./.github/actions/setup-ros2
      - name: Run C++ tests;
        run: |
          source /opt/ros/*/setup.bash
          ./gradlew targetTest -Ptarget=CppRos2
      - name: Report to CodeCov
        uses: ./.github/actions/report-code-coverage
        with:
          files: core/build/reports/jacoco/integrationTestCodeCoverageReport/integrationTestCodeCoverageReport.xml
        if: ${{ github.repository == 'lf-lang/lingua-franca' }}
