Skip to content

Commit 99fe77b

Browse files
committed
ci: update workflow action
1. Add cmake workflow presets for continuous integration. 2. Update github action to use the cmake workflow presets.
1 parent 03367dc commit 99fe77b

File tree

2 files changed

+324
-26
lines changed

2 files changed

+324
-26
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,15 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
uname: [Linux, Darwin, Windows]
13-
libraries: [Static, Shared]
14-
config: [Debug, Release]
15-
include:
16-
- { uname: Linux, os: ubuntu-latest }
17-
- { uname: Darwin, os: macos-latest }
18-
- { uname: Windows, os: windows-latest }
19-
- { libraries: Static, shared: NO }
20-
- { libraries: Shared, shared: YES }
12+
os: [ubuntu-latest, macos-latest, windows-latest]
2113

2214
runs-on: ${{matrix.os}}
2315

2416
steps:
2517
- uses: actions/checkout@v4
2618

27-
- name: Generate build system
28-
run: cmake -B ${{github.workspace}}/build
29-
-DCMAKE_BUILD_TYPE:STRING=${{matrix.config}}
30-
-DBUILD_SHARED_LIBS:BOOL=${{matrix.shared}}
31-
-DBUILD_TESTING:BOOL=YES
19+
- name: Run cmake workflow for shared libraries
20+
run: cmake --workflow ci-shared
3221

33-
- name: Build targets
34-
run: cmake --build ${{github.workspace}}/build
35-
--config ${{matrix.config}}
36-
37-
- name: Perform tests
38-
run: ctest --test-dir ${{github.workspace}}/build
39-
--build-config ${{matrix.config}}
40-
--verbose
41-
42-
- name: Create package
43-
working-directory: ${{github.workspace}}/build
44-
run: cpack -C ${{matrix.config}} -G ZIP -V
22+
- name: Run cmake workflow for static libraries
23+
run: cmake --workflow ci-static

