Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*.c linguist-language=C
*.cmake linguist-vendored
*.cmd linguist-detectable=false
*.cpp linguist-language=C++
*.cxx linguist-language=C++
*.dsp linguist-detectable=false
*.dsw linguist-detectable=false
*.h linguist-language=C
*.hpp linguist-language=C++
*.html linguist-detectable=false
*.hxx linguist-language=C++
*.sh linguist-detectable=false
*.sln linguist-detectable=false
*.vcxproj linguist-detectable=false
*.vimrc linguist-detectable=false
CMakeLists.txt linguist-vendored
makefile linguist-detectable=false
268 changes: 268 additions & 0 deletions .github/workflows/ci-cell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
name: CI cell

on:
workflow_call:
inputs:
cell-id:
required: true
type: string
os:
required: true
type: string
c-compiler:
required: true
type: string
cpp-compiler:
required: true
type: string
build-type:
required: false
type: string
default: Release
with-clasp:
required: false
type: boolean
default: true
with-cstring:
required: false
type: boolean
default: false
with-test-deps:
required: false
type: boolean
default: true
run-tests:
required: false
type: boolean
default: true

jobs:
cell:
name: ${{ inputs.cell-id }}
runs-on: ${{ inputs.os }}

steps:
- uses: actions/checkout@v4

- name: Install Clang (Ubuntu)
if: runner.os == 'Linux' && inputs.c-compiler == 'clang'
run: sudo apt-get update && sudo apt-get install -y clang

- name: Setup MSYS2 MinGW
if: runner.os == 'Windows' && inputs.c-compiler == 'mingw'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
mingw-w64-x86_64-make

- name: Install dependencies
shell: bash
run: |
set -euxo pipefail

DEPS="${RUNNER_TEMP}/sis-deps"
mkdir -p "$DEPS"
echo "SIS_DEPS=$DEPS" >> "$GITHUB_ENV"

if [ "${{ inputs.c-compiler }}" = "mingw" ]; then
export PATH="/mingw64/bin:$PATH"
fi

cmake_configure() {
local src="$1" bld="$2"
shift 2
if [ "${{ inputs.c-compiler }}" = "cl" ]; then
cmake -S "$src" -B "$bld" \
-DCMAKE_DISABLE_FIND_PACKAGE_MFC=TRUE \
-DCMAKE_INSTALL_PREFIX="$DEPS" \
-DCMAKE_PREFIX_PATH="$DEPS" \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF \
"$@"
elif [ "${{ inputs.c-compiler }}" = "mingw" ]; then
cmake -S "$src" -B "$bld" -G "MinGW Makefiles" \
-DCMAKE_BUILD_TYPE="${{ inputs.build-type }}" \
-DCMAKE_INSTALL_PREFIX="$DEPS" \
-DCMAKE_PREFIX_PATH="$DEPS" \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF \
"$@"
else
cmake -S "$src" -B "$bld" \
-DCMAKE_BUILD_TYPE="${{ inputs.build-type }}" \
-DCMAKE_C_COMPILER="${{ inputs.c-compiler }}" \
-DCMAKE_CXX_COMPILER="${{ inputs.cpp-compiler }}" \
-DCMAKE_INSTALL_PREFIX="$DEPS" \
-DCMAKE_PREFIX_PATH="$DEPS" \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF \
"$@"
fi
}

cmake_build_install() {
local bld="$1"
if [ "${{ inputs.c-compiler }}" = "cl" ]; then
cmake --build "$bld" --config "${{ inputs.build-type }}" --parallel
cmake --install "$bld" --config "${{ inputs.build-type }}"
elif [ "${{ inputs.c-compiler }}" = "mingw" ]; then
cmake --build "$bld" --parallel 2
cmake --install "$bld"
else
cmake --build "$bld" --parallel
cmake --install "$bld"
fi
}

# STLSoft (required)
STLSRC="${RUNNER_TEMP}/stlsoft-src"
STLBUILD="${RUNNER_TEMP}/stlsoft-build"
git clone --depth 1 https://github.com/synesissoftware/STLSoft "$STLSRC"
cmake_configure "$STLSRC" "$STLBUILD"
cmake_build_install "$STLBUILD"

# Catch2 v2 + xTests (test-only)
if [ "${{ inputs.with-test-deps }}" = "true" ]; then
CATCHSRC="${RUNNER_TEMP}/catch2-src"
CATCHBUILD="${RUNNER_TEMP}/catch2-build"
git clone --depth 1 --branch v2.x https://github.com/catchorg/Catch2 "$CATCHSRC"
cmake_configure "$CATCHSRC" "$CATCHBUILD" \
-DCATCH_BUILD_TESTING=OFF \
-DCATCH_ENABLE_WERROR=OFF \
-DCATCH_INSTALL_DOCS=OFF
cmake_build_install "$CATCHBUILD"

XTSRC="${RUNNER_TEMP}/xtests-src"
XTBUILD="${RUNNER_TEMP}/xtests-build"
git clone --depth 1 https://github.com/synesissoftware/xTests "$XTSRC"
cmake_configure "$XTSRC" "$XTBUILD" -DNO_SHWILD=TRUE
cmake_build_install "$XTBUILD"
fi

# CLASP
if [ "${{ inputs.with-clasp }}" = "true" ]; then
CLASPSRC="${RUNNER_TEMP}/clasp-src"
CLASPBUILD="${RUNNER_TEMP}/clasp-build"
git clone --depth 1 https://github.com/synesissoftware/CLASP "$CLASPSRC"
cmake_configure "$CLASPSRC" "$CLASPBUILD"
cmake_build_install "$CLASPBUILD"
fi

