Merge pull request #380 from elbeno/advance-to-boundary #1035
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Unit Tests | |
| permissions: read-all | |
| on: | |
| workflow_dispatch: | |
| merge_group: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| CMAKE_GENERATOR: Ninja | |
| DEFAULT_CXX_STANDARD: 23 | |
| DEFAULT_LLVM_VERSION: 22 | |
| DEFAULT_GCC_VERSION: 14 | |
| MULL_LLVM_MAJOR_VERSION: 20 | |
| MULL_LLVM_VERSION: 20.1.2 | |
| MULL_VERSION: 0.34.0 | |
| HYPOTHESIS_PROFILE: default | |
| UV_CACHE_DIR: /tmp/.uv-cache | |
| PIPX_BIN_DIR: /tmp/.pipx_bin | |
| concurrency: | |
| group: ${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| build_and_test_24: | |
| runs-on: &runner ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| compiler: [clang, gcc] | |
| version: [12, 13, 14, 18, 19, 20, 21, 22] | |
| cxx_standard: [23] | |
| stdlib: [libstdc++, libc++] | |
| build_type: [Debug] | |
| include: | |
| - compiler: clang | |
| cc: "clang" | |
| cxx: "clang++" | |
| cxx_flags: "-stdlib=libstdc++" | |
| - version: 22 | |
| compiler: clang | |
| toolchain_root: "/usr/lib/llvm-22" | |
| - version: 22 | |
| compiler: clang | |
| stdlib: libc++ | |
| cxx_flags: "-stdlib=libc++" | |
| - version: 21 | |
| compiler: clang | |
| toolchain_root: "/usr/lib/llvm-21" | |
| - version: 21 | |
| compiler: clang | |
| stdlib: libc++ | |
| cxx_flags: "-stdlib=libc++" | |
| - version: 20 | |
| compiler: clang | |
| toolchain_root: "/usr/lib/llvm-20" | |
| - version: 20 | |
| compiler: clang | |
| stdlib: libc++ | |
| cxx_flags: "-stdlib=libc++" | |
| - version: 19 | |
| compiler: clang | |
| toolchain_root: "/usr/lib/llvm-19" | |
| - version: 19 | |
| compiler: clang | |
| stdlib: libc++ | |
| cxx_flags: "-stdlib=libc++" | |
| - version: 18 | |
| compiler: clang | |
| toolchain_root: "/usr/lib/llvm-18" | |
| - version: 18 | |
| compiler: clang | |
| stdlib: libc++ | |
| cxx_flags: "-stdlib=libc++" | |
| - compiler: gcc | |
| toolchain_root: "/usr" | |
| cxx_flags: "" | |
| - version: 14 | |
| compiler: gcc | |
| cc: "gcc-14" | |
| cxx: "g++-14" | |
| - version: 13 | |
| compiler: gcc | |
| cc: "gcc-13" | |
| cxx: "g++-13" | |
| - version: 12 | |
| compiler: gcc | |
| cc: "gcc-12" | |
| cxx: "g++-12" | |
| cxx_flags: "" | |
| exclude: | |
| - compiler: gcc | |
| version: 22 | |
| - compiler: gcc | |
| version: 21 | |
| - compiler: gcc | |
| version: 20 | |
| - compiler: gcc | |
| version: 19 | |
| - compiler: gcc | |
| version: 18 | |
| - compiler: clang | |
| version: 14 | |
| - compiler: clang | |
| version: 13 | |
| - compiler: clang | |
| version: 12 | |
| - compiler: gcc | |
| stdlib: libc++ | |
| steps: | |
| - uses: &checkout actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Install build tools | |
| run: | | |
| if [[ "${{matrix.compiler}}" == "clang" ]]; then | |
| 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 apt update && sudo apt install -y pipx ninja-build clang-${{matrix.version}} libc++-${{matrix.version}}-dev libc++abi-${{matrix.version}}-dev | |
| else | |
| sudo apt update && sudo apt install -y pipx ninja-build gcc-${{matrix.version}} g++-${{matrix.version}} | |
| fi | |
| - &install_uv | |
| name: Install uv | |
| run: | | |
| pipx install uv | |
| echo "$PIPX_BIN_DIR" >> "$GITHUB_PATH" | |
| - &restore_uv_cache | |
| name: Restore uv cache | |
| env: | |
| cache-name: uv-cache-0 | |
| uses: actions/cache@2c8a9bd7457de244a408f35966fab2fb45fda9c8 # v6.0.0 | |
| with: | |
| path: ${{env.UV_CACHE_DIR}} | |
| key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('uv.lock') }} | |
| restore-keys: | | |
| ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('uv.lock') }} | |
| ${{runner.os}}-${{env.cache-name}}- | |
| - &setup_python | |
| name: Setup python venv | |
| working-directory: ${{github.workspace}} | |
| run: | | |
| uv venv -c | |
| source .venv/bin/activate | |
| uv sync | |
| echo "$(pwd)/.venv/bin" >> "$GITHUB_PATH" | |
| - &restore_cpm_cache | |
| name: Restore CPM cache | |
| env: | |
| cache-name: cpm-cache-0 | |
| id: cpm-cache-restore | |
| uses: actions/cache@2c8a9bd7457de244a408f35966fab2fb45fda9c8 # v6.0.0 | |
| with: | |
| path: ~/cpm-cache | |
| key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} | |
| restore-keys: | | |
| ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} | |
| ${{runner.os}}-${{env.cache-name}}- | |
| - name: Configure CMake | |
| env: | |
| CC: ${{matrix.toolchain_root}}/bin/${{matrix.cc}} | |
| 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: 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 -C ${{matrix.build_type}} | |
| - &minimize_uv_cache | |
| name: Minimize uv cache | |
| run: uv cache prune --ci | |
| quality_checks_pass: | |
| runs-on: *runner | |
| steps: | |
| - name: Checkout target branch | |
| uses: *checkout | |
| with: | |
| ref: ${{github.base_ref}} | |
| - name: Extract target branch SHA | |
| run: echo "branch=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| id: target_branch | |
| - name: Checkout PR branch | |
| uses: *checkout | |
| - name: Install build tools | |
| run: | | |
| 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 apt update && sudo apt install -y pipx ninja-build clang-tidy-${{env.DEFAULT_LLVM_VERSION}} clang-format-${{env.DEFAULT_LLVM_VERSION}} | |
| - *install_uv | |
| - *restore_uv_cache | |
| - *setup_python | |
| - *restore_cpm_cache | |
| - name: Configure CMake | |
| env: | |
| CC: "/usr/lib/llvm-${{env.DEFAULT_LLVM_VERSION}}/bin/clang" | |
| CXX: "/usr/lib/llvm-${{env.DEFAULT_LLVM_VERSION}}/bin/clang++" | |
| 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: Run quality checks | |
| run: cmake --build ${{github.workspace}}/build -t ci-quality | |
| - *minimize_uv_cache | |
| sanitize: | |
| runs-on: *runner | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| sanitizer: [undefined, address, thread] | |
| compiler: [clang, gcc] | |
| include: | |
| - compiler: clang | |
| cc: "clang" | |
| cxx: "clang++" | |
| toolchain_root: "/usr/lib/llvm-22" | |
| - compiler: gcc | |
| cc: "gcc-14" | |
| cxx: "g++-14" | |
| toolchain_root: "/usr" | |
| steps: | |
| - uses: *checkout | |
| - name: Install build tools | |
| run: | | |
| if [[ "${{matrix.compiler}}" == "clang" ]]; then | |
| 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 apt update && sudo apt install -y pipx ninja-build clang-${{env.DEFAULT_LLVM_VERSION}} | |
| else | |
| sudo apt update && sudo apt install -y pipx ninja-build ${{matrix.cc}} ${{matrix.cxx}} | |
| fi | |
| - *install_uv | |
| - *restore_uv_cache | |
| - *setup_python | |
| - *restore_cpm_cache | |
| - name: Configure CMake | |
| env: | |
| CC: ${{matrix.toolchain_root}}/bin/${{matrix.cc}} | |
| CXX: ${{matrix.toolchain_root}}/bin/${{matrix.cxx}} | |
| SANITIZERS: ${{matrix.sanitizer}} | |
| run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=${{env.DEFAULT_CXX_STANDARD}} -DCPM_SOURCE_CACHE=~/cpm-cache | |
| # https://github.com/actions/runner-images/issues/9524 | |
| - name: Fix kernel mmap rnd bits | |
| # Asan in llvm 14 provided in ubuntu 22.04 is incompatible with | |
| # high-entropy ASLR in much newer kernels that GitHub runners are | |
| # using leading to random crashes: https://reviews.llvm.org/D148280 | |
| run: sudo sysctl vm.mmap_rnd_bits=28 | |
| - name: Build Unit Tests | |
| run: cmake --build ${{github.workspace}}/build -t unit_tests | |
| - *minimize_uv_cache | |
| valgrind: | |
| runs-on: *runner | |
| steps: | |
| - uses: *checkout | |
| - name: Install build tools | |
| run: | | |
| sudo apt update && sudo apt install -y gcc-${{env.DEFAULT_GCC_VERSION}} g++-${{env.DEFAULT_GCC_VERSION}} pipx ninja-build valgrind | |
| - *install_uv | |
| - *restore_uv_cache | |
| - *setup_python | |
| - *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: 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 -E "EXPECT_FAIL|PYTHON" -T memcheck | |
| LOGFILE=$(ls ./Testing/Temporary/LastDynamicAnalysis_*.log) | |
| FAILSIZE=$(du -c ./Testing/Temporary/MemoryChecker.* | tail -1 | cut -f1) | |
| { echo "<details>"; | |
| 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" | |
| fi | |
| echo "</summary>" >> "$GITHUB_STEP_SUMMARY" | |
| for f in ./Testing/Temporary/MemoryChecker.* | |
| do | |
| if [ -s "$f" ]; then | |
| FILENAME=$(realpath "$f") | |
| TEST_COMMAND=$(grep "$FILENAME" "$LOGFILE") | |
| echo "" | tee -a "$GITHUB_STEP_SUMMARY" | |
| echo "========================================" | |
| echo "$TEST_COMMAND" | tee -a "$GITHUB_STEP_SUMMARY" | |
| echo "--------------------" | |
| cat "$f" | |
| fi | |
| done | |
| echo "</details>" >> "$GITHUB_STEP_SUMMARY" | |
| test "$FAILSIZE" = "0" | |
| - *minimize_uv_cache | |
| mutate: | |
| runs-on: *runner | |
| steps: | |
| - uses: *checkout | |
| - name: Install build tools | |
| run: | | |
| 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 apt update && sudo apt install -y pipx ninja-build clang-${{env.MULL_LLVM_MAJOR_VERSION}} | |
| - name: Install mull | |
| env: | |
| mull-pkg: Mull-${{env.MULL_LLVM_MAJOR_VERSION}}-${{env.MULL_VERSION}}-LLVM-${{env.MULL_LLVM_VERSION}}-ubuntu-amd64-24.04.deb | |
| run: | | |
| MULL_DEB="$(mktemp)" | |
| wget -O "$MULL_DEB" https://github.com/mull-project/mull/releases/download/${{env.MULL_VERSION}}/${{env.mull-pkg}} | |
| sudo dpkg -i "$MULL_DEB" | |
| - *install_uv | |
| - *restore_uv_cache | |
| - *setup_python | |
| - *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: Build and run mull tests | |
| run: cmake --build build -t mull_tests | |
| - *minimize_uv_cache | |
| merge_ok: | |
| runs-on: *runner | |
| needs: [build_and_test_24, mutate, quality_checks_pass, sanitize, valgrind] | |
| if: ${{ !cancelled() }} | |
| steps: | |
| - name: Enable merge | |
| if: >- | |
| ${{ | |
| contains(needs.*.result, 'failure') | |
| || contains(needs.*.result, 'cancelled') | |
| || contains(needs.*.result, 'skipped') | |
| }} | |
| run: exit 1 |