CMakePresets.json

Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
{
2+
"version": 8,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 28,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "diagnostics-default",
11+
"description": "Diagnostic settings: warnings off, errors off, debug off",
12+
"hidden": true,
13+
"warnings": {
14+
"dev": false,
15+
"deprecated": false,
16+
"uninitialized": false,
17+
"unusedCli": false,
18+
"systemVars": false
19+
},
20+
"errors": {
21+
"dev": false,
22+
"deprecated": false
23+
},
24+
"debug": {
25+
"output": false,
26+
"tryCompile": false,
27+
"find": false
28+
},
29+
"cacheVariables": {
30+
"CMAKE_MESSAGE_LOG_LEVEL": "WARNING",
31+
"CMAKE_REQUIRED_QUIET": true
32+
}
33+
},
34+
{
35+
"name": "diagnostics-pedantic",
36+
"description": "Diagnostic settings: warnings on, errors off, debug off",
37+
"hidden": true,
38+
"inherits": "diagnostics-default",
39+
"warnings": {
40+
"dev": true,
41+
"deprecated": true,
42+
"uninitialized": true,
43+
"unusedCli": true
44+
},
45+
"cacheVariables": {
46+
"CMAKE_MESSAGE_LOG_LEVEL": "STATUS",
47+
"CMAKE_REQUIRED_QUIET": false
48+
}
49+
},
50+
{
51+
"name": "diagnostics-errors",
52+
"description": "Diagnostic settings: warnings on, errors on, debug off",
53+
"hidden": true,
54+
"inherits": "diagnostics-pedantic",
55+
"errors": {
56+
"dev": true,
57+
"deprecated": true
58+
}
59+
},
60+
{
61+
"name": "diagnostics-debug",
62+
"description": "Diagnostic settings: warnings on, errors off, debug on",
63+
"hidden": true,
64+
"inherits": "diagnostics-pedantic",
65+
"debug": {
66+
"output": true,
67+
"tryCompile": true,
68+
"find": true
69+
},
70+
"cacheVariables": {
71+
"CMAKE_MESSAGE_LOG_LEVEL": "DEBUG"
72+
}
73+
},
74+
{
75+
"name": "language-std-c99",
76+
"description": "Set C language standard to C99",
77+
"hidden": true,
78+
"cacheVariables": {
79+
"CMAKE_C_STANDARD": "99",
80+
"CMAKE_C_STANDARD_REQUIRED": true,
81+
"CMAKE_C_EXTENSIONS": true
82+
}
83+
},
84+
{
85+
"name": "compiler-clang",
86+
"description": "Set C language compiler to Clang",
87+
"hidden": true,
88+
"environment": {
89+
"CC": "clang"
90+
},
91+
"cacheVariables": {
92+
"CMAKE_C_FLAGS": "-Wall"
93+
}
94+
},
95+
{
96+
"name": "generator-ninja-multi",
97+
"description": "Use Ninja Multi-Config generator",
98+
"hidden": true,
99+
"generator": "Ninja Multi-Config",
100+
"binaryDir": "out/build",
101+
"installDir": "out/stage"
102+
},
103+
{
104+
"name": "common",
105+
"description": "Common preset combining diagnostics, language standard, compiler, and generator",
106+
"hidden": true,
107+
"inherits": [
108+
"diagnostics-pedantic",
109+
"language-std-c99",
110+
"compiler-clang",
111+
"generator-ninja-multi"
112+
]
113+
},
114+
{
115+
"name": "shared",
116+
"description": "Configure the build system for building shared libraries",
117+
"displayName": "Shared Libraries",
118+
"inherits": "common",
119+
"cacheVariables": {
120+
"BUILD_SHARED_LIBS": true
121+
}
122+
},
123+
{
124+
"name": "static",
125+
"description": "Configure the build system for building static libraries",
126+
"displayName": "Static Libraries",
127+
"inherits": "common",
128+
"cacheVariables": {
129+
"BUILD_SHARED_LIBS": false
130+
}
131+
}
132+
],
133+
"buildPresets": [
134+
{
135+
"name": "common",
136+
"description": "Common build settings",
137+
"hidden": true,
138+
"jobs": 8,
139+
"targets": "all",
140+
"cleanFirst": false,
141+
"verbose": true
142+
},
143+
{
144+
"name": "debug-shared",
145+
"description": "Build shared libraries in Debug configuration",
146+
"displayName": "Debug Shared Libraries",
147+
"inherits": "common",
148+
"configurePreset": "shared",
149+
"configuration": "Debug"
150+
},
151+
{
152+
"name": "debug-static",
153+
"description": "Build static libraries in Debug configuration",
154+
"displayName": "Debug Static Libraries",
155+
"inherits": "common",
156+
"configurePreset": "static",
157+
"configuration": "Debug"
158+
},
159+
{
160+
"name": "release-shared",
161+
"description": "Build shared libraries in Release configuration",
162+
"displayName": "Release Shared Libraries",
163+
"inherits": "common",
164+
"configurePreset": "shared",
165+
"configuration": "Release"
166+
},
167+
{
168+
"name": "release-static",
169+
"description": "Build static libraries in Release configuration",
170+
"displayName": "Release Static Libraries",
171+
"inherits": "common",
172+
"configurePreset": "static",
173+
"configuration": "Release"
174+
}
175+
],
176+
"testPresets": [
177+
{
178+
"name": "common",
179+
"description": "Common test settings",
180+
"hidden": true,
181+
"output": {
182+
"shortProgress": false,
183+
"verbosity": "extra",
184+
"debug": false,
185+
"outputOnFailure": true,
186+
"quiet": false
187+
},
188+
"execution": {
189+
"stopOnFailure": false,
190+
"jobs": 8,
191+
"timeout": 300,
192+
"noTestsAction": "ignore"
193+
}
194+
},
195+
{
196+
"name": "debug-shared",
197+
"description" : "Test shared libraries in Debug configuration",
198+
"displayName": "Debug Shared Libraries",
199+
"inherits": "common",
200+
"configurePreset": "shared",
201+
"configuration": "Debug"
202+
},
203+
{
204+
"name": "debug-static",
205+
"description" : "Test static libraries in Debug configuration",
206+
"displayName": "Debug Static Libraries",
207+
"inherits": "common",
208+
"configurePreset": "static",
209+
"configuration": "Debug"
210+
},
211+
{
212+
"name": "release-shared",
213+
"description" : "Test shared libraries in Release configuration",
214+
"displayName": "Release Shared Libraries",
215+
"inherits": "common",
216+
"configurePreset": "shared",
217+
"configuration": "Release"
218+
},
219+
{
220+
"name": "release-static",
221+
"description" : "Test static libraries in Release configuration",
222+
"displayName": "Release Static Libraries",
223+
"inherits": "common",
224+
"configurePreset": "static",
225+
"configuration": "Release"
226+
}
227+
],
228+
"packagePresets": [
229+
{
230+
"name": "common",
231+
"description": "Common package settings",
232+
"hidden": true,
233+
"output": {
234+
"debug": false,
235+
"verbose": true
236+
},
237+
"configurations": ["Debug", "Release"],
238+
"generators": ["ZIP", "TGZ"]
239+
},
240+
{
241+
"name": "shared",
242+
"description": "Package shared libraries",
243+
"displayName": "Shared Libraries",
244+
"inherits": "common",
245+
"configurePreset": "shared"
246+
},
247+
{
248+
"name": "static",
249+
"description": "Package static libraries",
250+
"displayName": "Static Libraries",
251+
"inherits": "common",
252+
"configurePreset": "static"
253+
}
254+
],
255+
"workflowPresets": [
256+
{
257+
"name": "ci-shared",
258+
"description": "Run Debug and Release configurations for shared libraries",
259+
"displayName": "Shared Libraries",
260+
"steps": [
261+
{
262+
"type": "configure",
263+
"name": "shared"
264+
},
265+
{
266+
"type": "build",
267+
"name": "debug-shared"
268+
},
269+
{
270+
"type": "test",
271+
"name": "debug-shared"
272+
},
273+
{
274+
"type": "build",
275+
"name": "release-shared"
276+
},
277+
{
278+
"type": "test",
279+
"name": "release-shared"
280+
},
281+
{
282+
"type": "package",
283+
"name": "shared"
284+
}
285+
]
286+
},
287+
{
288+
"name": "ci-static",
289+
"description": "Run Debug and Release configurations for static libraries",
290+
"displayName": "Static Libraries",
291+
"steps": [
292+
{
293+
"type": "configure",
294+
"name": "static"
295+
},
296+
{
297+
"type": "build",
298+
"name": "debug-static"
299+
},
300+
{
301+
"type": "test",
302+
"name": "debug-static"
303+
},
304+
{
305+
"type": "build",
306+
"name": "release-static"
307+
},
308+
{
309+
"type": "test",
310+
"name": "release-static"
311+
},
312+
{
313+
"type": "package",
314+
"name": "static"
315+
}
316+
]
317+
}
318+
]
319+
}

0 commit comments

Comments
 (0)