diff --git a/.github/actions/setup-cpp/action.yml b/.github/actions/setup-cpp/action.yml new file mode 100644 index 0000000..451bde8 --- /dev/null +++ b/.github/actions/setup-cpp/action.yml @@ -0,0 +1,92 @@ +# Copyright 2026 The Iris Project Contributors +# +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +name: Setup Toolchain +description: Checkout, install compiler, and fetch environment info + +inputs: + os-name: + required: true + os-version: + required: true + compiler-toolset: + required: true + compiler-version: + required: true + compiler-executable: + required: true + compiler-toolset-version: + required: false + type: string + default: '' + vs-path: + required: false + type: string + default: '' + cpp-version-name: + required: true + build-type-name: + required: true + +outputs: + compiler-full-version: + description: Full version string of the compiler + value: ${{ steps.env-info.outputs.compiler-full-version }} + deps-cache-key: + description: Cache key for CMake dependencies + value: ${{ steps.env-info.outputs.deps-cache-key }} + +runs: + using: composite + steps: + - name: Initialize Ubuntu + if: inputs.os-name == 'ubuntu' + shell: bash + run: | + sudo echo "set man-db/auto-update false" | sudo debconf-communicate + sudo dpkg-reconfigure man-db + + - name: Setup GCC + if: inputs.compiler-toolset == 'gcc' + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y g++-${{ inputs.compiler-version }} + + - name: Setup Clang + if: inputs.compiler-toolset == 'clang' + shell: bash + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x ./llvm.sh + sudo ./llvm.sh ${{ inputs.compiler-version }} + sudo apt-get install -y libc++-${{ inputs.compiler-version }}-dev libc++abi-${{ inputs.compiler-version }}-dev libunwind-${{ inputs.compiler-version }}-dev + + - uses: TheMrMilchmann/setup-msvc-dev@v3 + if: inputs.os-name == 'windows' + with: + arch: x64 + vs-path: ${{ inputs.vs-path }} + toolset: ${{ inputs.compiler-toolset-version }} + + - name: Fetch Environment Info + id: env-info + shell: bash + run: | + set -e + case "${{ inputs.compiler-toolset }}" in + "gcc") + COMPILER_FULL_VERSION=$(${{ inputs.compiler-executable }} -dumpfullversion -dumpversion) + ;; + "clang") + COMPILER_FULL_VERSION=$(${{ inputs.compiler-executable }} -dumpversion) + ;; + "msvc") + COMPILER_FULL_VERSION=$(powershell -NoProfile -Command "(Get-Command ${{ inputs.compiler-executable }}).FileVersionInfo.FileVersion") + ;; + esac + echo "COMPILER_FULL_VERSION=$COMPILER_FULL_VERSION" + echo "compiler-full-version=$COMPILER_FULL_VERSION" >> "$GITHUB_OUTPUT" + echo "deps-cache-key=deps4-${{ inputs.os-name }}-${{ inputs.os-version }}-${{ inputs.compiler-toolset }}-${COMPILER_FULL_VERSION}-${{ inputs.cpp-version-name }}-${{ inputs.build-type-name }}" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/GHA-cleanup.yml b/.github/workflows/GHA-cleanup.yml new file mode 100644 index 0000000..b5f7e1d --- /dev/null +++ b/.github/workflows/GHA-cleanup.yml @@ -0,0 +1,31 @@ +# https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manage-caches#force-deleting-cache-entries + +name: Cleanup GitHub runner caches on closed pull requests +on: + pull_request: + types: + - closed + +jobs: + cleanup: + runs-on: ubuntu-latest + permissions: + actions: write + steps: + - name: Cleanup + run: | + echo "Fetching list of cache keys" + cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id') + + ## Setting this to not fail the workflow while deleting cache keys. + set +e + echo "Deleting caches..." + for cacheKey in $cacheKeysForPR + do + gh cache delete $cacheKey + done + echo "Done" + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9f0cd7b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,198 @@ +# Copyright 2026 The Iris Project Contributors +# +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +name: Build + +on: + workflow_call: + inputs: + os-name: + required: true + type: string + os-version: + required: true + type: string + build-type-name: + required: true + type: string + cpp-version-name: + required: true + type: string + cpp-version-number: + required: true + type: string + compiler-toolset: + required: true + type: string + compiler-version: + required: true + type: string + compiler-executable: + required: true + type: string + compiler-cxxflags: + required: false + type: string + default: "" + compiler-toolset-version: + required: false + type: string + default: "" + vs-path: + required: false + type: string + default: "" + cmake-config-additional-args: + required: false + type: string + default: "" + compiler-builder-additional-args: + required: false + type: string + default: "" + components: + required: true + type: string + description: 'JSON array of components to build (e.g. ["iris", "alloy","x4"])' + +env: + IRIS_CI_BUILD_JOBS: 4 + +jobs: + prepare-deps: + name: "Dependencies" + runs-on: ${{ inputs.os-name }}-${{ inputs.os-version }} + + steps: + - uses: actions/checkout@v5 + with: + submodules: recursive + + - name: Setup Toolchain + id: setup + uses: ./.github/actions/setup-cpp + with: + os-name: ${{ inputs.os-name }} + os-version: ${{ inputs.os-version }} + compiler-toolset: ${{ inputs.compiler-toolset }} + compiler-version: ${{ inputs.compiler-version }} + compiler-executable: ${{ inputs.compiler-executable }} + compiler-toolset-version: ${{ inputs.compiler-toolset-version }} + vs-path: ${{ inputs.vs-path }} + cpp-version-name: ${{ inputs.cpp-version-name }} + build-type-name: ${{ inputs.build-type-name }} + + - name: Cache CMake Dependencies (restore) + id: cache-deps + uses: actions/cache/restore@v5 + with: + key: ${{ steps.setup.outputs.deps-cache-key }} + path: ${{ github.workspace }}/build/_deps + + # Adapt CMP0168; enable caching in CI + # https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_FULLY_DISCONNECTED + - name: Setup Cached CMake Dependencies + id: deps-info + shell: bash + run: | + if [ "${{ steps.cache-deps.outputs.cache-hit }}" = "true" ]; then + echo "IRIS_CI_CMAKE_ARGS=-DFETCHCONTENT_FULLY_DISCONNECTED=ON" >> "$GITHUB_OUTPUT" + else + echo "IRIS_CI_CMAKE_ARGS=" >> "$GITHUB_OUTPUT" + fi + + - name: Configure + env: + CLICOLOR_FORCE: 1 + shell: bash + run: | + set -xe + cmake ${{ steps.deps-info.outputs.IRIS_CI_CMAKE_ARGS }} -B build \ + ${{ inputs.cmake-config-additional-args }} \ + -DCMAKE_CXX_COMPILER=${{ inputs.compiler-executable }} \ + -DCMAKE_CXX_FLAGS="${{ inputs.compiler-cxxflags }}" \ + -DCMAKE_CXX_STANDARD=${{ inputs.cpp-version-number }} \ + -DCMAKE_BUILD_TYPE=${{ inputs.build-type-name }} \ + -DIRIS_CI=ON \ + -S . + + - name: Build Deps + env: + CLICOLOR_FORCE: 1 + run: | + cmake --build build --config ${{ inputs.build-type-name }} -j${{ env.IRIS_CI_BUILD_JOBS }} --target Catch2WithMain ${{ inputs.compiler-builder-additional-args }} + + - name: Cache CMake Dependencies (save) + # Due to some bogus "Unable to reserve cache with key" error, we *always* save the cache for now. + # See this page for the rate limit: https://docs.github.com/en/actions/reference/limits#existing-system-limits + # if: steps.cache-deps.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + key: ${{ steps.cache-deps.outputs.cache-primary-key }} + path: ${{ github.workspace }}/build/_deps + + build: + name: ${{ matrix.component }} + needs: prepare-deps + runs-on: ${{ inputs.os-name }}-${{ inputs.os-version }} + + strategy: + fail-fast: false + + matrix: + component: ${{ fromJSON(inputs.components) }} + + steps: + - uses: actions/checkout@v5 + with: + submodules: recursive + + - name: Setup Toolchain + id: setup + uses: ./.github/actions/setup-cpp + with: + os-name: ${{ inputs.os-name }} + os-version: ${{ inputs.os-version }} + compiler-toolset: ${{ inputs.compiler-toolset }} + compiler-version: ${{ inputs.compiler-version }} + compiler-executable: ${{ inputs.compiler-executable }} + cpp-version-name: ${{ inputs.cpp-version-name }} + build-type-name: ${{ inputs.build-type-name }} + + - name: Cache CMake Dependencies (restore) + id: cache-deps + uses: actions/cache/restore@v4 + with: + key: ${{ steps.setup.outputs.deps-cache-key }} + path: ${{ github.workspace }}/build/_deps + + - name: Configure + env: + CLICOLOR_FORCE: 1 + shell: bash + run: | + set -xe + cmake -DFETCHCONTENT_FULLY_DISCONNECTED=ON -B build \ + -DCMAKE_CXX_COMPILER=${{ inputs.compiler-executable }} \ + -DCMAKE_CXX_FLAGS="${{ inputs.compiler-cxxflags }}" \ + -DCMAKE_CXX_STANDARD=${{ inputs.cpp-version-number }} \ + -DCMAKE_BUILD_TYPE=${{ inputs.build-type-name }} \ + -DIRIS_CI_COMPONENT=${{ matrix.component }} \ + -DIRIS_CI=ON \ + -S . + + - name: Build Tests + env: + CLICOLOR_FORCE: 1 + shell: bash + run: | + echo "CPPWARNINGNOTIFIER_LOG_MARKER" + cmake --build build --config ${{ inputs.build-type-name }} -j${{ env.IRIS_CI_BUILD_JOBS }} ${{ inputs.compiler-builder-additional-args }} + + - name: Test + env: + CLICOLOR_FORCE: 1 + working-directory: ${{ github.workspace }}/build/test + run: ctest --output-on-failure -C ${{ inputs.build-type-name }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d585d74..5f31d64 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,9 @@ name: CI +permissions: + id-token: write + on: pull_request: push: @@ -12,14 +15,11 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - IRIS_BUILD_JOBS: 4 - jobs: changes: runs-on: ubuntu-latest outputs: - iris_component: ${{ steps.filter.outputs.changes }} + components: ${{ steps.filter.outputs.changes }} steps: - uses: actions/checkout@v5 - uses: dorny/paths-filter@v3 @@ -27,19 +27,18 @@ jobs: with: filters: | iris: - - '.github/workflows/*.yml' + - '.github/workflows/**/*.yml' + - '.github/actions/**/*.yml' - 'CMakeLists.txt' - 'include/iris/**/*' - 'test/CMakeLists.txt' - 'test/**/*' build: - name: "[${{ matrix.cpp_version.name }}] ${{ matrix.iris_component }} | ${{ matrix.compiler.toolset }}-${{ matrix.compiler.version }} (${{ matrix.build_type.name }}) @ ${{ matrix.os.name }}-${{ matrix.os.version }}" + name: "[${{ matrix.cpp_version.name }}] ${{ matrix.compiler.name }} ${{ matrix.compiler.version }} (${{ matrix.build_type.name }})" needs: changes - if: ${{ needs.changes.outputs.iris_component != '[]' && needs.changes.outputs.iris_component != '' }} - - runs-on: ${{ matrix.os.name }}-${{ matrix.os.version }} + if: ${{ needs.changes.outputs.components != '[]' && needs.changes.outputs.components != '' }} strategy: fail-fast: false @@ -50,6 +49,8 @@ jobs: version: 24.04 - name: windows version: 2022 + - name: windows + version: 2025-vs2026 build_type: - name: Debug lowercase: debug @@ -74,13 +75,31 @@ jobs: - name: MSVC toolset: msvc version: 2022 + toolset_version: 14.44 + vs-path: C:\Program Files\Microsoft Visual Studio\2022\Enterprise + cmake_config_additional_args: -G "Visual Studio 17 2022" + builder_additional_args: -- "-consoleLoggerParameters:ForceConsoleColor" + executable: cl + - name: MSVC + toolset: msvc + version: 2026 + toolset_version: 14.50 + vs-path: C:\Program Files\Microsoft Visual Studio\18\Enterprise + cmake_config_additional_args: -G "Visual Studio 18 2026" builder_additional_args: -- "-consoleLoggerParameters:ForceConsoleColor" executable: cl - - iris_component: ${{ fromJSON(needs.changes.outputs.iris_component) }} exclude: - # Blacklist all invalid combinations of environments + - os: + name: windows + version: 2022 + compiler: + version: 2026 + - os: + name: windows + version: 2025-vs2026 + compiler: + version: 2022 - os: name: windows compiler: @@ -94,97 +113,35 @@ jobs: compiler: name: MSVC + uses: ./.github/workflows/build.yml + with: + os-name: ${{ matrix.os.name }} + os-version: ${{ matrix.os.version }} + build-type-name: ${{ matrix.build_type.name }} + cpp-version-name: ${{ matrix.cpp_version.name }} + cpp-version-number: ${{ matrix.cpp_version.number }} + compiler-toolset: ${{ matrix.compiler.toolset }} + compiler-version: ${{ matrix.compiler.version }} + compiler-executable: ${{ matrix.compiler.executable }} + compiler-cxxflags: ${{ matrix.compiler.cxxflags }} + compiler-toolset-version: ${{ matrix.compiler.toolset_version }} + vs-path: ${{ matrix.compiler.vs-path }} + cmake-config-additional-args: ${{ matrix.compiler.cmake_config_additional_args }} + compiler-builder-additional-args: ${{ matrix.compiler.builder_additional_args }} + components: ${{ needs.changes.outputs.components }} + + run-notifier: + needs: build + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 - - - name: Initialize Ubuntu - if: matrix.os.name == 'ubuntu' - run: | - sudo echo "set man-db/auto-update false" | sudo debconf-communicate - sudo dpkg-reconfigure man-db - - - name: Setup GCC - if: matrix.compiler.toolset == 'gcc' - run: | - sudo apt-get update - sudo apt-get install -y g++-${{ matrix.compiler.version }} - - - name: Setup Clang - if: matrix.compiler.toolset == 'clang' - run: | - wget https://apt.llvm.org/llvm.sh - chmod +x ./llvm.sh - sudo ./llvm.sh ${{ matrix.compiler.version }} - sudo apt-get install -y libc++-${{ matrix.compiler.version }}-dev libc++abi-${{ matrix.compiler.version }}-dev libunwind-${{ matrix.compiler.version }}-dev - - - uses: TheMrMilchmann/setup-msvc-dev@v3 - if: matrix.os.name == 'windows' + - uses: actions/checkout@v6 + - uses: iris-cpp/cpp-warning-notifier@v0.7.0 with: - arch: x64 - - - name: Fetch Environment Info - id: env-info - shell: bash - run: | - set -e - case "${{ matrix.compiler.toolset }}" in - "gcc") - COMPILER_FULL_VERSION=$(${{ matrix.compiler.executable }} -dumpfullversion -dumpversion) - ;; - "clang") - COMPILER_FULL_VERSION=$(${{ matrix.compiler.executable }} -dumpversion) - ;; - "msvc") - COMPILER_FULL_VERSION=$(powershell -NoProfile -Command "(Get-Command ${{ matrix.compiler.executable }}).FileVersionInfo.FileVersion") - ;; - esac - echo "COMPILER_FULL_VERSION=$COMPILER_FULL_VERSION" - echo "compiler-full-version=$COMPILER_FULL_VERSION" >> "$GITHUB_OUTPUT" - - - name: Cache CMake Dependencies (restore) - id: cache-deps - uses: actions/cache/restore@v4 - with: - key: deps-${{ matrix.os.name }}-${{ matrix.os.version }}-${{ matrix.compiler.toolset }}-${{ steps.env-info.outputs.compiler-full-version }}-${{ matrix.cpp_version.name }}-${{ matrix.build_type.name }} - path: ${{ github.workspace }}/build/_deps - - # Adapt CMP0168; enable caching in CI - # https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_FULLY_DISCONNECTED - - name: Setup Cached CMake Dependencies - id: deps-info - shell: bash - run: | - if [ "${{ steps.cache-deps.outputs.cache-hit }}" = "true" ]; then - echo "IRIS_CMAKE_ARGS=-DFETCHCONTENT_FULLY_DISCONNECTED=ON" >> "$GITHUB_OUTPUT" - else - echo "IRIS_CMAKE_ARGS=" >> "$GITHUB_OUTPUT" - fi - - - name: Configure - shell: bash - run: | - set -xe - cmake ${{ steps.deps-info.outputs.IRIS_CMAKE_ARGS }} -B build \ - -DCMAKE_CXX_COMPILER=${{ matrix.compiler.executable }} \ - -DCMAKE_CXX_FLAGS="${{ matrix.compiler.cxxflags }}" \ - -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version.number }} \ - -DCMAKE_BUILD_TYPE=${{ matrix.build_type.name }} \ - -DIRIS_CI=ON \ - -S . - - - name: Build Tests - run: | - cmake --build build --config ${{ matrix.build_type.name }} -j${{ env.IRIS_BUILD_JOBS }} ${{ matrix.compiler.builder_additional_args }} - - - name: Cache CMake Dependencies (save) - if: steps.cache-deps.outputs.cache-hit != 'true' - uses: actions/cache/save@v4 - with: - key: ${{ steps.cache-deps.outputs.cache-primary-key }} - path: ${{ github.workspace }}/build/_deps - - - name: Test - env: - CLICOLOR_FORCE: 1 - working-directory: ${{ github.workspace }}/build - run: ctest --output-on-failure -C ${{ matrix.build_type.name }} + IGNORE_NO_MARKER: true + RUN_ID: ${{ github.run_id }} + JOB_ID: ${{ job.check_run_id }} + WORKER_URL: https://cpp-warning-notifier.iris-cpp.org + STEP_REGEX: Build .+ + JOB_REGEX: '\[C\+\+(?\d+)\] (?.+) (?.+) \((?.+)\) / (?.+)' + ROW_HEADERS: '["component", "vendorName", "vendorVersion", "config"]' + COLUMN_HEADER: cppVersion diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 25cf178..da39afb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -150,21 +150,23 @@ endfunction() # Iris tests if(PROJECT_IS_TOP_LEVEL) - add_subdirectory(rvariant) - - set( - IRIS_TEST_IRIS_TESTS - core - type_traits - enum - indirect - colorize_format - preprocess - ) + if(IRIS_CI_COMPONENT STREQUAL iris) + add_subdirectory(rvariant) + + set( + IRIS_TEST_IRIS_TESTS + core + type_traits + enum + indirect + colorize_format + preprocess + ) - iris_define_sub_tests(iris ${IRIS_TEST_IRIS_TESTS}) + iris_define_sub_tests(iris ${IRIS_TEST_IRIS_TESTS}) - foreach(test_name IN LISTS IRIS_TEST_IRIS_TESTS) - iris_define_test_headers(iris_${test_name} iris_test.hpp) - endforeach() + foreach(test_name IN LISTS IRIS_TEST_IRIS_TESTS) + iris_define_test_headers(iris_${test_name} iris_test.hpp) + endforeach() + endif() endif()