# cstring
if [ "${{ inputs.with-cstring }}" = "true" ]; then
CSTRSRC="${RUNNER_TEMP}/cstring-src"
CSTRBUILD="${RUNNER_TEMP}/cstring-build"
git clone --depth 1 https://github.com/synesissoftware/cstring "$CSTRSRC"
cmake_configure "$CSTRSRC" "$CSTRBUILD"
cmake_build_install "$CSTRBUILD"
fi

- name: Configure
shell: bash
run: |
set -euo pipefail
DEPS="${{ env.SIS_DEPS }}"

if [ "${{ inputs.c-compiler }}" = "mingw" ]; then
export PATH="/mingw64/bin:$PATH"
fi

# Bare `cstring` link (rstrip) needs include/lib search paths beyond
# find_package(CLASP)-style imported targets.
if [ "${{ inputs.with-cstring }}" = "true" ]; then
if [ "${{ inputs.c-compiler }}" = "cl" ]; then
export INCLUDE="$(cygpath -w "$DEPS/include");${INCLUDE:-}"
export LIB="$(cygpath -w "$DEPS/lib");${LIB:-}"
else
export CPATH="$DEPS/include${CPATH:+:$CPATH}"
export LIBRARY_PATH="$DEPS/lib${LIBRARY_PATH:+:$LIBRARY_PATH}"
fi
fi

if [ "${{ inputs.c-compiler }}" = "cl" ]; then
cmake -B build -S . \
-DCMAKE_DISABLE_FIND_PACKAGE_MFC=TRUE \
-DCMAKE_PREFIX_PATH="$DEPS" \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=ON
elif [ "${{ inputs.c-compiler }}" = "mingw" ]; then
cmake -B build -G "MinGW Makefiles" \
-DCMAKE_BUILD_TYPE="${{ inputs.build-type }}" \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_PREFIX_PATH="$DEPS" \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=ON
else
cmake -B build -S . \
-DCMAKE_BUILD_TYPE="${{ inputs.build-type }}" \
-DCMAKE_C_COMPILER="${{ inputs.c-compiler }}" \
-DCMAKE_CXX_COMPILER="${{ inputs.cpp-compiler }}" \
-DCMAKE_PREFIX_PATH="$DEPS" \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=ON
fi

- name: Build
shell: bash
run: |
set -euo pipefail
if [ "${{ inputs.c-compiler }}" = "mingw" ]; then
export PATH="/mingw64/bin:$PATH"
fi
if [ "${{ inputs.with-cstring }}" = "true" ]; then
DEPS="${{ env.SIS_DEPS }}"
if [ "${{ inputs.c-compiler }}" = "cl" ]; then
export INCLUDE="$(cygpath -w "$DEPS/include");${INCLUDE:-}"
export LIB="$(cygpath -w "$DEPS/lib");${LIB:-}"
else
export CPATH="$DEPS/include${CPATH:+:$CPATH}"
export LIBRARY_PATH="$DEPS/lib${LIBRARY_PATH:+:$LIBRARY_PATH}"
fi
fi
if [ "${{ inputs.c-compiler }}" = "cl" ]; then
cmake --build build --config "${{ inputs.build-type }}" --parallel
elif [ "${{ inputs.c-compiler }}" = "mingw" ]; then
cmake --build build --parallel 2
else
cmake --build build --parallel
fi

- name: Run tests
if: inputs.run-tests
shell: bash
run: |
set -euo pipefail
if [ "${{ inputs.c-compiler }}" = "mingw" ]; then
export PATH="/mingw64/bin:$PATH"
fi
export SIS_CMAKE_BUILD_DIR="${{ github.workspace }}/build"
if [ "${{ runner.os }}" = "Windows" ]; then
cmd.exe //c "run_all_unit_tests.cmd -M -v"
else
./run_all_unit_tests.sh -M -v
fi

- name: Install and verify
shell: bash
run: |
set -euo pipefail
PREFIX="${RUNNER_TEMP}/install-prefix"
PROJECT="$(tr -d '[:space:]' < .sis/project_name.txt)"
if [ "${{ inputs.c-compiler }}" = "mingw" ]; then
export PATH="/mingw64/bin:$PATH"
fi
if [ "${{ inputs.c-compiler }}" = "cl" ]; then
cmake --install build --config "${{ inputs.build-type }}" --prefix "$PREFIX"
else
cmake --install build --prefix "$PREFIX"
fi
if [ "${{ inputs.c-compiler }}" = "cl" ] || [ "${{ inputs.c-compiler }}" = "mingw" ]; then
test -f "$PREFIX/bin/${PROJECT}.exe"
else
test -x "$PREFIX/bin/${PROJECT}"
fi
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
push:
branches:
- master
- boilerplate
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
cell:
name: CI (${{ matrix.id }})
strategy:
fail-fast: false
matrix:
include:
- id: windows-cl
os: windows-latest
c_compiler: cl
cpp_compiler: cl
- id: windows-mingw
os: windows-latest
c_compiler: mingw
cpp_compiler: g++
uses: ./.github/workflows/ci-cell.yml
with:
cell-id: ${{ matrix.id }}
os: ${{ matrix.os }}
c-compiler: ${{ matrix.c_compiler }}
cpp-compiler: ${{ matrix.cpp_compiler }}
build-type: Release
with-clasp: false
with-cstring: false
with-test-deps: false
run-tests: true
Loading