Skip to content

Commit 60d4e8b

Browse files
committed
👷 Deduplicate blocks with YAML anchors
Also fixed many actionlint warnings.
1 parent be3f072 commit 60d4e8b

1 file changed

Lines changed: 60 additions & 121 deletions

File tree

‎.github/workflows/unit_tests.yml‎

Lines changed: 60 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ concurrency:
2626

2727
jobs:
2828
build_and_test_24:
29-
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
30-
strategy:
29+
runs-on: &runner ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
30+
strategy: &strategy
3131
fail-fast: false
3232
matrix:
3333
compiler: [clang, gcc]
@@ -112,20 +112,22 @@ jobs:
112112
stdlib: libc++
113113

114114
steps:
115-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
115+
- uses: &checkout actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
116116

117-
- name: Install build tools
117+
- &install_build_tools
118+
name: Install build tools
118119
run: |
119120
if [[ "${{matrix.compiler}}" == "clang" ]]; then
120-
export DISTRO=$(lsb_release -cs)
121+
distro=$(lsb_release -cs)
121122
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
122-
sudo add-apt-repository -y deb https://apt.llvm.org/$DISTRO/ llvm-toolchain-$DISTRO-${{matrix.version}} main
123+
sudo add-apt-repository -y deb "https://apt.llvm.org/$distro/" "llvm-toolchain-$distro-${{matrix.version}}" main
123124
sudo apt update && sudo apt install -y ninja-build clang-${{matrix.version}} libc++-${{matrix.version}}-dev libc++abi-${{matrix.version}}-dev
124125
else
125126
sudo apt update && sudo apt install -y ninja-build gcc-${{matrix.version}} g++-${{matrix.version}}
126127
fi
127128
128-
- name: Restore CPM cache
129+
- &restore_cpm_cache
130+
name: Restore CPM cache
129131
env:
130132
cache-name: cpm-cache-0
131133
id: cpm-cache-restore
@@ -142,7 +144,8 @@ jobs:
142144
CXX: ${{matrix.toolchain_root}}/bin/${{matrix.cxx}}
143145
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{matrix.cxx_standard}} -DCMAKE_CXX_FLAGS_INIT=${{matrix.cxx_flags}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCPM_SOURCE_CACHE=~/cpm-cache
144146

145-
- name: Save CPM cache
147+
- &save_cpm_cache
148+
name: Save CPM cache
146149
env:
147150
cache-name: cpm-cache-0
148151
if: steps.cpm-cache-restore.outputs.cache-hit != 'true'
@@ -156,57 +159,48 @@ jobs:
156159
python3 -m venv ${{github.workspace}}/test_venv
157160
source ${{github.workspace}}/test_venv/bin/activate
158161
pip install -r ${{github.workspace}}/requirements.txt
159-
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
162+
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"
160163
161164
- name: Build Unit Tests
162165
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -v -t build_unit_tests
163166

164167
- name: Test
165168
working-directory: ${{github.workspace}}/build
166-
run: ctest --output-on-failure -j $(nproc) -C ${{matrix.build_type}}
169+
run: ctest --output-on-failure -j -C ${{matrix.build_type}}
167170

168171
quality_checks_pass:
169-
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
172+
runs-on: *runner
170173
steps:
171174
- name: Checkout target branch
172-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
175+
uses: *checkout
173176
with:
174177
ref: ${{github.base_ref}}
175178

176179
- name: Extract target branch SHA
177-
run: echo "branch=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
180+
run: echo "branch=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
178181
id: target_branch
179182

180183
- name: Checkout PR branch
181-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
184+
uses: *checkout
182185

183186
- name: Setup python venv
184187
run: |
185188
python3 -m venv ${{github.workspace}}/test_venv
186189
source ${{github.workspace}}/test_venv/bin/activate
187-
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
190+
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"
188191
189192
- name: Install build tools
190193
run: |
191-
export DISTRO=$(lsb_release -cs)
194+
distro="$(lsb_release -cs)"
192195
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
193-
sudo add-apt-repository -y deb https://apt.llvm.org/$DISTRO/ llvm-toolchain-$DISTRO-${{env.DEFAULT_LLVM_VERSION}} main
196+
sudo add-apt-repository -y deb "https://apt.llvm.org/$distro/" "llvm-toolchain-$distro-${{env.DEFAULT_LLVM_VERSION}}" main
194197
sudo apt update && sudo apt install -y ninja-build clang-tidy-${{env.DEFAULT_LLVM_VERSION}} clang-format-${{env.DEFAULT_LLVM_VERSION}}
195198
196199
- name: Install cmake-format
197200
run: |
198201
pip install cmakelang pyyaml
199202
200-
- name: Restore CPM cache
201-
env:
202-
cache-name: cpm-cache-0
203-
id: cpm-cache-restore
204-
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
205-
with:
206-
path: ~/cpm-cache
207-
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
208-
restore-keys: |
209-
${{runner.os}}-${{env.cache-name}}-
203+
- *restore_cpm_cache
210204

211205
- name: Configure CMake
212206
env:
@@ -215,20 +209,13 @@ jobs:
215209
PR_TARGET_BRANCH: ${{ steps.target_branch.outputs.branch }}
216210
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache
217211

218-
- name: Save CPM cache
219-
env:
220-
cache-name: cpm-cache-0
221-
if: steps.cpm-cache-restore.outputs.cache-hit != 'true'
222-
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
223-
with:
224-
path: ~/cpm-cache
225-
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
212+
- *save_cpm_cache
226213

227214
- name: Run quality checks
228215
run: cmake --build ${{github.workspace}}/build -t ci-quality
229216

230217
sanitize:
231-
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
218+
runs-on: *runner
232219
strategy:
233220
fail-fast: false
234221
matrix:
@@ -245,29 +232,20 @@ jobs:
245232
toolchain_root: "/usr"
246233

247234
steps:
248-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
235+
- uses: *checkout
249236

250237
- name: Install build tools
251238
run: |
252239
if [[ "${{matrix.compiler}}" == "clang" ]]; then
253-
export DISTRO=$(lsb_release -cs)
240+
distro=$(lsb_release -cs)
254241
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
255-
sudo add-apt-repository -y deb https://apt.llvm.org/$DISTRO/ llvm-toolchain-$DISTRO-${{env.DEFAULT_LLVM_VERSION}} main
242+
sudo add-apt-repository -y deb "https://apt.llvm.org/$distro/" "llvm-toolchain-$distro-${{env.DEFAULT_LLVM_VERSION}}" main
256243
sudo apt update && sudo apt install -y ninja-build clang-${{env.DEFAULT_LLVM_VERSION}}
257244
else
258245
sudo apt update && sudo apt install -y ninja-build ${{matrix.cc}} ${{matrix.cxx}}
259246
fi
260247
261-
- name: Restore CPM cache
262-
env:
263-
cache-name: cpm-cache-0
264-
id: cpm-cache-restore
265-
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
266-
with:
267-
path: ~/cpm-cache
268-
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
269-
restore-keys: |
270-
${{runner.os}}-${{env.cache-name}}-
248+
- *restore_cpm_cache
271249

272250
- name: Configure CMake
273251
env:
@@ -276,21 +254,14 @@ jobs:
276254
SANITIZERS: ${{matrix.sanitizer}}
277255
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache
278256

279-
- name: Save CPM cache
280-
env:
281-
cache-name: cpm-cache-0
282-
if: steps.cpm-cache-restore.outputs.cache-hit != 'true'
283-
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
284-
with:
285-
path: ~/cpm-cache
286-
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
257+
- *save_cpm_cache
287258

288259
- name: Install python test requirements
289260
run: |
290261
python3 -m venv ${{github.workspace}}/test_venv
291262
source ${{github.workspace}}/test_venv/bin/activate
292263
pip install -r ${{github.workspace}}/requirements.txt
293-
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
264+
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"
294265
295266
# https://github.com/actions/runner-images/issues/9524
296267
- name: Fix kernel mmap rnd bits
@@ -303,93 +274,77 @@ jobs:
303274
run: cmake --build ${{github.workspace}}/build -t unit_tests
304275

305276
valgrind:
306-
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
277+
runs-on: *runner
307278
steps:
308-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
279+
- uses: *checkout
309280

310281
- name: Install build tools
311282
run: |
312283
sudo apt update && sudo apt install -y gcc-${{env.DEFAULT_GCC_VERSION}} g++-${{env.DEFAULT_GCC_VERSION}} ninja-build valgrind python3-venv python3-pip
313284
314-
- name: Restore CPM cache
315-
env:
316-
cache-name: cpm-cache-0
317-
id: cpm-cache-restore
318-
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
319-
with:
320-
path: ~/cpm-cache
321-
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
322-
restore-keys: |
323-
${{runner.os}}-${{env.cache-name}}-
285+
- *restore_cpm_cache
324286

325287
- name: Configure CMake
326288
env:
327289
CC: "/usr/bin/gcc-${{env.DEFAULT_GCC_VERSION}}"
328290
CXX: "/usr/bin/g++-${{env.DEFAULT_GCC_VERSION}}"
329291
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache
330292

331-
- name: Save CPM cache
332-
env:
333-
cache-name: cpm-cache-0
334-
if: steps.cpm-cache-restore.outputs.cache-hit != 'true'
335-
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
336-
with:
337-
path: ~/cpm-cache
338-
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
293+
- *save_cpm_cache
339294

340295
- name: Install python test requirements
341296
run: |
342297
python3 -m venv ${{github.workspace}}/test_venv
343298
source ${{github.workspace}}/test_venv/bin/activate
344299
pip install -r ${{github.workspace}}/requirements.txt
345-
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
300+
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"
346301
347302
- name: Build Unit Tests
348303
run: cmake --build ${{github.workspace}}/build -t build_unit_tests
349304

350305
- name: Test
351306
working-directory: ${{github.workspace}}/build
352307
run: |
353-
ctest --output-on-failure -j $(nproc) -E EXPECT_FAIL -T memcheck
308+
ctest --output-on-failure -j -E EXPECT_FAIL -T memcheck
354309
355-
LOGFILE=$(ls ./Testing/Temporary/LastDynamicAnalysis_*.log)
356-
FAILSIZE=$(du -c ./Testing/Temporary/MemoryChecker.* | tail -1 | cut -f1)
357-
echo "<details>" >> $GITHUB_STEP_SUMMARY
310+
LOGFILE="$(ls ./Testing/Temporary/LastDynamicAnalysis_*.log)"
311+
FAILSIZE="$(du -c ./Testing/Temporary/MemoryChecker.* | tail -1 | cut -f1)"
312+
echo "<details>" >> "$GITHUB_STEP_SUMMARY"
358313
359-
echo "<summary>" >> $GITHUB_STEP_SUMMARY
360-
if [ $FAILSIZE != "0" ]; then
361-
echo "Failing tests:" | tee -a $GITHUB_STEP_SUMMARY
314+
echo "<summary>" >> "$GITHUB_STEP_SUMMARY"
315+
if [ "$FAILSIZE" != "0" ]; then
316+
echo "Failing tests:" | tee -a "$GITHUB_STEP_SUMMARY"
362317
else
363-
echo "No failing tests" >> $GITHUB_STEP_SUMMARY
318+
echo "No failing tests" >> "$GITHUB_STEP_SUMMARY"
364319
fi
365-
echo "</summary>" >> $GITHUB_STEP_SUMMARY
320+
echo "</summary>" >> "$GITHUB_STEP_SUMMARY"
366321
367322
for f in ./Testing/Temporary/MemoryChecker.*
368323
do
369-
if [ -s $f ]; then
370-
FILENAME=$(cd $(dirname $f) && pwd)/$(basename $f)
371-
TEST_COMMAND=$(grep $FILENAME $LOGFILE)
372-
echo "" | tee -a $GITHUB_STEP_SUMMARY
324+
if [ -s "$f" ]; then
325+
FILENAME="$(realpath -- "$(dirname -- "$f")")/$(basename -- "$f")"
326+
TEST_COMMAND="$(grep "$FILENAME" "$LOGFILE")"
327+
echo "" | tee -a "$GITHUB_STEP_SUMMARY"
373328
echo "========================================"
374-
echo $TEST_COMMAND | tee -a $GITHUB_STEP_SUMMARY
329+
echo "$TEST_COMMAND" | tee -a "$GITHUB_STEP_SUMMARY"
375330
echo "--------------------"
376-
cat $f
331+
cat "$f"
377332
fi
378333
done
379334
380-
echo "</details>" >> $GITHUB_STEP_SUMMARY
381-
test $FAILSIZE = "0"
335+
echo "</details>" >> "$GITHUB_STEP_SUMMARY"
336+
test "$FAILSIZE" = "0"
382337
383338
mutate:
384-
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
339+
runs-on: *runner
385340
steps:
386-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
341+
- uses: *checkout
387342

388343
- name: Install build tools
389344
run: |
390-
export DISTRO=$(lsb_release -cs)
345+
distro=$(lsb_release -cs)
391346
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
392-
sudo add-apt-repository -y deb https://apt.llvm.org/$DISTRO/ llvm-toolchain-$DISTRO-${{env.MULL_LLVM_MAJOR_VERSION}} main
347+
sudo add-apt-repository -y deb "https://apt.llvm.org/$distro/" "llvm-toolchain-$distro-${{env.MULL_LLVM_MAJOR_VERSION}}" main
393348
sudo apt update && sudo apt install -y ninja-build clang-${{env.MULL_LLVM_MAJOR_VERSION}}
394349
395350
- name: Install mull
@@ -400,45 +355,29 @@ jobs:
400355
wget -O "$MULL_DEB" https://github.com/mull-project/mull/releases/download/${{env.MULL_VERSION}}/${{env.mull-pkg}}
401356
sudo dpkg -i "$MULL_DEB"
402357
403-
- name: Restore CPM cache
404-
env:
405-
cache-name: cpm-cache-0
406-
id: cpm-cache-restore
407-
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
408-
with:
409-
path: ~/cpm-cache
410-
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
411-
restore-keys: |
412-
${{runner.os}}-${{env.cache-name}}-
358+
- *restore_cpm_cache
413359

414360
- name: Configure CMake
415361
env:
416362
CC: "/usr/lib/llvm-${{env.MULL_LLVM_MAJOR_VERSION}}/bin/clang"
417363
CXX: "/usr/lib/llvm-${{env.MULL_LLVM_MAJOR_VERSION}}/bin/clang++"
418364
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache
419365

420-
- name: Save CPM cache
421-
env:
422-
cache-name: cpm-cache-0
423-
if: steps.cpm-cache-restore.outputs.cache-hit != 'true'
424-
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
425-
with:
426-
path: ~/cpm-cache
427-
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
366+
- *save_cpm_cache
428367

429368
- name: Install python test requirements
430369
run: |
431370
python3 -m venv ${{github.workspace}}/test_venv
432371
source ${{github.workspace}}/test_venv/bin/activate
433372
pip install -r ${{github.workspace}}/requirements.txt
434-
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
373+
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"
435374
436375
- name: Build and run mull tests
437376
run: cmake --build build -t mull_tests
438377

439378
merge_ok:
440-
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
441-
needs: [build_and_test_24, mutate, quality_checks_pass, sanitize, valgrind]
379+
runs-on: *runner
380+
needs: [build_and_test_24_cmake, build_and_test_24_meson, mutate, quality_checks_pass, sanitize, valgrind]
442381
if: ${{ !cancelled() }}
443382
steps:
444383
- name: Enable merge

0 commit comments

Comments
 (0)