Skip to content

Commit

Permalink
Add osi-validation to CL2 and CL3 (#82)
Browse files Browse the repository at this point in the history
* Add osi-validation to cl2
* Fix field check test, add CL3 tests and add custom rules
* Replace test trace files
* Fix input trace files
* Add sensor id and mounting position to model output
* Cache osi-validation in cl3
* Update behavior test trace file
* Remove checking out branch of osi-validation
* Update action versions
* Correct osi fields test output trace file name
* Update cache version in osi-validation build
---------

Signed-off-by: ClemensLinnhoff <Clemens.Linnhoff@partner.bmw.de>
  • Loading branch information
ClemensLinnhoff committed Jun 20, 2024
1 parent c1b838b commit 0210885
Show file tree
Hide file tree
Showing 146 changed files with 6,086 additions and 166 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build_osi-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build osi-validation

on:
workflow_call:

jobs:
build_esmini:
name: Build osi-validation
runs-on: ubuntu-latest

steps:
- name: Cache osi-validation
id: cache-osi-validation
uses: actions/cache@v4
with:
path: /tmp/osi-validation
key: ${{ runner.os }}-osi-validation

- name: Get osi-validation
if: steps.cache-osi-validation.outputs.cache-hit != 'true'
working-directory: /tmp
env:
GIT_CLONE_PROTECTION_ACTIVE: false
run: git clone https://github.com/OpenSimulationInterface/osi-validation.git

- name: Update Submodules
if: steps.cache-osi-validation.outputs.cache-hit != 'true'
working-directory: /tmp/osi-validation
run: git submodule update --init

- name: Build osi-validation
if: steps.cache-osi-validation.outputs.cache-hit != 'true'
working-directory: /tmp/osi-validation
run: |
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements_develop.txt
cd open-simulation-interface && python3 -m pip install . && cd ..
python3 -m pip install -r requirements.txt
python3 rules2yml.py -d rules
python3 -m pip install .
- name: Generate default rules
if: steps.cache-osi-validation.outputs.cache-hit != 'true'
working-directory: /tmp/osi-validation
run: |
source .venv/bin/activate
python3 rules2yml.py
- name: Add Commit ID to Cache
if: steps.cache-osi-validation.outputs.cache-hit != 'true'
working-directory: /tmp/osi-validation
run: |
git rev-parse --short HEAD > commit-id.txt
79 changes: 0 additions & 79 deletions .github/workflows/build_osi_field_checker.yml

This file was deleted.

86 changes: 69 additions & 17 deletions .github/workflows/cl2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
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
build_osi-validation:
name: Build osi-validation
uses: ./.github/workflows/build_osi-validation.yml

build_openmcx:
name: Build OpenMCx
Expand All @@ -39,7 +39,7 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

run_integration_test:
needs: [build_tracefile_player, build_tracefile_writer, build_openmcx, build_osi_field_checker_fmu, build_esmini, generate_integration_test_paths]
needs: [build_tracefile_player, build_tracefile_writer, build_osi-validation, build_openmcx, build_esmini, generate_integration_test_paths]
name: Integration Test
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -91,12 +91,12 @@ jobs:
path: /tmp/esmini_fmu
key: ${{ runner.os }}-esmini-fmu

- name: Cache OSI Field Checker
id: cache-osi-field-checker
- name: Cache osi-validation
id: cache-osi-validation
uses: actions/cache@v4
with:
path: /tmp/osi-field-checker
key: ${{ runner.os }}-osi-field-checker
path: /tmp/osi-validation
key: ${{ runner.os }}-osi-validation

- name: Cache OpenMCx
id: cache-openmcx
Expand All @@ -108,6 +108,35 @@ jobs:
- name: Install dependencies
run: sudo apt install -y libxml2-dev zlib1g-dev libzip-dev

- name: Check For Input Trace Files
id: check-for-input-trace-files
working-directory: ./test/integration/${{ matrix.path }}
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 One trace file found.
echo "found_trace=1" >> $GITHUB_OUTPUT
filename=$(ls -1 *.osi)
else
echo More than one trace file.
echo "found_trace=1" >> $GITHUB_OUTPUT
fi
)
- name: Check Input Trace Files with osi-validation and model input rules
if: steps.check-for-input-trace-files.outputs.found_trace == 1
run: |
if [ -d "./rules/input_rules" ]; then
source /tmp/osi-validation/.venv/bin/activate
for filename in ./test/integration/${{ matrix.path }}/*.osi; do
osivalidator --rules ./rules/input_rules --data ${filename}
done
else echo "No custom input rules found in ./rules/input_rules";
fi
- name: Create Output Folder
working-directory: ./test/integration/${{ matrix.path }}
run: mkdir output
Expand All @@ -116,31 +145,54 @@ jobs:
id: cosimulation
run: ./openmcx/install/openmcx ./test/integration/${{ matrix.path }}/SystemStructure.ssd

- name: Check For Trace Files
id: check-for-trace-files
- name: Check For Output Trace Files
id: check-for-output-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 One trace file found.
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
echo "found_trace=1" >> $GITHUB_OUTPUT
zip ${{ matrix.path }}.zip *.osi
echo "trace_file_name=${{ matrix.path }}.zip" >> $GITHUB_OUTPUT
fi
)
- name: Archive Trace File
if: steps.check-for-trace-files.outputs.found_trace == 1
- name: Archive Output Trace Files
if: steps.check-for-output-trace-files.outputs.found_trace == 1
uses: actions/upload-artifact@v4
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: ${{ steps.check-for-output-trace-files.outputs.trace_file_name }}
path: ./test/integration/${{ matrix.path }}/output/${{ steps.check-for-output-trace-files.outputs.trace_file_name }}

- name: Check Output Trace Files with osi-validation and default rules
if: steps.check-for-output-trace-files.outputs.found_trace == 1
working-directory: ./test/integration/${{ matrix.path }}/output
run: |
source /tmp/osi-validation/.venv/bin/activate
for filename in ./*.osi; do
osivalidator --rules /tmp/osi-validation/rules/ --data ${filename}
done
- name: Check Output Trace Files with osi-validation and model output rules
if: steps.check-for-output-trace-files.outputs.found_trace == 1
run: |
if [ -d "./rules/output_rules" ]; then
source /tmp/osi-validation/.venv/bin/activate
for filename in ./test/integration/${{ matrix.path }}/output/*.osi; do
osivalidator --rules ./rules/output_rules --data ${filename}
done
else echo "No custom output rules found in ./rules/output_rules";
fi
- name: Check For Python Scripts
id: check-for-python-scripts
working-directory: ./test/integration/${{ matrix.path }}
Expand Down Expand Up @@ -173,7 +225,7 @@ jobs:
- 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 }}
run: python3 ${{ steps.check-for-python-scripts.outputs.python_file_name }} output/${{ steps.check-for-output-trace-files.outputs.trace_file_name }}

- name: Failed?
if: steps.cosimulation.outputs.failed == 1
Expand Down
Loading

1 comment on commit 0210885

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy reports: 1 concern(s)

Have any feedback or feature suggestions? Share it here.

Please sign in to comment.