From 83c27471d1e6829da31b224dd34ccb94308007ee Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Thu, 22 Aug 2024 08:00:56 -0600 Subject: [PATCH] :construction_worker: Workflow updates - Use gcc-13 for sanitizers - Improve CPM caching - Use CI diff target for quality checks --- .github/workflows/unit_tests.yml | 74 ++++++++++++++++++++++++-------- include/stdx/ct_string.hpp | 2 +- 2 files changed, 56 insertions(+), 20 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 923245d..53cdcb8 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -14,7 +14,7 @@ env: CMAKE_GENERATOR: Ninja DEFAULT_CXX_STANDARD: 20 DEFAULT_LLVM_VERSION: 18 - DEFAULT_GCC_VERSION: 12 + DEFAULT_GCC_VERSION: 13 concurrency: group: ${{ github.head_ref || github.run_id }} @@ -125,13 +125,15 @@ jobs: sudo apt install -y ninja-build - name: Restore CPM cache + env: + cache-name: cpm-cache-0 id: cpm-cache-restore uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/cpm-cache - key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }} + key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} restore-keys: | - ${{ runner.os }}-cpm- + ${{runner.os}}-${{env.cache-name}}- - name: Configure CMake env: @@ -140,11 +142,13 @@ jobs: 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 + env: + cache-name: cpm-cache-0 if: steps.cpm-cache-restore.outputs.cache-hit != 'true' uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/cpm-cache - key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }} + key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} - name: Build Unit Tests run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -v -t build_unit_tests @@ -156,7 +160,17 @@ jobs: quality_checks_pass: runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-22.04 steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Checkout target branch + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + 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: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install build tools run: | @@ -169,29 +183,34 @@ jobs: sudo pip3 install pyyaml cmake-format - name: Restore CPM cache + env: + cache-name: cpm-cache-0 id: cpm-cache-restore uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/cpm-cache - key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }} + key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} restore-keys: | - ${{ runner.os }}-cpm- + ${{runner.os}}-${{env.cache-name}}- - 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: Save CPM cache + env: + cache-name: cpm-cache-0 if: steps.cpm-cache-restore.outputs.cache-hit != 'true' uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/cpm-cache - key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }} + key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} - name: Run quality checks - run: cmake --build ${{github.workspace}}/build -t quality + run: cmake --build ${{github.workspace}}/build -t ci-quality sanitize: runs-on: ${{ github.repository_owner == 'intel' && 'intel-' || '' }}ubuntu-22.04 @@ -207,9 +226,9 @@ jobs: install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 18 toolchain_root: "/usr/lib/llvm-18" - compiler: gcc - cc: "gcc-12" - cxx: "g++-12" - install: sudo apt update && sudo apt install -y gcc-12 + cc: "gcc-13" + cxx: "g++-13" + install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt install -y gcc-13 g++-13 toolchain_root: "/usr" steps: @@ -221,13 +240,15 @@ jobs: sudo apt install -y ninja-build - name: Restore CPM cache + env: + cache-name: cpm-cache-0 id: cpm-cache-restore uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/cpm-cache - key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }} + key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} restore-keys: | - ${{ runner.os }}-cpm- + ${{runner.os}}-${{env.cache-name}}- - name: Configure CMake env: @@ -237,11 +258,20 @@ jobs: 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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/cpm-cache - key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }} + key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} + + # 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 @@ -252,16 +282,20 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install build tools - run: sudo apt update && sudo apt install -y gcc-${{env.DEFAULT_GCC_VERSION}} ninja-build valgrind + run: | + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + sudo apt update && sudo apt install -y gcc-${{env.DEFAULT_GCC_VERSION}} g++-${{env.DEFAULT_GCC_VERSION}} ninja-build valgrind - name: Restore CPM cache + env: + cache-name: cpm-cache-0 id: cpm-cache-restore uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/cpm-cache - key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }} + key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} restore-keys: | - ${{ runner.os }}-cpm- + ${{runner.os}}-${{env.cache-name}}- - name: Configure CMake env: @@ -270,11 +304,13 @@ jobs: 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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/cpm-cache - key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }} + key: ${{runner.os}}-${{env.cache-name}}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} - name: Build Unit Tests run: cmake --build ${{github.workspace}}/build -t build_unit_tests diff --git a/include/stdx/ct_string.hpp b/include/stdx/ct_string.hpp index 9977065..70b153f 100644 --- a/include/stdx/ct_string.hpp +++ b/include/stdx/ct_string.hpp @@ -14,7 +14,7 @@ inline namespace v1 { template struct ct_string { CONSTEVAL ct_string() = default; - // NOLINTNEXTLINE(*-avoid-c-arrays, google-explicit-constructor) + // NOLINTNEXTLINE(*-avoid-c-arrays) CONSTEVAL explicit(false) ct_string(char const (&str)[N]) { for (auto i = std::size_t{}; i < N; ++i) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-*)