Repository navigation
382 lines (362 loc) · 17.9 KB
/
Copy pathchart-test-map.yml
File metadata and controls
382 lines (362 loc) · 17.9 KB
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
name: "Test map: chart"
# The test map of the chart tests, for the change-based test selection of opp_repl (its doc/test_map.md, and its
# plan plan/pending/test-selection.md, sections 15.6 and 15.7). It runs on master after the landing job, as the chart
# tests do, and each night. A run after a landing updates the map of an earlier run: it runs the selected chart tests
# and a random sample of 5% of the other runs in coverage mode, in the environment of that map, and records what each
# run uses. A run without a map with build tables, a run by hand, and a scheduled run when master,
# omnetpp or opp_repl changed since the last full map run all chart tests with the newest omnetpp and opp_repl,
# and write a full map. The verdicts of these runs do not count: chart-tests.yml gives the verdict of master in
# release mode, and `Master green` does not wait for this workflow. The pull request job of chart-tests.yml takes the
# map from the artifact test-map-chart.
on:
workflow_run:
workflows:
- "Check: baseline masters"
types:
- completed
branches:
- master
schedule:
# each night; the run does nothing if nothing changed since the last full map
- cron: "7 3 * * *"
workflow_dispatch:
# nothing
permissions:
contents: read
# The runs of master wait for each other, and a newer run cancels a run that waits: the update of the newer run
# selects the changes from the commit of its map, so it also covers the changes of the cancelled run.
concurrency:
group: chart-test-map-${{ github.ref }}
cancel-in-progress: false
jobs:
environment:
name: Environment and test map
runs-on: ubuntu-latest
permissions:
actions: read # the test maps of the earlier runs, and the landing job of a trivial landing
contents: read
pull-requests: read
statuses: read
outputs:
# the commit of the run: the landed commit, or the head of master
commit: ${{ steps.commit.outputs.commit }}
map: ${{ steps.map.outputs.found }}
map_commit: ${{ steps.map.outputs.commit }}
# update (a run of master with a map), full, or skip (a trivial landing, or a scheduled run after which
# nothing changed)
run: ${{ steps.commits.outputs.run }}
omnetpp_commit: ${{ steps.commits.outputs.omnetpp_commit }}
opp_repl_commit: ${{ steps.commits.outputs.opp_repl_commit }}
steps:
- uses: actions/checkout@v6
with:
path: inet
# the landed commit; the head of master for a scheduled run and a run by hand
ref: ${{ github.event.workflow_run.head_sha }}
# the map commit must be an ancestor of the commit
fetch-depth: 0
filter: blob:none
persist-credentials: false
- name: Decide if the landing is trivial
id: commit
env:
GH_TOKEN: ${{ github.token }}
run: |
cd $GITHUB_WORKSPACE/inet
commit=$(git rev-parse HEAD)
echo "commit=$commit" >> $GITHUB_OUTPUT
# a trivial landing on master starts no test (M9): the job Landing of "Check: master green" decides
if [ "$GITHUB_EVENT_NAME" = workflow_run ] \
&& [ "$(python3 doc/project/enforcement/master_green.py is-trivial --commit "$commit")" = trivial ]; then
echo "trivial=true" >> $GITHUB_OUTPUT
echo "The landing of ${commit:0:10} is trivial; the run records nothing." >> $GITHUB_STEP_SUMMARY
fi
- name: Find the test map
id: map
if: github.event_name != 'schedule' && steps.commit.outputs.trivial != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
cd $GITHUB_WORKSPACE/inet
# a run of master updates the newest map, and the update needs the build tables of that map; without one,
# the run writes a full map
if ! NEED_BUILD_TABLES=true _scripts/github/get-test-map.sh chart-test-map.yml chart HEAD $RUNNER_TEMP/test-map \
> $RUNNER_TEMP/map.txt; then
echo "The search for the test map failed: the run writes a full map." >> $RUNNER_TEMP/map.txt
rm -rf $RUNNER_TEMP/test-map
echo "found=false" >> $GITHUB_OUTPUT
fi
cat $RUNNER_TEMP/map.txt >> $GITHUB_STEP_SUMMARY
cat $RUNNER_TEMP/map.txt
- name: Find the last full map
id: full
if: github.event_name == 'schedule'
env:
GH_TOKEN: ${{ github.token }}
run: |
# a scheduled run compares it with the heads
cd $GITHUB_WORKSPACE/inet
if ! FULL_ONLY=true _scripts/github/get-test-map.sh chart-test-map.yml chart HEAD $RUNNER_TEMP/full-map \
> $RUNNER_TEMP/full-map.txt; then
echo "The search for the last full map failed." >> $RUNNER_TEMP/full-map.txt
echo "found=false" >> $GITHUB_OUTPUT
fi
cat $RUNNER_TEMP/full-map.txt
- name: Select the commits of omnetpp and opp_repl
id: commits
env:
COMMIT: ${{ steps.commit.outputs.commit }}
TRIVIAL: ${{ steps.commit.outputs.trivial }}
MAP: ${{ steps.map.outputs.found }}
MAP_OMNETPP_COMMIT: ${{ steps.map.outputs.omnetpp_commit }}
MAP_OPP_REPL_COMMIT: ${{ steps.map.outputs.opp_repl_commit }}
FULL: ${{ steps.full.outputs.found }}
FULL_COMMIT: ${{ steps.full.outputs.commit }}
FULL_OMNETPP_COMMIT: ${{ steps.full.outputs.omnetpp_commit }}
FULL_OPP_REPL_COMMIT: ${{ steps.full.outputs.opp_repl_commit }}
run: |
# An update tests in the environment of its map, so that only the changes since the map can change a record
# (decision D9). A full run uses the heads of the branches, so the environment of the maps changes only in a
# full run.
omnetpp_head=$(git ls-remote https://github.com/omnetpp/omnetpp.git refs/heads/omnetpp-6.x | cut -f1)
opp_repl_head=$(git ls-remote https://github.com/omnetpp/opp_repl.git refs/heads/github_ci | cut -f1)
if [ "$TRIVIAL" = true ]; then
run=skip
elif [ "$GITHUB_EVENT_NAME" = schedule ]; then
if [ "$FULL" = true ] && [ "$FULL_COMMIT" = "$COMMIT" ] && [ "$FULL_OMNETPP_COMMIT" = "$omnetpp_head" ] \
&& [ "$FULL_OPP_REPL_COMMIT" = "$opp_repl_head" ]; then
run=skip
echo "Nothing changed since the last full map: the run records nothing." >> $GITHUB_STEP_SUMMARY
else
run=full
fi
elif [ "$GITHUB_EVENT_NAME" = workflow_run ] && [ "$MAP" = true ]; then
run=update
else
run=full
fi
if [ "$run" = update ]; then
omnetpp=$MAP_OMNETPP_COMMIT
opp_repl=$MAP_OPP_REPL_COMMIT
else
omnetpp=$omnetpp_head
opp_repl=$opp_repl_head
fi
if [ -z "$omnetpp" ] || [ -z "$opp_repl" ]; then
echo "error: no commit of omnetpp or opp_repl" >&2
exit 1
fi
echo "run=$run" >> $GITHUB_OUTPUT
echo "omnetpp_commit=$omnetpp" >> $GITHUB_OUTPUT
echo "opp_repl_commit=$opp_repl" >> $GITHUB_OUTPUT
echo "The run is a $run run. The jobs use omnetpp $omnetpp and opp_repl $opp_repl." >> $GITHUB_STEP_SUMMARY
- uses: actions/upload-artifact@v7
if: steps.commits.outputs.run == 'update'
with:
name: test-map-for-update
path: ${{ runner.temp }}/test-map
if-no-files-found: error
retention-days: 1
records:
name: Records
needs: environment
if: needs.environment.outputs.run == 'update' || needs.environment.outputs.run == 'full'
runs-on: ubuntu-latest
# The chart tests run all their simulations before a split applies, so one job runs all of them: the weekly
# coverage run needs 90 minutes for all tests, and coverage mode is about 5 times slower than release mode.
timeout-minutes: 240
env:
MODE: coverage
RUN: ${{ needs.environment.outputs.run }}
# an update tests the changes since the old map, and a sample of the other runs for check V5
CHANGES: ${{ format('{0}..HEAD', needs.environment.outputs.map_commit) }}
OPP_REPL_COMMIT: ${{ needs.environment.outputs.opp_repl_commit }}
steps:
- uses: actions/checkout@v6
with:
repository: omnetpp/omnetpp
path: omnetpp
ref: ${{ needs.environment.outputs.omnetpp_commit }}
- uses: actions/checkout@v6
with:
path: inet
ref: ${{ needs.environment.outputs.commit }}
# the selection of an update reads the changes from the map commit, and the trailer form of a baseline
# needs the history of the commit
fetch-depth: 0
filter: blob:none
persist-credentials: false
- uses: actions/download-artifact@v7
if: needs.environment.outputs.run == 'update'
with:
name: test-map-for-update
path: ${{ runner.temp }}/test-map
- run: mkdir -p /home/runner/work/ccache
- uses: actions/cache/restore@v5
with:
path: /home/runner/work/ccache
key: native-coverage-ccache-${{ github.run_id }}
# See: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
restore-keys: native-coverage-ccache
- name: Build and record
run: |
echo "::group::Installing packages"
sudo apt -o Acquire::Retries=10 update
sudo apt -o Acquire::Retries=10 install -y --no-install-recommends git wget curl ca-certificates \
make ccache clang lld gdb bison flex perl doxygen graphviz libxml2-dev zlib1g-dev \
libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libz3-dev libopenscenegraph-dev \
python3 python3-venv jq
# the profile runtime of the compiler and the LLVM tools of its version
llvm_version=$(clang -dumpversion | cut -d. -f1)
sudo apt -o Acquire::Retries=10 install -y --no-install-recommends libclang-rt-$llvm_version-dev llvm-$llvm_version
echo "::endgroup::"
source $GITHUB_WORKSPACE/inet/_scripts/github/build-omnetpp.sh
echo "::group::Compiling the scave bindings of omnetpp in release mode"
# the chart tests read the results with omnetpp.scave, which loads the bindings of the release, debug and
# sanitize modes, but not of the coverage mode
make -C $GITHUB_WORKSPACE/omnetpp MODE=release -j $(nproc) scave
echo "::endgroup::"
echo "::group::Installing opp_repl"
python3 -m venv $GITHUB_WORKSPACE/venv
source $GITHUB_WORKSPACE/venv/bin/activate
# omnetpp.scave needs these packages
python3 -m pip install -r $GITHUB_WORKSPACE/omnetpp/python/requirements.txt
python3 -m pip install "opp_repl @ git+https://github.com/omnetpp/opp_repl.git@$OPP_REPL_COMMIT"
echo "::endgroup::"
source $GITHUB_WORKSPACE/inet/_scripts/github/build-inet.sh
cd $GITHUB_WORKSPACE/inet
echo "::group::Checking out the inet charts"
opp_checkout_test_baselines --load $INET_ROOT -p inet chart
echo "::endgroup::"
# -m coverage replaces the release mode that inet.opp gives the chart tests
args=(--load $INET_ROOT -p inet -m coverage --no-build --test-map-records $RUNNER_TEMP/records)
if [ "$RUN" = update ]; then
args+=(--changes $CHANGES --test-map $RUNNER_TEMP/test-map --sample 0.05)
fi
echo "::group::Running chart tests in coverage mode"
set +e
opp_run_chart_tests "${args[@]}"
status=$?
set -e
echo "::endgroup::"
# the records give what the runs used, and not the verdicts, and some results differ in coverage mode
echo "The chart tests in coverage mode ended with the exit code $status; the verdict does not count." >> $GITHUB_STEP_SUMMARY
if [ -d $RUNNER_TEMP/records ]; then
echo "::group::Making the build tables of the test map"
# the build tables of this build go into the records, for the job Test map
opp_update_test_map --load $INET_ROOT -p inet --no-build --no-run --records $RUNNER_TEMP/records -o $RUNNER_TEMP/map-of-the-records
echo "::endgroup::"
fi
- uses: actions/upload-artifact@v7
if: always()
with:
name: test-map-records
path: ${{ runner.temp }}/records
if-no-files-found: ignore
retention-days: 7
test-map:
name: Test map
needs: [environment, records]
# also if a records job failed: the job writes no map without the records that it needs
if: >-
always() && needs.environment.result == 'success'
&& (needs.environment.outputs.run == 'update' || needs.environment.outputs.run == 'full')
runs-on: ubuntu-latest
permissions:
contents: read
actions: read # the map of the earlier run
env:
OPP_REPL_COMMIT: ${{ needs.environment.outputs.opp_repl_commit }}
RUN: ${{ needs.environment.outputs.run }}
steps:
- uses: actions/checkout@v6
with:
repository: omnetpp/omnetpp
path: omnetpp
ref: ${{ needs.environment.outputs.omnetpp_commit }}
- uses: actions/checkout@v6
with:
path: inet
ref: ${{ needs.environment.outputs.commit }}
# the update reads the changes from the commit of the old map
fetch-depth: 0
filter: blob:none
persist-credentials: false
- uses: actions/download-artifact@v7
if: needs.environment.outputs.run == 'update'
with:
name: test-map-for-update
path: ${{ runner.temp }}/old-map
- uses: actions/download-artifact@v7
# an update that selects no test has no records; the next step reports it
continue-on-error: true
with:
name: test-map-records
path: ${{ runner.temp }}/records
- name: Write the test map
id: write
run: |
echo "::group::Installing packages"
sudo apt -o Acquire::Retries=10 update
sudo apt -o Acquire::Retries=10 install -y --no-install-recommends git wget curl ca-certificates \
make ccache clang lld gdb bison flex perl doxygen graphviz libxml2-dev zlib1g-dev \
libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libz3-dev libopenscenegraph-dev \
python3 python3-venv jq
echo "::endgroup::"
# the header of the map gives the environment of the jobs: the commits, the compiler and the features
source $GITHUB_WORKSPACE/inet/_scripts/github/configure-omnetpp.sh
echo "::group::Compiling opp_nedtool"
# an update selects the changes since the old map, and the selection parses the changed NED files with
# opp_nedtool, which only the make of omnetpp gives
make -C $GITHUB_WORKSPACE/omnetpp MODE=release -j $(nproc) nedxml
echo "::endgroup::"
echo "::group::Installing opp_repl"
python3 -m venv $GITHUB_WORKSPACE/venv
source $GITHUB_WORKSPACE/venv/bin/activate
# the header of the map gives the versions of the packages that draw the charts, and an update compares
# them with the versions of the records job (rule 4.3), so this job installs the same packages
python3 -m pip install -r $GITHUB_WORKSPACE/omnetpp/python/requirements.txt
python3 -m pip install "opp_repl @ git+https://github.com/omnetpp/opp_repl.git@$OPP_REPL_COMMIT"
echo "::endgroup::"
source $GITHUB_WORKSPACE/inet/_scripts/github/configure-inet.sh
echo "::group::Checking out the inet charts"
# an update selects the changes since the old map, and rule E3 reads the chart baseline at both commits;
# without the baseline repository it selects all runs, and a run without a new record leaves the map
opp_checkout_test_baselines --load $INET_ROOT -p inet chart
echo "::endgroup::"
args=(--records $RUNNER_TEMP/records)
build_tables=$RUNNER_TEMP/records/build-tables.json.gz
if [ ! -f $build_tables ]; then
if [ "$RUN" = update ]; then
# the records job builds if the selection gives at least one test, which the sample almost always does
echo "The records job ran no test, so the run has no build tables and writes no map; the old map stays the newest map." >> $GITHUB_STEP_SUMMARY
exit 0
fi
echo "error: the records have no build tables" >&2
exit 1
fi
if [ "$RUN" = update ]; then
# the runs that the selection does not give keep the data of the old map; check V5 compares the new records
# of the sample with the old map, and the command fails after it writes the map if one differs
args+=(--update-from $RUNNER_TEMP/old-map)
fi
set +e
opp_update_test_map --load $INET_ROOT -p inet --no-build --no-run "${args[@]}" --build-tables $build_tables -o $RUNNER_TEMP/test-map
status=$?
set -e
if [ -f $RUNNER_TEMP/test-map/header.json ]; then
echo "written=true" >> $GITHUB_OUTPUT
jq . $RUNNER_TEMP/test-map/header.json
jq -r '"The map of \(.commit) has \(.runs) runs and \(.updates) updates since the full map of \(.full_commit)."' $RUNNER_TEMP/test-map/header.json >> $GITHUB_STEP_SUMMARY
fi
if [ $status != 0 ]; then
echo "The map command failed, for example because check V5 found a defect of the selection: see the log." >> $GITHUB_STEP_SUMMARY
fi
exit $status
- uses: actions/upload-artifact@v7
if: always() && steps.write.outputs.written == 'true'
with:
name: test-map-chart
path: ${{ runner.temp }}/test-map
if-no-files-found: error
retention-days: 30