Skip to content

Commit ea2505b

Browse files
authored
Boilerplate, CI (#1)
* .gitattributes * .gitignore * .vimrc * settings * chore: project helper scripts * chore: added project markdown files * LICENSE * chore: CMake updates * CI
1 parent 3b45993 commit ea2505b

24 files changed

Lines changed: 2002 additions & 27 deletions

‎.gitattributes‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
*.c linguist-language=C
2+
*.cmake linguist-vendored
3+
*.cmd linguist-detectable=false
4+
*.cpp linguist-language=C++
5+
*.cxx linguist-language=C++
6+
*.dsp linguist-detectable=false
7+
*.dsw linguist-detectable=false
8+
*.h linguist-language=C
9+
*.hpp linguist-language=C++
10+
*.html linguist-detectable=false
11+
*.hxx linguist-language=C++
12+
*.sh linguist-detectable=false
13+
*.sln linguist-detectable=false
14+
*.vcxproj linguist-detectable=false
15+
*.vimrc linguist-detectable=false
16+
CMakeLists.txt linguist-vendored
17+
makefile linguist-detectable=false

‎.github/workflows/ci-cell.yml‎

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
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

‎.github/workflows/ci.yml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- boilerplate
8+
pull_request:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
cell:
16+
name: CI (${{ matrix.id }})
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- id: windows-cl
22+
os: windows-latest
23+
c_compiler: cl
24+
cpp_compiler: cl
25+
- id: windows-mingw
26+
os: windows-latest
27+
c_compiler: mingw
28+
cpp_compiler: g++
29+
uses: ./.github/workflows/ci-cell.yml
30+
with:
31+
cell-id: ${{ matrix.id }}
32+
os: ${{ matrix.os }}
33+
c-compiler: ${{ matrix.c_compiler }}
34+
cpp-compiler: ${{ matrix.cpp_compiler }}
35+
build-type: Release
36+
with-clasp: false
37+
with-cstring: false
38+
with-test-deps: false
39+
run-tests: true

0 commit comments

Comments
 (0)