Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 59 additions & 120 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ concurrency:

jobs:
build_and_test_24:
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
strategy:
runs-on: &runner ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
strategy: &strategy
fail-fast: false
matrix:
compiler: [clang, gcc]
Expand Down Expand Up @@ -112,20 +112,22 @@ jobs:
stdlib: libc++

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: &checkout actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install build tools
- &install_build_tools
name: Install build tools
run: |
if [[ "${{matrix.compiler}}" == "clang" ]]; then
export DISTRO=$(lsb_release -cs)
distro=$(lsb_release -cs)
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository -y deb https://apt.llvm.org/$DISTRO/ llvm-toolchain-$DISTRO-${{matrix.version}} main
sudo add-apt-repository -y deb "https://apt.llvm.org/$distro/" "llvm-toolchain-$distro-${{matrix.version}}" main
sudo apt update && sudo apt install -y ninja-build clang-${{matrix.version}} libc++-${{matrix.version}}-dev libc++abi-${{matrix.version}}-dev
else
sudo apt update && sudo apt install -y ninja-build gcc-${{matrix.version}} g++-${{matrix.version}}
fi

- name: Restore CPM cache
- &restore_cpm_cache
name: Restore CPM cache
env:
cache-name: cpm-cache-0
id: cpm-cache-restore
Expand All @@ -142,7 +144,8 @@ jobs:
CXX: ${{matrix.toolchain_root}}/bin/${{matrix.cxx}}
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

- name: Save CPM cache
- &save_cpm_cache
name: Save CPM cache
env:
cache-name: cpm-cache-0
if: steps.cpm-cache-restore.outputs.cache-hit != 'true'
Expand All @@ -156,57 +159,48 @@ jobs:
python3 -m venv ${{github.workspace}}/test_venv
source ${{github.workspace}}/test_venv/bin/activate
pip install -r ${{github.workspace}}/requirements.txt
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"

- name: Build Unit Tests
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -v -t build_unit_tests

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

quality_checks_pass:
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
runs-on: *runner
steps:
- name: Checkout target branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: *checkout
with:
ref: ${{github.base_ref}}

- name: Extract target branch SHA
run: echo "branch=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
run: echo "branch=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
id: target_branch

- name: Checkout PR branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: *checkout

- name: Setup python venv
run: |
python3 -m venv ${{github.workspace}}/test_venv
source ${{github.workspace}}/test_venv/bin/activate
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"

- name: Install build tools
run: |
export DISTRO=$(lsb_release -cs)
distro="$(lsb_release -cs)"
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository -y deb https://apt.llvm.org/$DISTRO/ llvm-toolchain-$DISTRO-${{env.DEFAULT_LLVM_VERSION}} main
sudo add-apt-repository -y deb "https://apt.llvm.org/$distro/" "llvm-toolchain-$distro-${{env.DEFAULT_LLVM_VERSION}}" main
sudo apt update && sudo apt install -y ninja-build clang-tidy-${{env.DEFAULT_LLVM_VERSION}} clang-format-${{env.DEFAULT_LLVM_VERSION}}

- name: Install cmake-format
run: |
pip install cmakelang pyyaml

- name: Restore CPM cache
env:
cache-name: cpm-cache-0
id: cpm-cache-restore
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/cpm-cache
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
restore-keys: |
${{runner.os}}-${{env.cache-name}}-
- *restore_cpm_cache

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

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

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

sanitize:
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
runs-on: *runner
strategy:
fail-fast: false
matrix:
Expand All @@ -245,29 +232,20 @@ jobs:
toolchain_root: "/usr"

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: *checkout

- name: Install build tools
run: |
if [[ "${{matrix.compiler}}" == "clang" ]]; then
export DISTRO=$(lsb_release -cs)
distro=$(lsb_release -cs)
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository -y deb https://apt.llvm.org/$DISTRO/ llvm-toolchain-$DISTRO-${{env.DEFAULT_LLVM_VERSION}} main
sudo add-apt-repository -y deb "https://apt.llvm.org/$distro/" "llvm-toolchain-$distro-${{env.DEFAULT_LLVM_VERSION}}" main
sudo apt update && sudo apt install -y ninja-build clang-${{env.DEFAULT_LLVM_VERSION}}
else
sudo apt update && sudo apt install -y ninja-build ${{matrix.cc}} ${{matrix.cxx}}
fi

- name: Restore CPM cache
env:
cache-name: cpm-cache-0
id: cpm-cache-restore
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/cpm-cache
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
restore-keys: |
${{runner.os}}-${{env.cache-name}}-
- *restore_cpm_cache

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

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

- name: Install python test requirements
run: |
python3 -m venv ${{github.workspace}}/test_venv
source ${{github.workspace}}/test_venv/bin/activate
pip install -r ${{github.workspace}}/requirements.txt
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"

# https://github.com/actions/runner-images/issues/9524
- name: Fix kernel mmap rnd bits
Expand All @@ -303,93 +274,77 @@ jobs:
run: cmake --build ${{github.workspace}}/build -t unit_tests

valgrind:
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
runs-on: *runner
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: *checkout

