|
| 1 | +# Copyright 2026 The Iris Project Contributors |
| 2 | +# |
| 3 | +# Distributed under the Boost Software License, Version 1.0. |
| 4 | +# https://www.boost.org/LICENSE_1_0.txt |
| 5 | + |
| 6 | +name: Build |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_call: |
| 10 | + inputs: |
| 11 | + os-name: |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + os-version: |
| 15 | + required: true |
| 16 | + type: string |
| 17 | + build-type-name: |
| 18 | + required: true |
| 19 | + type: string |
| 20 | + cpp-version-name: |
| 21 | + required: true |
| 22 | + type: string |
| 23 | + cpp-version-number: |
| 24 | + required: true |
| 25 | + type: string |
| 26 | + compiler-toolset: |
| 27 | + required: true |
| 28 | + type: string |
| 29 | + compiler-version: |
| 30 | + required: true |
| 31 | + type: string |
| 32 | + compiler-executable: |
| 33 | + required: true |
| 34 | + type: string |
| 35 | + compiler-cxxflags: |
| 36 | + required: false |
| 37 | + type: string |
| 38 | + default: "" |
| 39 | + compiler-toolset-version: |
| 40 | + required: false |
| 41 | + type: string |
| 42 | + default: "" |
| 43 | + vs-path: |
| 44 | + required: false |
| 45 | + type: string |
| 46 | + default: "" |
| 47 | + cmake-config-additional-args: |
| 48 | + required: false |
| 49 | + type: string |
| 50 | + default: "" |
| 51 | + compiler-builder-additional-args: |
| 52 | + required: false |
| 53 | + type: string |
| 54 | + default: "" |
| 55 | + components: |
| 56 | + required: true |
| 57 | + type: string |
| 58 | + description: 'JSON array of components to build (e.g. ["iris", "alloy","x4"])' |
| 59 | + |
| 60 | +env: |
| 61 | + IRIS_CI_BUILD_JOBS: 4 |
| 62 | + |
| 63 | +jobs: |
| 64 | + prepare-deps: |
| 65 | + name: "Dependencies" |
| 66 | + runs-on: ${{ inputs.os-name }}-${{ inputs.os-version }} |
| 67 | + |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v5 |
| 70 | + with: |
| 71 | + submodules: recursive |
| 72 | + |
| 73 | + - name: Setup Toolchain |
| 74 | + id: setup |
| 75 | + uses: ./.github/actions/setup-cpp |
| 76 | + with: |
| 77 | + os-name: ${{ inputs.os-name }} |
| 78 | + os-version: ${{ inputs.os-version }} |
| 79 | + compiler-toolset: ${{ inputs.compiler-toolset }} |
| 80 | + compiler-version: ${{ inputs.compiler-version }} |
| 81 | + compiler-executable: ${{ inputs.compiler-executable }} |
| 82 | + compiler-toolset-version: ${{ inputs.compiler-toolset-version }} |
| 83 | + vs-path: ${{ inputs.vs-path }} |
| 84 | + cpp-version-name: ${{ inputs.cpp-version-name }} |
| 85 | + build-type-name: ${{ inputs.build-type-name }} |
| 86 | + |
| 87 | + - name: Cache CMake Dependencies (restore) |
| 88 | + id: cache-deps |
| 89 | + uses: actions/cache/restore@v5 |
| 90 | + with: |
| 91 | + key: ${{ steps.setup.outputs.deps-cache-key }} |
| 92 | + path: ${{ github.workspace }}/build/_deps |
| 93 | + |
| 94 | + # Adapt CMP0168; enable caching in CI |
| 95 | + # https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_FULLY_DISCONNECTED |
| 96 | + - name: Setup Cached CMake Dependencies |
| 97 | + id: deps-info |
| 98 | + shell: bash |
| 99 | + run: | |
| 100 | + if [ "${{ steps.cache-deps.outputs.cache-hit }}" = "true" ]; then |
| 101 | + echo "IRIS_CI_CMAKE_ARGS=-DFETCHCONTENT_FULLY_DISCONNECTED=ON" >> "$GITHUB_OUTPUT" |
| 102 | + else |
| 103 | + echo "IRIS_CI_CMAKE_ARGS=" >> "$GITHUB_OUTPUT" |
| 104 | + fi |
| 105 | +
|
| 106 | + - name: Configure |
| 107 | + env: |
| 108 | + CLICOLOR_FORCE: 1 |
| 109 | + shell: bash |
| 110 | + run: | |
| 111 | + set -xe |
| 112 | + cmake ${{ steps.deps-info.outputs.IRIS_CI_CMAKE_ARGS }} -B build \ |
| 113 | + ${{ inputs.cmake-config-additional-args }} \ |
| 114 | + -DCMAKE_CXX_COMPILER=${{ inputs.compiler-executable }} \ |
| 115 | + -DCMAKE_CXX_FLAGS="${{ inputs.compiler-cxxflags }}" \ |
| 116 | + -DCMAKE_CXX_STANDARD=${{ inputs.cpp-version-number }} \ |
| 117 | + -DCMAKE_BUILD_TYPE=${{ inputs.build-type-name }} \ |
| 118 | + -DIRIS_CI=ON \ |
| 119 | + -S . |
| 120 | +
|
| 121 | + - name: Build Deps |
| 122 | + env: |
| 123 | + CLICOLOR_FORCE: 1 |
| 124 | + run: | |
| 125 | + cmake --build build --config ${{ inputs.build-type-name }} -j${{ env.IRIS_CI_BUILD_JOBS }} --target Catch2WithMain ${{ inputs.compiler-builder-additional-args }} |
| 126 | +
|
| 127 | + - name: Cache CMake Dependencies (save) |
| 128 | + # Due to some bogus "Unable to reserve cache with key" error, we *always* save the cache for now. |
| 129 | + # See this page for the rate limit: https://docs.github.com/en/actions/reference/limits#existing-system-limits |
| 130 | + # if: steps.cache-deps.outputs.cache-hit != 'true' |
| 131 | + uses: actions/cache/save@v5 |
| 132 | + with: |
| 133 | + key: ${{ steps.cache-deps.outputs.cache-primary-key }} |
| 134 | + path: ${{ github.workspace }}/build/_deps |
| 135 | + |
| 136 | + build: |
| 137 | + name: ${{ matrix.component }} |
| 138 | + needs: prepare-deps |
| 139 | + runs-on: ${{ inputs.os-name }}-${{ inputs.os-version }} |
| 140 | + |
| 141 | + strategy: |
| 142 | + fail-fast: false |
| 143 | + |
| 144 | + matrix: |
| 145 | + component: ${{ fromJSON(inputs.components) }} |
| 146 | + |
| 147 | + steps: |
| 148 | + - uses: actions/checkout@v5 |
| 149 | + with: |
| 150 | + submodules: recursive |
| 151 | + |
| 152 | + - name: Setup Toolchain |
| 153 | + id: setup |
| 154 | + uses: ./.github/actions/setup-cpp |
| 155 | + with: |
| 156 | + os-name: ${{ inputs.os-name }} |
| 157 | + os-version: ${{ inputs.os-version }} |
| 158 | + compiler-toolset: ${{ inputs.compiler-toolset }} |
| 159 | + compiler-version: ${{ inputs.compiler-version }} |
| 160 | + compiler-executable: ${{ inputs.compiler-executable }} |
| 161 | + cpp-version-name: ${{ inputs.cpp-version-name }} |
| 162 | + build-type-name: ${{ inputs.build-type-name }} |
| 163 | + |
| 164 | + - name: Cache CMake Dependencies (restore) |
| 165 | + id: cache-deps |
| 166 | + uses: actions/cache/restore@v4 |
| 167 | + with: |
| 168 | + key: ${{ steps.setup.outputs.deps-cache-key }} |
| 169 | + path: ${{ github.workspace }}/build/_deps |
| 170 | + |
| 171 | + - name: Configure |
| 172 | + env: |
| 173 | + CLICOLOR_FORCE: 1 |
| 174 | + shell: bash |
| 175 | + run: | |
| 176 | + set -xe |
| 177 | + cmake -DFETCHCONTENT_FULLY_DISCONNECTED=ON -B build \ |
| 178 | + -DCMAKE_CXX_COMPILER=${{ inputs.compiler-executable }} \ |
| 179 | + -DCMAKE_CXX_FLAGS="${{ inputs.compiler-cxxflags }}" \ |
| 180 | + -DCMAKE_CXX_STANDARD=${{ inputs.cpp-version-number }} \ |
| 181 | + -DCMAKE_BUILD_TYPE=${{ inputs.build-type-name }} \ |
| 182 | + -DIRIS_CI_COMPONENT=${{ matrix.component }} \ |
| 183 | + -DIRIS_CI=ON \ |
| 184 | + -S . |
| 185 | +
|
| 186 | + - name: Build Tests |
| 187 | + env: |
| 188 | + CLICOLOR_FORCE: 1 |
| 189 | + shell: bash |
| 190 | + run: | |
| 191 | + echo "CPPWARNINGNOTIFIER_LOG_MARKER" |
| 192 | + cmake --build build --config ${{ inputs.build-type-name }} -j${{ env.IRIS_CI_BUILD_JOBS }} ${{ inputs.compiler-builder-additional-args }} |
| 193 | +
|
| 194 | + - name: Test |
| 195 | + env: |
| 196 | + CLICOLOR_FORCE: 1 |
| 197 | + working-directory: ${{ github.workspace }}/build/test |
| 198 | + run: ctest --output-on-failure -C ${{ inputs.build-type-name }} |
0 commit comments