|
| 1 | +name: CI cell |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + cell-id: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + os: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + c-compiler: |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + cpp-compiler: |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + build-type: |
| 19 | + required: false |
| 20 | + type: string |
| 21 | + default: Release |
| 22 | + with-clasp: |
| 23 | + required: false |
| 24 | + type: boolean |
| 25 | + default: true |
| 26 | + with-cstring: |
| 27 | + required: false |
| 28 | + type: boolean |
| 29 | + default: false |
| 30 | + with-test-deps: |
| 31 | + required: false |
| 32 | + type: boolean |
| 33 | + default: true |
| 34 | + run-tests: |
| 35 | + required: false |
| 36 | + type: boolean |
| 37 | + default: true |
| 38 | + |
| 39 | +jobs: |
| 40 | + cell: |
| 41 | + name: ${{ inputs.cell-id }} |
| 42 | + runs-on: ${{ inputs.os }} |
| 43 | + |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Install Clang (Ubuntu) |
| 48 | + if: runner.os == 'Linux' && inputs.c-compiler == 'clang' |
| 49 | + run: sudo apt-get update && sudo apt-get install -y clang |
| 50 | + |
| 51 | + - name: Setup MSYS2 MinGW |
| 52 | + if: runner.os == 'Windows' && inputs.c-compiler == 'mingw' |
| 53 | + uses: msys2/setup-msys2@v2 |
| 54 | + with: |
| 55 | + msystem: MINGW64 |
| 56 | + update: true |
| 57 | + install: >- |
| 58 | + mingw-w64-x86_64-toolchain |
| 59 | + mingw-w64-x86_64-cmake |
| 60 | + mingw-w64-x86_64-make |
| 61 | +
|
| 62 | + - name: Install dependencies |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + set -euxo pipefail |
| 66 | +
|
| 67 | + DEPS="${RUNNER_TEMP}/sis-deps" |
| 68 | + mkdir -p "$DEPS" |
| 69 | + echo "SIS_DEPS=$DEPS" >> "$GITHUB_ENV" |
| 70 | +
|
| 71 | + if [ "${{ inputs.c-compiler }}" = "mingw" ]; then |
| 72 | + export PATH="/mingw64/bin:$PATH" |
| 73 | + fi |
| 74 | +
|
| 75 | + cmake_configure() { |
| 76 | + local src="$1" bld="$2" |
| 77 | + shift 2 |
| 78 | + if [ "${{ inputs.c-compiler }}" = "cl" ]; then |
| 79 | + cmake -S "$src" -B "$bld" \ |
| 80 | + -DCMAKE_DISABLE_FIND_PACKAGE_MFC=TRUE \ |
| 81 | + -DCMAKE_INSTALL_PREFIX="$DEPS" \ |
| 82 | + -DCMAKE_PREFIX_PATH="$DEPS" \ |
| 83 | + -DBUILD_EXAMPLES=OFF \ |
| 84 | + -DBUILD_TESTING=OFF \ |
| 85 | + "$@" |
| 86 | + elif [ "${{ inputs.c-compiler }}" = "mingw" ]; then |
| 87 | + cmake -S "$src" -B "$bld" -G "MinGW Makefiles" \ |
| 88 | + -DCMAKE_BUILD_TYPE="${{ inputs.build-type }}" \ |
| 89 | + -DCMAKE_INSTALL_PREFIX="$DEPS" \ |
| 90 | + -DCMAKE_PREFIX_PATH="$DEPS" \ |
| 91 | + -DBUILD_EXAMPLES=OFF \ |
| 92 | + -DBUILD_TESTING=OFF \ |
| 93 | + "$@" |
| 94 | + else |
| 95 | + cmake -S "$src" -B "$bld" \ |
| 96 | + -DCMAKE_BUILD_TYPE="${{ inputs.build-type }}" \ |
| 97 | + -DCMAKE_C_COMPILER="${{ inputs.c-compiler }}" \ |
| 98 | + -DCMAKE_CXX_COMPILER="${{ inputs.cpp-compiler }}" \ |
| 99 | + -DCMAKE_INSTALL_PREFIX="$DEPS" \ |
| 100 | + -DCMAKE_PREFIX_PATH="$DEPS" \ |
| 101 | + -DBUILD_EXAMPLES=OFF \ |
| 102 | + -DBUILD_TESTING=OFF \ |
| 103 | + "$@" |
| 104 | + fi |
| 105 | + } |
| 106 | +
|
| 107 | + cmake_build_install() { |
| 108 | + local bld="$1" |
| 109 | + if [ "${{ inputs.c-compiler }}" = "cl" ]; then |
| 110 | + cmake --build "$bld" --config "${{ inputs.build-type }}" --parallel |
| 111 | + cmake --install "$bld" --config "${{ inputs.build-type }}" |
| 112 | + elif [ "${{ inputs.c-compiler }}" = "mingw" ]; then |
| 113 | + cmake --build "$bld" --parallel 2 |
| 114 | + cmake --install "$bld" |
| 115 | + else |
| 116 | + cmake --build "$bld" --parallel |
| 117 | + cmake --install "$bld" |
| 118 | + fi |
| 119 | + } |
| 120 | +
|
| 121 | + # STLSoft (required) |
| 122 | + STLSRC="${RUNNER_TEMP}/stlsoft-src" |
| 123 | + STLBUILD="${RUNNER_TEMP}/stlsoft-build" |
| 124 | + git clone --depth 1 https://github.com/synesissoftware/STLSoft "$STLSRC" |
| 125 | + cmake_configure "$STLSRC" "$STLBUILD" |
| 126 | + cmake_build_install "$STLBUILD" |
| 127 | +
|
| 128 | + # Catch2 v2 + xTests (test-only) |
| 129 | + if [ "${{ inputs.with-test-deps }}" = "true" ]; then |
| 130 | + CATCHSRC="${RUNNER_TEMP}/catch2-src" |
| 131 | + CATCHBUILD="${RUNNER_TEMP}/catch2-build" |
| 132 | + git clone --depth 1 --branch v2.x https://github.com/catchorg/Catch2 "$CATCHSRC" |
| 133 | + cmake_configure "$CATCHSRC" "$CATCHBUILD" \ |
| 134 | + -DCATCH_BUILD_TESTING=OFF \ |
| 135 | + -DCATCH_ENABLE_WERROR=OFF \ |
| 136 | + -DCATCH_INSTALL_DOCS=OFF |
| 137 | + cmake_build_install "$CATCHBUILD" |
| 138 | +
|
| 139 | + XTSRC="${RUNNER_TEMP}/xtests-src" |
| 140 | + XTBUILD="${RUNNER_TEMP}/xtests-build" |
| 141 | + git clone --depth 1 https://github.com/synesissoftware/xTests "$XTSRC" |
| 142 | + cmake_configure "$XTSRC" "$XTBUILD" -DNO_SHWILD=TRUE |
| 143 | + cmake_build_install "$XTBUILD" |
| 144 | + fi |
| 145 | +
|
| 146 | + # CLASP |
| 147 | + if [ "${{ inputs.with-clasp }}" = "true" ]; then |
| 148 | + CLASPSRC="${RUNNER_TEMP}/clasp-src" |
| 149 | + CLASPBUILD="${RUNNER_TEMP}/clasp-build" |
| 150 | + git clone --depth 1 https://github.com/synesissoftware/CLASP "$CLASPSRC" |
| 151 | + cmake_configure "$CLASPSRC" "$CLASPBUILD" |
| 152 | + cmake_build_install "$CLASPBUILD" |
| 153 | + fi |
| 154 | +
|
| 155 | + # cstring |
| 156 | + if [ "${{ inputs.with-cstring }}" = "true" ]; then |
| 157 | + CSTRSRC="${RUNNER_TEMP}/cstring-src" |
| 158 | + CSTRBUILD="${RUNNER_TEMP}/cstring-build" |
| 159 | + git clone --depth 1 https://github.com/synesissoftware/cstring "$CSTRSRC" |
| 160 | + cmake_configure "$CSTRSRC" "$CSTRBUILD" |
| 161 | + cmake_build_install "$CSTRBUILD" |
| 162 | + fi |
| 163 | +
|
| 164 | + - name: Configure |
| 165 | + shell: bash |
| 166 | + run: | |
| 167 | + set -euo pipefail |
| 168 | + DEPS="${{ env.SIS_DEPS }}" |
| 169 | +
|
| 170 | + if [ "${{ inputs.c-compiler }}" = "mingw" ]; then |
| 171 | + export PATH="/mingw64/bin:$PATH" |
| 172 | + fi |
| 173 | +
|
| 174 | + # Bare `cstring` link (rstrip) needs include/lib search paths beyond |
| 175 | + # find_package(CLASP)-style imported targets. |
| 176 | + if [ "${{ inputs.with-cstring }}" = "true" ]; then |
| 177 | + if [ "${{ inputs.c-compiler }}" = "cl" ]; then |
| 178 | + export INCLUDE="$(cygpath -w "$DEPS/include");${INCLUDE:-}" |
| 179 | + export LIB="$(cygpath -w "$DEPS/lib");${LIB:-}" |
| 180 | + else |
| 181 | + export CPATH="$DEPS/include${CPATH:+:$CPATH}" |
| 182 | + export LIBRARY_PATH="$DEPS/lib${LIBRARY_PATH:+:$LIBRARY_PATH}" |
| 183 | + fi |
| 184 | + fi |
| 185 | +
|
| 186 | + if [ "${{ inputs.c-compiler }}" = "cl" ]; then |
| 187 | + cmake -B build -S . \ |
| 188 | + -DCMAKE_DISABLE_FIND_PACKAGE_MFC=TRUE \ |
| 189 | + -DCMAKE_PREFIX_PATH="$DEPS" \ |
| 190 | + -DBUILD_EXAMPLES=OFF \ |
| 191 | + -DBUILD_TESTING=ON |
| 192 | + elif [ "${{ inputs.c-compiler }}" = "mingw" ]; then |
| 193 | + cmake -B build -G "MinGW Makefiles" \ |
| 194 | + -DCMAKE_BUILD_TYPE="${{ inputs.build-type }}" \ |
| 195 | + -DCMAKE_C_COMPILER=gcc \ |
| 196 | + -DCMAKE_CXX_COMPILER=g++ \ |
| 197 | + -DCMAKE_PREFIX_PATH="$DEPS" \ |
| 198 | + -DBUILD_EXAMPLES=OFF \ |
| 199 | + -DBUILD_TESTING=ON |
| 200 | + else |
| 201 | + cmake -B build -S . \ |
| 202 | + -DCMAKE_BUILD_TYPE="${{ inputs.build-type }}" \ |
| 203 | + -DCMAKE_C_COMPILER="${{ inputs.c-compiler }}" \ |
| 204 | + -DCMAKE_CXX_COMPILER="${{ inputs.cpp-compiler }}" \ |
| 205 | + -DCMAKE_PREFIX_PATH="$DEPS" \ |
| 206 | + -DBUILD_EXAMPLES=OFF \ |
| 207 | + -DBUILD_TESTING=ON |
| 208 | + fi |
| 209 | +
|
| 210 | + - name: Build |
| 211 | + shell: bash |
| 212 | + run: | |
| 213 | + set -euo pipefail |
| 214 | + if [ "${{ inputs.c-compiler }}" = "mingw" ]; then |
| 215 | + export PATH="/mingw64/bin:$PATH" |
| 216 | + fi |
| 217 | + if [ "${{ inputs.with-cstring }}" = "true" ]; then |
| 218 | + DEPS="${{ env.SIS_DEPS }}" |
| 219 | + if [ "${{ inputs.c-compiler }}" = "cl" ]; then |
| 220 | + export INCLUDE="$(cygpath -w "$DEPS/include");${INCLUDE:-}" |
| 221 | + export LIB="$(cygpath -w "$DEPS/lib");${LIB:-}" |
| 222 | + else |
| 223 | + export CPATH="$DEPS/include${CPATH:+:$CPATH}" |
| 224 | + export LIBRARY_PATH="$DEPS/lib${LIBRARY_PATH:+:$LIBRARY_PATH}" |
| 225 | + fi |
| 226 | + fi |
| 227 | + if [ "${{ inputs.c-compiler }}" = "cl" ]; then |
| 228 | + cmake --build build --config "${{ inputs.build-type }}" --parallel |
| 229 | + elif [ "${{ inputs.c-compiler }}" = "mingw" ]; then |
| 230 | + cmake --build build --parallel 2 |
| 231 | + else |
| 232 | + cmake --build build --parallel |
| 233 | + fi |
| 234 | +
|
| 235 | + - name: Run tests |
| 236 | + if: inputs.run-tests |
| 237 | + shell: bash |
| 238 | + run: | |
| 239 | + set -euo pipefail |
| 240 | + if [ "${{ inputs.c-compiler }}" = "mingw" ]; then |
| 241 | + export PATH="/mingw64/bin:$PATH" |
| 242 | + fi |
| 243 | + export SIS_CMAKE_BUILD_DIR="${{ github.workspace }}/build" |
| 244 | + if [ "${{ runner.os }}" = "Windows" ]; then |
| 245 | + cmd.exe //c "run_all_unit_tests.cmd -M -v" |
| 246 | + else |
| 247 | + ./run_all_unit_tests.sh -M -v |
| 248 | + fi |
| 249 | +
|
| 250 | + - name: Install and verify |
| 251 | + shell: bash |
| 252 | + run: | |
| 253 | + set -euo pipefail |
| 254 | + PREFIX="${RUNNER_TEMP}/install-prefix" |
| 255 | + PROJECT="$(tr -d '[:space:]' < .sis/project_name.txt)" |
| 256 | + if [ "${{ inputs.c-compiler }}" = "mingw" ]; then |
| 257 | + export PATH="/mingw64/bin:$PATH" |
| 258 | + fi |
| 259 | + if [ "${{ inputs.c-compiler }}" = "cl" ]; then |
| 260 | + cmake --install build --config "${{ inputs.build-type }}" --prefix "$PREFIX" |
| 261 | + else |
| 262 | + cmake --install build --prefix "$PREFIX" |
| 263 | + fi |
| 264 | + if [ "${{ inputs.c-compiler }}" = "cl" ] || [ "${{ inputs.c-compiler }}" = "mingw" ]; then |
| 265 | + test -f "$PREFIX/bin/${PROJECT}.exe" |
| 266 | + else |
| 267 | + test -x "$PREFIX/bin/${PROJECT}" |
| 268 | + fi |
0 commit comments