From 442b57429b84a6a204cc495244f0b8d84f372f4e Mon Sep 17 00:00:00 2001 From: Clemens Linnhoff Date: Wed, 12 Jul 2023 08:55:04 +0200 Subject: [PATCH] Update pipeline (#5) * Update pipeline Signed-off-by: ClemensLinnhoff * Update readme badge Signed-off-by: ClemensLinnhoff * Fix unit and integration tests Signed-off-by: ClemensLinnhoff --------- Signed-off-by: ClemensLinnhoff --- .github/workflows/build.yml | 16 +-- .github/workflows/build_esmini.yml | 77 ++++++++++++ .github/workflows/build_openmcx.yml | 13 +- .github/workflows/build_osi_field_checker.yml | 19 ++- .github/workflows/build_tracefile_player.yml | 37 ++++-- .github/workflows/build_tracefile_writer.yml | 78 ++++++++++++ .github/workflows/cl0.yml | 5 +- .github/workflows/cl1.yml | 19 ++- .github/workflows/cl2.yml | 113 +++++++++++++++--- .github/workflows/cpp-linter.yml | 5 +- .github/workflows/credibility_assessment.yml | 21 ++++ .github/workflows/fmu_artifact.yml | 23 ++++ .github/workflows/fmu_checker.yml | 67 +++++++++++ .github/workflows/markdown.yml | 1 + .github/workflows/markdownlint.json | 5 +- .github/workflows/srmd-validator.yml | 32 +++++ .github/workflows/unit-tests.yml | 20 +++- README.md | 4 +- src/CMakeLists.txt | 16 +-- src/modelDescription.in.xml | 6 +- .../001_smoke_test/SystemStructure.ssd | 4 +- .../002_output_osi_fields/SystemStructure.ssd | 4 +- test/unit/CMakeLists.txt | 2 +- 23 files changed, 515 insertions(+), 72 deletions(-) create mode 100644 .github/workflows/build_esmini.yml create mode 100644 .github/workflows/build_tracefile_writer.yml create mode 100644 .github/workflows/credibility_assessment.yml create mode 100644 .github/workflows/fmu_artifact.yml create mode 100644 .github/workflows/fmu_checker.yml create mode 100644 .github/workflows/srmd-validator.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0eca758..7896e8c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,9 +3,6 @@ name: Build on: workflow_call: -env: - FMU_FILE_NAME: OSMPCameraSensor.fmu #TODO: Adjust to file name of your FMU - jobs: build: name: Build FMU @@ -31,7 +28,7 @@ jobs: - name: Build ProtoBuf if: steps.cache-protobuf.outputs.cache-hit != 'true' working-directory: protobuf-21.12 - run: ./configure DIST_LANG=cpp --disable-shared CXXFLAGS="-fPIC" && make + run: ./configure DIST_LANG=cpp --disable-shared CXXFLAGS="-fPIC" && make -j4 - name: Install ProtoBuf working-directory: protobuf-21.12 @@ -46,7 +43,7 @@ jobs: - name: Build C++ working-directory: build - run: cmake --build . + run: cmake --build . -j4 --config Release - name: Create FMU Directory working-directory: build @@ -54,11 +51,16 @@ jobs: - name: Copy Model FMU working-directory: build - run: cp $FMU_FILE_NAME /tmp/model_fmu/SensorModel.fmu + run: cp ${{ github.event.repository.name }}.fmu /tmp/model_fmu/${{ github.event.repository.name }}.fmu - name: Cache Model FMU id: cache-model-fmu uses: actions/cache@v3 with: path: /tmp/model_fmu - key: ${{ runner.os }}-model-fmu \ No newline at end of file + key: ${{ runner.os }}-model-fmu + + - name: Commit ID + run: | + echo "Commit ID: " + echo $(git rev-parse --short HEAD) diff --git a/.github/workflows/build_esmini.yml b/.github/workflows/build_esmini.yml new file mode 100644 index 0000000..f6af496 --- /dev/null +++ b/.github/workflows/build_esmini.yml @@ -0,0 +1,77 @@ +name: Build esmini FMU + +on: + workflow_call: + +jobs: + build_esmini: + name: Build esmini FMU + runs-on: ubuntu-latest + + steps: + - name: Cache esmini FMU + id: cache-esmini-fmu + uses: actions/cache@v3 + with: + path: /tmp/esmini_fmu + key: ${{ runner.os }}-esmini-fmu + + - name: Get esmini + if: steps.cache-esmini-fmu.outputs.cache-hit != 'true' + run: git clone https://github.com/esmini/esmini.git + + - name: Checkout dev Branch + if: steps.cache-esmini-fmu.outputs.cache-hit != 'true' + working-directory: esmini + run: git checkout dev + + - name: Update Submodules + if: steps.cache-esmini-fmu.outputs.cache-hit != 'true' + working-directory: esmini + run: git submodule update --init + + - name: Fetch Dependencies + if: steps.cache-esmini-fmu.outputs.cache-hit != 'true' + run: | + sudo apt-get update + sudo apt-get install -y build-essential gdb ninja-build git pkg-config libgl1-mesa-dev libpthread-stubs0-dev libjpeg-dev libxml2-dev libpng-dev libtiff5-dev libgdal-dev libpoppler-dev libdcmtk-dev libgtk2.0-dev libcairo2-dev libpoppler-glib-dev libxrandr-dev libxinerama-dev curl cmake + + - name: Build esmini + if: steps.cache-esmini-fmu.outputs.cache-hit != 'true' + working-directory: esmini + run: | + mkdir build + cd build + cmake .. + cmake --build . --config Release --target install -j4 + + - name: Build esmini FMU + if: steps.cache-esmini-fmu.outputs.cache-hit != 'true' + working-directory: esmini/OSMP_FMU + run: | + mkdir build + cd build + cmake .. + cmake --build . --config Release + + - name: Create esmini FMU Directory + if: steps.cache-esmini-fmu.outputs.cache-hit != 'true' + run: mkdir /tmp/esmini_fmu + + - name: Copy Commit ID to Cache + if: steps.cache-esmini-fmu.outputs.cache-hit != 'true' + working-directory: esmini + run: | + git rev-parse --short HEAD > commit-id.txt + cp commit-id.txt /tmp/esmini_fmu/commit-id.txt + + - name: Copy esmini FMU + if: steps.cache-esmini-fmu.outputs.cache-hit != 'true' + working-directory: esmini/OSMP_FMU/build + run: cp EsminiOsiSource.fmu /tmp/esmini_fmu/EsminiOsiSource.fmu + + - name: Commit ID + working-directory: /tmp/esmini_fmu + run: | + echo "Commit ID: " + echo $(cat commit-id.txt) diff --git a/.github/workflows/build_openmcx.yml b/.github/workflows/build_openmcx.yml index 49131d8..14d98c6 100644 --- a/.github/workflows/build_openmcx.yml +++ b/.github/workflows/build_openmcx.yml @@ -23,7 +23,18 @@ jobs: if: steps.cache-openmcx.outputs.cache-hit != 'true' run: git clone https://github.com/eclipse/openmcx.git + - name: Copy Commit ID to Cache + if: steps.cache-openmcx.outputs.cache-hit != 'true' + working-directory: openmcx + run: git rev-parse --short HEAD > commit-id.txt + - name: Build OpenMCx if: steps.cache-openmcx.outputs.cache-hit != 'true' working-directory: openmcx - run: ./build.sh \ No newline at end of file + run: ./build.sh + + - name: Commit ID + working-directory: openmcx + run: | + echo "Commit ID: " + echo $(cat commit-id.txt) diff --git a/.github/workflows/build_osi_field_checker.yml b/.github/workflows/build_osi_field_checker.yml index 163125e..4fa1d48 100644 --- a/.github/workflows/build_osi_field_checker.yml +++ b/.github/workflows/build_osi_field_checker.yml @@ -23,7 +23,7 @@ jobs: - name: Build ProtoBuf if: steps.cache-protobuf.outputs.cache-hit != 'true' working-directory: protobuf-21.12 - run: ./configure DIST_LANG=cpp --disable-shared CXXFLAGS="-fPIC" && make + run: ./configure DIST_LANG=cpp --disable-shared CXXFLAGS="-fPIC" && make -j4 - name: Install ProtoBuf working-directory: protobuf-21.12 @@ -53,14 +53,27 @@ jobs: - name: Build C++ if: steps.cache-osi-field-checker.outputs.cache-hit != 'true' working-directory: sl-1-5-sensor-model-testing/build - run: cmake --build . + run: cmake --build . -j4 - name: Create FMU Directory if: steps.cache-osi-field-checker.outputs.cache-hit != 'true' working-directory: sl-1-5-sensor-model-testing/build run: mkdir /tmp/osi-field-checker + - name: Copy Commit ID to Cache + if: steps.cache-osi-field-checker.outputs.cache-hit != 'true' + working-directory: sl-1-5-sensor-model-testing + run: | + git rev-parse --short HEAD > commit-id.txt + cp commit-id.txt /tmp/osi-field-checker/commit-id.txt + - name: Copy OSI Field Checker FMU if: steps.cache-osi-field-checker.outputs.cache-hit != 'true' working-directory: sl-1-5-sensor-model-testing/build - run: cp OSIFieldChecker.fmu /tmp/osi-field-checker/OSIFieldChecker.fmu \ No newline at end of file + run: cp OSIFieldChecker.fmu /tmp/osi-field-checker/OSIFieldChecker.fmu + + - name: Commit ID + working-directory: /tmp/osi-field-checker + run: | + echo "Commit ID: " + echo $(cat commit-id.txt) diff --git a/.github/workflows/build_tracefile_player.yml b/.github/workflows/build_tracefile_player.yml index c5c5b26..93109b6 100644 --- a/.github/workflows/build_tracefile_player.yml +++ b/.github/workflows/build_tracefile_player.yml @@ -29,38 +29,51 @@ jobs: working-directory: protobuf-21.12 run: sudo make install && sudo ldconfig - - name: Cache Tracefile FMU - id: cache-tracefile-fmu + - name: Cache Tracefile Player FMU + id: cache-tracefile-player-fmu uses: actions/cache@v3 with: - path: /tmp/tracefile_fmu - key: ${{ runner.os }}-tracefile-fmu + path: /tmp/tracefile_player_fmu + key: ${{ runner.os }}-tracefile-player-fmu - name: Get Tracefile Player - if: steps.cache-tracefile-fmu.outputs.cache-hit != 'true' + if: steps.cache-tracefile-player-fmu.outputs.cache-hit != 'true' run: git clone https://gitlab.com/persival-open-source/open-simulation-interface/osi-trace-file-player.git - name: Prepare C++ Build - if: steps.cache-tracefile-fmu.outputs.cache-hit != 'true' + if: steps.cache-tracefile-player-fmu.outputs.cache-hit != 'true' working-directory: osi-trace-file-player run: git submodule update --init && mkdir build - name: Configure CMake - if: steps.cache-tracefile-fmu.outputs.cache-hit != 'true' + if: steps.cache-tracefile-player-fmu.outputs.cache-hit != 'true' working-directory: osi-trace-file-player/build run: cmake -DCMAKE_PREFIX_PATH:PATH=${DEPS_DIR}/protobuf/install .. - name: Build C++ - if: steps.cache-tracefile-fmu.outputs.cache-hit != 'true' + if: steps.cache-tracefile-player-fmu.outputs.cache-hit != 'true' working-directory: osi-trace-file-player/build run: cmake --build . - name: Create FMU Directory - if: steps.cache-tracefile-fmu.outputs.cache-hit != 'true' + if: steps.cache-tracefile-player-fmu.outputs.cache-hit != 'true' working-directory: osi-trace-file-player/build - run: mkdir /tmp/tracefile_fmu + run: mkdir /tmp/tracefile_player_fmu + + - name: Copy Commit ID to Cache + if: steps.cache-tracefile-player-fmu.outputs.cache-hit != 'true' + working-directory: osi-trace-file-player + run: | + git rev-parse --short HEAD > commit-id.txt + cp commit-id.txt /tmp/tracefile_player_fmu/commit-id.txt - name: Copy Tracefile FMU - if: steps.cache-tracefile-fmu.outputs.cache-hit != 'true' + if: steps.cache-tracefile-player-fmu.outputs.cache-hit != 'true' working-directory: osi-trace-file-player/build - run: cp src/OSMPTraceFilePlayer.fmu /tmp/tracefile_fmu/OSMPTraceFilePlayer.fmu \ No newline at end of file + run: cp src/OSMPTraceFilePlayer.fmu /tmp/tracefile_player_fmu/OSMPTraceFilePlayer.fmu + + - name: Commit ID + working-directory: /tmp/tracefile_player_fmu + run: | + echo "Commit ID: " + echo $(cat commit-id.txt) diff --git a/.github/workflows/build_tracefile_writer.yml b/.github/workflows/build_tracefile_writer.yml new file mode 100644 index 0000000..c85d81d --- /dev/null +++ b/.github/workflows/build_tracefile_writer.yml @@ -0,0 +1,78 @@ +name: Build Tracefile Writer + +on: + workflow_call: + +jobs: + build_tracefile_player: + name: Build Tracefile Writer FMU + runs-on: ubuntu-latest + + steps: + - name: Cache Protobuf + id: cache-protobuf + uses: actions/cache@v3 + with: + path: protobuf-21.12 + key: ${{ runner.os }}-protobuf + + - name: Download ProtoBuf + if: steps.cache-protobuf.outputs.cache-hit != 'true' + run: curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protobuf-all-21.12.tar.gz && tar xzvf protobuf-all-21.12.tar.gz + + - name: Build ProtoBuf + if: steps.cache-protobuf.outputs.cache-hit != 'true' + working-directory: protobuf-21.12 + run: ./configure DIST_LANG=cpp --disable-shared CXXFLAGS="-fPIC" && make + + - name: Install ProtoBuf + working-directory: protobuf-21.12 + run: sudo make install && sudo ldconfig + + - name: Cache Tracefile Writer FMU + id: cache-tracefile-writer-fmu + uses: actions/cache@v3 + with: + path: /tmp/tracefile_writer_fmu + key: ${{ runner.os }}-tracefile-writer-fmu + + - name: Get Tracefile Player + if: steps.cache-tracefile-writer-fmu.outputs.cache-hit != 'true' + run: git clone https://github.com/Persival-GmbH/osi-sensordata-trace-file-writer.git + + - name: Prepare C++ Build + if: steps.cache-tracefile-writer-fmu.outputs.cache-hit != 'true' + working-directory: osi-sensordata-trace-file-writer + run: git submodule update --init && mkdir build + + - name: Configure CMake + if: steps.cache-tracefile-writer-fmu.outputs.cache-hit != 'true' + working-directory: osi-sensordata-trace-file-writer/build + run: cmake -DCMAKE_PREFIX_PATH:PATH=${DEPS_DIR}/protobuf/install .. + + - name: Build C++ + if: steps.cache-tracefile-writer-fmu.outputs.cache-hit != 'true' + working-directory: osi-sensordata-trace-file-writer/build + run: cmake --build . + + - name: Create FMU Directory + if: steps.cache-tracefile-writer-fmu.outputs.cache-hit != 'true' + run: mkdir /tmp/tracefile_writer_fmu + + - name: Copy Commit ID to Cache + if: steps.cache-tracefile-writer-fmu.outputs.cache-hit != 'true' + working-directory: osi-sensordata-trace-file-writer + run: | + git rev-parse --short HEAD > commit-id.txt + cp commit-id.txt /tmp/tracefile_writer_fmu/commit-id.txt + + - name: Copy Tracefile Writer FMU + if: steps.cache-tracefile-writer-fmu.outputs.cache-hit != 'true' + working-directory: osi-sensordata-trace-file-writer/build + run: cp osi-sensordata-trace-file-writer.fmu /tmp/tracefile_writer_fmu/osi-sensordata-trace-file-writer.fmu + + - name: Commit ID + working-directory: /tmp/tracefile_writer_fmu + run: | + echo "Commit ID: " + echo $(cat commit-id.txt) diff --git a/.github/workflows/cl0.yml b/.github/workflows/cl0.yml index a64c5ae..c60851b 100644 --- a/.github/workflows/cl0.yml +++ b/.github/workflows/cl0.yml @@ -1,10 +1,7 @@ name: Credibility Assessment Level 0 on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + workflow_call: jobs: check-spdx-headers: diff --git a/.github/workflows/cl1.yml b/.github/workflows/cl1.yml index 64cb8d2..2289979 100644 --- a/.github/workflows/cl1.yml +++ b/.github/workflows/cl1.yml @@ -1,16 +1,23 @@ name: Credibility Assessment Level 1 on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + workflow_call: jobs: build_model: name: Build Model uses: ./.github/workflows/build.yml + fmu-artifact: + needs: build_model + name: FMU Artifact + uses: ./.github/workflows/fmu_artifact.yml + + fmu-checker: + needs: build_model + name: FMU Compliance Checker + uses: ./.github/workflows/fmu_checker.yml + cpp-linter: name: C++ Linter uses: ./.github/workflows/cpp-linter.yml @@ -19,6 +26,10 @@ jobs: name: Markdown Linter uses: ./.github/workflows/markdown.yml + srmd-validator: + name: SRMD Validator + uses: ./.github/workflows/srmd-validator.yml + unit-tests: name: Unit Tests uses: ./.github/workflows/unit-tests.yml \ No newline at end of file diff --git a/.github/workflows/cl2.yml b/.github/workflows/cl2.yml index 09b0cab..912a980 100644 --- a/.github/workflows/cl2.yml +++ b/.github/workflows/cl2.yml @@ -1,20 +1,21 @@ name: Credibility Assessment Level 2 on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + workflow_call: jobs: - build_model: - name: Build Model - uses: ./.github/workflows/build.yml - build_tracefile_player: name: Build Tracefile Player FMU uses: ./.github/workflows/build_tracefile_player.yml + build_tracefile_writer: + name: Build Tracefile Writer FMU + uses: ./.github/workflows/build_tracefile_writer.yml + + build_esmini: + name: Build esmini FMU + uses: ./.github/workflows/build_esmini.yml + build_osi_field_checker_fmu: name: Build OSI Field Checker FMU uses: ./.github/workflows/build_osi_field_checker.yml @@ -38,7 +39,7 @@ jobs: matrix: ${{ steps.set-matrix.outputs.matrix }} run_integration_test: - needs: [build_model, build_tracefile_player, build_openmcx, build_osi_field_checker_fmu, generate_integration_test_paths] + needs: [build_tracefile_player, build_tracefile_writer, build_openmcx, build_osi_field_checker_fmu, build_esmini, generate_integration_test_paths] name: Integration Test runs-on: ubuntu-latest strategy: @@ -55,6 +56,13 @@ jobs: with: submodules: true + - name: Cache Protobuf + id: cache-protobuf + uses: actions/cache@v3 + with: + path: protobuf-21.12 + key: ${{ runner.os }}-protobuf + - name: Cache Model FMU id: cache-model-fmu uses: actions/cache@v3 @@ -62,12 +70,26 @@ jobs: path: /tmp/model_fmu key: ${{ runner.os }}-model-fmu - - name: Cache Tracefile FMU - id: cache-tracefile-fmu + - name: Cache Tracefile Player FMU + id: cache-tracefile-player-fmu + uses: actions/cache@v3 + with: + path: /tmp/tracefile_player_fmu + key: ${{ runner.os }}-tracefile-player-fmu + + - name: Cache Tracefile Writer FMU + id: cache-tracefile-writer-fmu uses: actions/cache@v3 with: - path: /tmp/tracefile_fmu - key: ${{ runner.os }}-tracefile-fmu + path: /tmp/tracefile_writer_fmu + key: ${{ runner.os }}-tracefile-writer-fmu + + - name: Cache esmini FMU + id: cache-esmini-fmu + uses: actions/cache@v3 + with: + path: /tmp/esmini_fmu + key: ${{ runner.os }}-esmini-fmu - name: Cache OSI Field Checker id: cache-osi-field-checker @@ -86,10 +108,73 @@ jobs: - name: Install dependencies run: sudo apt install -y libxml2-dev zlib1g-dev libzip-dev + - name: Create Output Folder + working-directory: ./test/integration/${{ matrix.path }} + run: mkdir output + - name: Run OpenMCx id: cosimulation run: ./openmcx/install/openmcx ./test/integration/${{ matrix.path }}/SystemStructure.ssd + - name: Check For Trace Files + id: check-for-trace-files + working-directory: ./test/integration/${{ matrix.path }}/output + run: | + ( count=`ls -1 *.osi 2>/dev/null | wc -l` + if [ $count == 0 ]; then + echo No trace file found. + echo "found_trace=0" >> $GITHUB_OUTPUT + elif [ $count == 1 ]; then + echo "found_trace=1" >> $GITHUB_OUTPUT + filename=$(ls -1 *.osi) + echo "trace_file_name=${filename}" >> $GITHUB_OUTPUT + else + echo More than one trace file. + echo "found_trace=0" >> $GITHUB_OUTPUT + fi + ) + + - name: Archive Trace File + if: steps.check-for-trace-files.outputs.found_trace == 1 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.check-for-trace-files.outputs.trace_file_name }} + path: ./test/integration/${{ matrix.path }}/output/${{ steps.check-for-trace-files.outputs.trace_file_name }} + + - name: Check For Python Scripts + id: check-for-python-scripts + working-directory: ./test/integration/${{ matrix.path }} + run: | + ( count=`ls -1 *.py 2>/dev/null | wc -l` + if [ $count == 0 ]; then + echo No python script found. + echo "found_script=0" >> $GITHUB_OUTPUT + elif [ $count == 1 ]; then + echo "found_script=1" >> $GITHUB_OUTPUT + filename=$(ls -1 *.py) + echo "python_file_name=${filename}" >> $GITHUB_OUTPUT + else + echo More than one trace file. + echo "found_script=0" >> $GITHUB_OUTPUT + fi + ) + + - name: Install ProtoBuf + working-directory: protobuf-21.12 + run: sudo make install && sudo ldconfig + + - name: Install Analysis Dependencies + if: steps.check-for-python-scripts.outputs.found_script == 1 + working-directory: ./lib/open-simulation-interface + run: | + python3 -m pip install protobuf==4.21.12 + python3 -m pip install . + + - name: Run Trace File Analysis + if: steps.check-for-python-scripts.outputs.found_script == 1 + working-directory: ./test/integration/${{ matrix.path }} + run: python3 ${{ steps.check-for-python-scripts.outputs.python_file_name }} output/${{ steps.check-for-trace-files.outputs.trace_file_name }} + - name: Failed? if: steps.cosimulation.outputs.failed == 1 - run: exit 1 \ No newline at end of file + run: exit 1 diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 565ffc6..acbb48f 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -5,6 +5,7 @@ on: jobs: cpp-linter: + name: C++ Linter runs-on: ubuntu-latest steps: - name: Checkout Model @@ -26,7 +27,7 @@ jobs: - name: Build ProtoBuf if: steps.cache-protobuf.outputs.cache-hit != 'true' working-directory: protobuf-21.12 - run: ./configure DIST_LANG=cpp --prefix=/usr && make + run: ./configure DIST_LANG=cpp --prefix=/usr && make -j4 - name: Install ProtoBuf working-directory: protobuf-21.12 @@ -41,7 +42,7 @@ jobs: - name: Build C++ working-directory: build - run: cmake --build . + run: cmake --build . -j4 - name: Lint CPP uses: cpp-linter/cpp-linter-action@v2 diff --git a/.github/workflows/credibility_assessment.yml b/.github/workflows/credibility_assessment.yml new file mode 100644 index 0000000..8d9a646 --- /dev/null +++ b/.github/workflows/credibility_assessment.yml @@ -0,0 +1,21 @@ +name: Credibility Assessment + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + cl0: + name: CL 0 + uses: ./.github/workflows/cl0.yml + + cl1: + name: CL 1 + uses: ./.github/workflows/cl1.yml + + cl2: + name: CL 2 + needs: cl1 + uses: ./.github/workflows/cl2.yml diff --git a/.github/workflows/fmu_artifact.yml b/.github/workflows/fmu_artifact.yml new file mode 100644 index 0000000..02a864e --- /dev/null +++ b/.github/workflows/fmu_artifact.yml @@ -0,0 +1,23 @@ +name: Archive built FMU as artifact + +on: + workflow_call: + +jobs: + fmu-artifact: + name: FMU Artifact + runs-on: ubuntu-latest + + steps: + - name: Cache Model FMU + id: cache-model-fmu + uses: actions/cache@v3 + with: + path: /tmp/model_fmu + key: ${{ runner.os }}-model-fmu + + - name: Archive built FMU + uses: actions/upload-artifact@v3 + with: + name: ${{ github.event.repository.name }} + path: /tmp/model_fmu/${{ github.event.repository.name }}.fmu diff --git a/.github/workflows/fmu_checker.yml b/.github/workflows/fmu_checker.yml new file mode 100644 index 0000000..4aa1a48 --- /dev/null +++ b/.github/workflows/fmu_checker.yml @@ -0,0 +1,67 @@ +name: FMU Compliance Checker + +on: + workflow_call: + +jobs: + fmu-compliance-checker: + name: FMU Compliance Checker + runs-on: ubuntu-latest + + steps: + - name: Cache Model FMU + id: cache-model-fmu + uses: actions/cache@v3 + with: + path: /tmp/model_fmu + key: ${{ runner.os }}-model-fmu + + - name: Cache FMUComplianceChecker + id: cache-fmu-checker + uses: actions/cache@v3 + with: + path: /tmp/FMUComplianceChecker + key: ${{ runner.os }}-fmu-checker + + - name: Get FMUComplianceChecker + if: steps.cache-fmu-checker.outputs.cache-hit != 'true' + working-directory: /tmp + run: git clone https://github.com/modelica-tools/FMUComplianceChecker.git + + - name: Build FMUComplianceChecker + if: steps.cache-fmu-checker.outputs.cache-hit != 'true' + working-directory: /tmp/FMUComplianceChecker + run: | + mkdir build + cd build + cmake .. + cmake --build . + + - name: Run FMUComplianceChecker + working-directory: /tmp/FMUComplianceChecker/build + run: ./fmuCheck.linux64 /tmp/model_fmu/${{ github.event.repository.name }}.fmu + + - name: Commit ID + working-directory: /tmp/FMUComplianceChecker + run: | + echo "Commit ID: " + echo $(git rev-parse --short HEAD) + + fmpy: + name: FMPy Validate + runs-on: ubuntu-latest + + steps: + - name: Cache Model FMU + id: cache-model-fmu + uses: actions/cache@v3 + with: + path: /tmp/model_fmu + key: ${{ runner.os }}-model-fmu + + - name: Install FMPy + run: python -m pip install fmpy[complete] + + - name: Run FMPy Validate + working-directory: /tmp/model_fmu + run: fmpy validate ${{ github.event.repository.name }}.fmu diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml index 49f2f43..6c3dd4d 100644 --- a/.github/workflows/markdown.yml +++ b/.github/workflows/markdown.yml @@ -5,6 +5,7 @@ on: jobs: markdown-lint: + name: Markdown Linter runs-on: ubuntu-latest steps: - name: checkout diff --git a/.github/workflows/markdownlint.json b/.github/workflows/markdownlint.json index ed21b0c..42f10ae 100644 --- a/.github/workflows/markdownlint.json +++ b/.github/workflows/markdownlint.json @@ -6,13 +6,14 @@ "MD013": { "code_blocks": false, "tables": false, - "line_length": 200 + "line_length": 300 }, "MD033": { "allowed_elements": [ "a", "br", - "img" + "img", + "sup" ] } } diff --git a/.github/workflows/srmd-validator.yml b/.github/workflows/srmd-validator.yml new file mode 100644 index 0000000..86d86fe --- /dev/null +++ b/.github/workflows/srmd-validator.yml @@ -0,0 +1,32 @@ +name: SRMD Validator + +on: + workflow_call: + +jobs: + srmd-validator: + name: SRMD Validator + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + + - name: Get Sensor Model Testing + run: git clone https://github.com/openMSL/sl-1-5-sensor-model-testing.git + + - name: Init Submodules + working-directory: sl-1-5-sensor-model-testing + run: git submodule update --init --recursive + + - name: Install Dependencies + run: pip3 install xmlschema + + - name: Validate SRMD + working-directory: sl-1-5-sensor-model-testing/src/srmd-validator + run: python3 srmd-validator.py + + - name: Commit ID + working-directory: sl-1-5-sensor-model-testing + run: | + echo "Commit ID: " + echo $(git rev-parse --short HEAD) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index a0b4807..4d1d1f8 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -5,6 +5,7 @@ on: jobs: unit-tests: + name: Unit Tests runs-on: ubuntu-latest steps: - name: Checkout Model @@ -12,6 +13,12 @@ jobs: with: submodules: true + - name: Check unit tests exist + id: check_files + uses: andstor/file-existence-action@v2 + with: + files: "test/unit" + - name: Cache Protobuf id: cache-protobuf uses: actions/cache@v3 @@ -20,28 +27,33 @@ jobs: key: ${{ runner.os }}-protobuf - name: Download ProtoBuf - if: steps.cache-protobuf.outputs.cache-hit != 'true' + if: steps.cache-protobuf.outputs.cache-hit != 'true' && steps.check_files.outputs.files_exists == 'true' run: curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protobuf-all-21.12.tar.gz && tar xzvf protobuf-all-21.12.tar.gz - name: Build ProtoBuf - if: steps.cache-protobuf.outputs.cache-hit != 'true' + if: steps.cache-protobuf.outputs.cache-hit != 'true' && steps.check_files.outputs.files_exists == 'true' working-directory: protobuf-21.12 - run: ./configure DIST_LANG=cpp --prefix=/usr && make + run: ./configure DIST_LANG=cpp --prefix=/usr && make -j4 - name: Install ProtoBuf + if: steps.check_files.outputs.files_exists == 'true' working-directory: protobuf-21.12 run: sudo make install && sudo ldconfig - name: Prepare C++ Build + if: steps.check_files.outputs.files_exists == 'true' run: mkdir build - name: Configure CMake + if: steps.check_files.outputs.files_exists == 'true' working-directory: build run: cmake -DCMAKE_PREFIX_PATH:PATH=${DEPS_DIR}/protobuf/install -DCMAKE_EXPORT_COMPILE_COMMANDS=on .. - name: Build C++ + if: steps.check_files.outputs.files_exists == 'true' working-directory: build - run: cmake --build . + run: cmake --build . -j4 - name: Run Unit Tests + if: steps.check_files.outputs.files_exists == 'true' run: build/test/unit/Google_Tests_run diff --git a/README.md b/README.md index b13a188..f5d20fb 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # SL 1-4 Object Based Camera Object Model -[![Credibility Assessment Level 0](../../actions/workflows/cl0.yml/badge.svg)](https://github.com/openMSL/sl-1-5-sensor-model-testing/blob/main/doc/test_architecture.md#cl-0-license-check) -[![Credibility Assessment Level 1](../../actions/workflows/cl1.yml/badge.svg)](https://github.com/openMSL/sl-1-5-sensor-model-testing/blob/main/doc/test_architecture.md#cl-1-code-verification) -[![Credibility Assessment Level 2](../../actions/workflows/cl2.yml/badge.svg)](https://github.com/openMSL/sl-1-5-sensor-model-testing/blob/main/doc/test_architecture.md#cl-2-qualitative-verification) +[![Credibility Assessment](../../actions/workflows/credibility_assessment.yml/badge.svg)](https://github.com/openMSL/sl-1-4-object-based-camera-object-model/actions/workflows/credibility_assessment.yml) This model is a parameterizable object based video perception sensor and tracking model using the interface OSI. The model was developed in the project SetLevel by Bosch. The model should simulate some basic video typical effects in a phenomenological way. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6f22ece..255ac4c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,13 +9,13 @@ string(MD5 FMUGUID modelDescription.in.xml) configure_file(modelDescription.in.xml modelDescription.xml @ONLY) find_package(Protobuf 2.6.1 REQUIRED) -add_library(OSMPCameraSensor SHARED OSMP.h OSMP.cpp OSMPCameraSensor.cpp OSMPCameraSensor.h ) -set_target_properties(OSMPCameraSensor PROPERTIES PREFIX "") -target_compile_definitions(OSMPCameraSensor PRIVATE "FMU_SHARED_OBJECT") +add_library(sl-1-4-object-based-camera-object-model SHARED OSMP.h OSMP.cpp OSMPCameraSensor.cpp OSMPCameraSensor.h ) +set_target_properties(sl-1-4-object-based-camera-object-model PROPERTIES PREFIX "") +target_compile_definitions(sl-1-4-object-based-camera-object-model PRIVATE "FMU_SHARED_OBJECT") if(LINK_WITH_SHARED_OSI) - target_link_libraries(OSMPCameraSensor open_simulation_interface) + target_link_libraries(sl-1-4-object-based-camera-object-model open_simulation_interface) else() - target_link_libraries(OSMPCameraSensor open_simulation_interface_pic) + target_link_libraries(sl-1-4-object-based-camera-object-model open_simulation_interface_pic) endif() if(WIN32) @@ -38,7 +38,7 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif() endif() -add_custom_command(TARGET OSMPCameraSensor +add_custom_command(TARGET sl-1-4-object-based-camera-object-model POST_BUILD COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/buildfmu" COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/sources" @@ -48,5 +48,5 @@ add_custom_command(TARGET OSMPCameraSensor COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/OSMPCameraSensor.h" "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/sources/" COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/OSMP.h" "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/sources/" COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/OSMP.cpp" "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/sources/" - COMMAND ${CMAKE_COMMAND} -E copy $ $<$:$<$:$>> "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/binaries/${FMI_BINARIES_PLATFORM}" - COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/buildfmu" ${CMAKE_COMMAND} -E tar "cfv" "${FMU_INSTALL_DIR}/OSMPCameraSensor.fmu" --format=zip "modelDescription.xml" "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/sources" "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/binaries/${FMI_BINARIES_PLATFORM}") \ No newline at end of file + COMMAND ${CMAKE_COMMAND} -E copy $ $<$:$<$:$>> "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/binaries/${FMI_BINARIES_PLATFORM}" + COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/buildfmu" ${CMAKE_COMMAND} -E tar "cfv" "${FMU_INSTALL_DIR}/sl-1-4-object-based-camera-object-model.fmu" --format=zip "modelDescription.xml" "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/sources" "${CMAKE_CURRENT_BINARY_DIR}/buildfmu/binaries/${FMI_BINARIES_PLATFORM}") \ No newline at end of file diff --git a/src/modelDescription.in.xml b/src/modelDescription.in.xml index ff675c6..25c6c76 100644 --- a/src/modelDescription.in.xml +++ b/src/modelDescription.in.xml @@ -3,14 +3,14 @@ fmiVersion="2.0" modelName="OSMP Camera Sensor FMU" guid="@FMUGUID@" - description="Demonstration C++ Sensor FMU for OSI Sensor Model Packaging" - author="PMSF" + description="Camera Model" + author="Robert Bosch GmbH" version="2.0" generationTool="PMSF Manual FMU Framework" generationDateAndTime="@FMUTIMESTAMP@" variableNamingConvention="structured"> diff --git a/test/integration/001_smoke_test/SystemStructure.ssd b/test/integration/001_smoke_test/SystemStructure.ssd index cedc891..020ccb5 100644 --- a/test/integration/001_smoke_test/SystemStructure.ssd +++ b/test/integration/001_smoke_test/SystemStructure.ssd @@ -11,7 +11,7 @@ - + @@ -41,7 +41,7 @@ - + diff --git a/test/integration/002_output_osi_fields/SystemStructure.ssd b/test/integration/002_output_osi_fields/SystemStructure.ssd index 5119816..73c0213 100644 --- a/test/integration/002_output_osi_fields/SystemStructure.ssd +++ b/test/integration/002_output_osi_fields/SystemStructure.ssd @@ -11,7 +11,7 @@ - + @@ -41,7 +41,7 @@ - + diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index e828dce..afafd48 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -8,5 +8,5 @@ include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) # 'test1.cpp tests2.cpp' are source files with tests add_executable(Google_Tests_run test.cpp) #target_link_libraries(Google_Tests_run HelloWorldSensor) -target_link_libraries(Google_Tests_run OSMPCameraSensor) +target_link_libraries(Google_Tests_run sl-1-4-object-based-camera-object-model) target_link_libraries(Google_Tests_run gtest gtest_main) \ No newline at end of file