name: Serialization tests

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

jobs:
  serialization-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: Install RTI
        uses: ./.github/actions/install-rti
        if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
      - name: Setup ROS2
        uses: ./.github/actions/setup-ros2
      - name: Install Protobuf Ubuntu
        run: |
          sudo apt-get update
          sudo apt-get install -y libprotobuf-c-dev protobuf-c-compiler protobuf-compiler libprotobuf-dev
          npm install -g protoc-gen-js
      - name: Install LinguaFrancaBase
        run: |
          python3 -m venv .venv
          source .venv/bin/activate
          pip install LinguaFrancaBase protobuf
      - name: Run serialization tests;
        run: |
          source .venv/bin/activate
          source /opt/ros/*/setup.bash
          ./gradlew core:integrationTest --tests org.lflang.tests.serialization.SerializationTest.* core:integrationTestCodeCoverageReport
      - name: Report to CodeCov
        uses: ./.github/actions/report-code-coverage
        with:
          files: core/build/reports/jacoco/integrationTestCodeCoverageReport/integrationTestCodeCoverageReport.xml
        if: ${{ !inputs.compiler-ref }}  # i.e., if this is part of the main repo's CI