- name: Install build tools
run: |
sudo apt update && sudo apt install -y gcc-${{env.DEFAULT_GCC_VERSION}} g++-${{env.DEFAULT_GCC_VERSION}} ninja-build valgrind python3-venv python3-pip

- name: Restore CPM cache
env:
cache-name: cpm-cache-0
id: cpm-cache-restore
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/cpm-cache
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
restore-keys: |
${{runner.os}}-${{env.cache-name}}-
- *restore_cpm_cache

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

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

- name: Install python test requirements
run: |
python3 -m venv ${{github.workspace}}/test_venv
source ${{github.workspace}}/test_venv/bin/activate
pip install -r ${{github.workspace}}/requirements.txt
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"

- name: Build Unit Tests
run: cmake --build ${{github.workspace}}/build -t build_unit_tests

- name: Test
working-directory: ${{github.workspace}}/build
run: |
ctest --output-on-failure -j $(nproc) -E EXPECT_FAIL -T memcheck
ctest --output-on-failure -j -E EXPECT_FAIL -T memcheck

LOGFILE=$(ls ./Testing/Temporary/LastDynamicAnalysis_*.log)
FAILSIZE=$(du -c ./Testing/Temporary/MemoryChecker.* | tail -1 | cut -f1)
echo "<details>" >> $GITHUB_STEP_SUMMARY
LOGFILE="$(ls ./Testing/Temporary/LastDynamicAnalysis_*.log)"
FAILSIZE="$(du -c ./Testing/Temporary/MemoryChecker.* | tail -1 | cut -f1)"
echo "<details>" >> "$GITHUB_STEP_SUMMARY"

echo "<summary>" >> $GITHUB_STEP_SUMMARY
if [ $FAILSIZE != "0" ]; then
echo "Failing tests:" | tee -a $GITHUB_STEP_SUMMARY
echo "<summary>" >> "$GITHUB_STEP_SUMMARY"
if [ "$FAILSIZE" != "0" ]; then
echo "Failing tests:" | tee -a "$GITHUB_STEP_SUMMARY"
else
echo "No failing tests" >> $GITHUB_STEP_SUMMARY
echo "No failing tests" >> "$GITHUB_STEP_SUMMARY"
fi
echo "</summary>" >> $GITHUB_STEP_SUMMARY
echo "</summary>" >> "$GITHUB_STEP_SUMMARY"

for f in ./Testing/Temporary/MemoryChecker.*
do
if [ -s $f ]; then
FILENAME=$(cd $(dirname $f) && pwd)/$(basename $f)
TEST_COMMAND=$(grep $FILENAME $LOGFILE)
echo "" | tee -a $GITHUB_STEP_SUMMARY
if [ -s "$f" ]; then
FILENAME="$(realpath -- "$(dirname -- "$f")")/$(basename -- "$f")"
TEST_COMMAND="$(grep "$FILENAME" "$LOGFILE")"
echo "" | tee -a "$GITHUB_STEP_SUMMARY"
echo "========================================"
echo $TEST_COMMAND | tee -a $GITHUB_STEP_SUMMARY
echo "$TEST_COMMAND" | tee -a "$GITHUB_STEP_SUMMARY"
echo "--------------------"
cat $f
cat "$f"
fi
done

echo "</details>" >> $GITHUB_STEP_SUMMARY
test $FAILSIZE = "0"
echo "</details>" >> "$GITHUB_STEP_SUMMARY"
test "$FAILSIZE" = "0"

mutate:
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
runs-on: *runner
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: *checkout

- name: Install build tools
run: |
export DISTRO=$(lsb_release -cs)
distro=$(lsb_release -cs)
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository -y deb https://apt.llvm.org/$DISTRO/ llvm-toolchain-$DISTRO-${{env.MULL_LLVM_MAJOR_VERSION}} main
sudo add-apt-repository -y deb "https://apt.llvm.org/$distro/" "llvm-toolchain-$distro-${{env.MULL_LLVM_MAJOR_VERSION}}" main
sudo apt update && sudo apt install -y ninja-build clang-${{env.MULL_LLVM_MAJOR_VERSION}}

- name: Install mull
Expand All @@ -400,44 +355,28 @@ jobs:
wget -O "$MULL_DEB" https://github.com/mull-project/mull/releases/download/${{env.MULL_VERSION}}/${{env.mull-pkg}}
sudo dpkg -i "$MULL_DEB"

- name: Restore CPM cache
env:
cache-name: cpm-cache-0
id: cpm-cache-restore
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/cpm-cache
key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
restore-keys: |
${{runner.os}}-${{env.cache-name}}-
- *restore_cpm_cache

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

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

- name: Install python test requirements
run: |
python3 -m venv ${{github.workspace}}/test_venv
source ${{github.workspace}}/test_venv/bin/activate
pip install -r ${{github.workspace}}/requirements.txt
echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH
echo "${{github.workspace}}/test_venv/bin" >> "$GITHUB_PATH"

- name: Build and run mull tests
run: cmake --build build -t mull_tests

merge_ok:
runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04
runs-on: *runner
needs: [build_and_test_24, mutate, quality_checks_pass, sanitize, valgrind]
if: ${{ !cancelled() }}
steps:
Expand Down