-
Notifications
You must be signed in to change notification settings - Fork 2
245 lines (210 loc) · 8.57 KB
/
cl2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
name: Credibility Assessment Level 2
on:
workflow_call:
jobs:
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-validation:
name: Build osi-validation
uses: ./.github/workflows/build_osi-validation.yml
build_openmcx:
name: Build OpenMCx
uses: ./.github/workflows/build_openmcx.yml
generate_integration_test_paths:
runs-on: ubuntu-latest
name: Generate Integration Test Paths
steps:
- uses: actions/checkout@v4
- name: Generate matrix with all integration tests
id: set-matrix
working-directory: test/integration
run: |
echo "matrix=$(ls -l | grep '^d' | awk -F ' ' '{print $9}' | grep -Po '\d{3}.*' | jq -R -s -c 'split("\n") | map(select(length > 0))')" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
run_integration_test:
needs: [build_tracefile_player, build_tracefile_writer, build_openmcx, build_esmini, generate_integration_test_paths]
name: Integration Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
path: ${{ fromJson(needs.generate_integration_test_paths.outputs.matrix) }}
steps:
- name: Print matrix path
run: echo ${{ github.workspace }}/${{ matrix.path }}
- name: Checkout Model
uses: actions/checkout@v4
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
with:
path: /tmp/model_fmu
key: ${{ runner.os }}-model-fmu-${{ github.sha }}
- 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_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-validation
id: cache-osi-validation
uses: actions/cache@v3
with:
path: /tmp/osi-validation
key: ${{ runner.os }}-osi-validation
- name: Cache OpenMCx
id: cache-openmcx
uses: actions/cache@v3
with:
path: openmcx
key: ${{ runner.os }}-openmcx
- 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 -j4
- name: Install ProtoBuf
working-directory: protobuf-21.12
run: sudo make install && sudo ldconfig
- 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 output 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
- name: Run OpenMCx
id: cosimulation
run: ./openmcx/install/openmcx ./test/integration/${{ matrix.path }}/SystemStructure.ssd
- 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=1" >> $GITHUB_OUTPUT
zip ${{ matrix.path }}.zip *.osi
echo "trace_file_name=${{ matrix.path }}.zip" >> $GITHUB_OUTPUT
fi
)
- name: Archive Output Trace Files
if: steps.check-for-output-trace-files.outputs.found_trace == 1
uses: actions/upload-artifact@v3
with:
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 }}
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-output-trace-files.outputs.trace_file_name }}
- name: Failed?
if: steps.cosimulation.outputs.failed == 1
run: exit 1