19
19
- v**
20
20
21
21
env :
22
- CMAKE_VERSION : 3.26.3
23
- NINJA_VERSION : 1.11.1
24
22
BUILD_TYPE : Release
25
- CCACHE_VERSION : 4.7.3
26
23
27
24
jobs :
28
25
build :
@@ -58,53 +55,42 @@ jobs:
58
55
vcpkg_triplet : x64-osx-release
59
56
}
60
57
58
+ defaults :
59
+ run :
60
+ # Run scripts with project directory as working directory
61
+ working-directory : ./
62
+ # Use bash as default shell
63
+ shell : bash
64
+
61
65
steps :
62
66
- uses : actions/checkout@v3
63
67
64
- - name : Download Ninja and CMake
65
- shell : cmake -P {0}
68
+ - name : Install Ninja
69
+ shell : bash
66
70
run : |
67
- set(cmake_version $ENV{CMAKE_VERSION})
68
- set(ninja_version $ENV{NINJA_VERSION})
69
-
70
- message(STATUS "Using host CMake version: ${CMAKE_VERSION}")
71
-
72
- if ("${{ runner.os }}" STREQUAL "Windows")
73
- set(ninja_suffix "win.zip")
74
- set(cmake_suffix "windows-x86_64.zip")
75
- set(cmake_dir "cmake-${cmake_version}-windows-x86_64/bin")
76
- elseif ("${{ runner.os }}" STREQUAL "Linux")
77
- set(ninja_suffix "linux.zip")
78
- set(cmake_suffix "linux-x86_64.tar.gz")
79
- set(cmake_dir "cmake-${cmake_version}-linux-x86_64/bin")
80
- elseif ("${{ runner.os }}" STREQUAL "macOS")
81
- set(ninja_suffix "mac.zip")
82
- set(cmake_suffix "macos-universal.tar.gz")
83
- set(cmake_dir "cmake-${cmake_version}-macos-universal/CMake.app/Contents/bin")
84
- endif()
85
-
86
- set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}")
87
- file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS)
88
- execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip)
89
-
90
- set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}")
91
- file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS)
92
- execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip)
93
-
94
- # Add to PATH environment variable
95
- file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir)
96
- set(path_separator ":")
97
- if ("${{ runner.os }}" STREQUAL "Windows")
98
- set(path_separator ";")
99
- endif()
100
- file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${cmake_dir}")
71
+ if [ "$RUNNER_OS" == "Linux" ]; then
72
+ sudo apt-get install -y ninja-build
73
+ elif [ "$RUNNER_OS" == "Windows" ]; then
74
+ choco install ninja
75
+ elif [ "$RUNNER_OS" == "macOS" ]; then
76
+ brew install ninja
77
+ fi
78
+
79
+ - name : Install ccache
80
+ shell : bash
81
+ run : |
82
+ if [ "$RUNNER_OS" == "Linux" ]; then
83
+ sudo apt-get install -y ccache
84
+ elif [ "$RUNNER_OS" == "Windows" ]; then
85
+ choco install ccache
86
+ elif [ "$RUNNER_OS" == "macOS" ]; then
87
+ brew install ccache
88
+ fi
101
89
102
- if (NOT "${{ runner.os }}" STREQUAL "Windows")
103
- execute_process(
104
- COMMAND chmod +x ninja
105
- COMMAND chmod +x ${cmake_dir}/cmake
106
- )
107
- endif()
90
+ - name : Install Ubuntu dependencies
91
+ if : runner.os == 'Linux'
92
+ shell : bash
93
+ run : sudo apt-get install -y libwxgtk3.0-gtk3-dev libgtest-dev rpm
108
94
109
95
- name : vcpkg build
110
96
if : runner.os != 'Linux'
@@ -116,19 +102,6 @@ jobs:
116
102
revision : master
117
103
token : ${{ github.token }}
118
104
119
- - name : Install Ubuntu dependencies
120
- if : runner.os == 'Linux'
121
- shell : bash
122
- run : sudo apt-get -y install libwxgtk3.0-gtk3-dev rpm libgtest-dev
123
-
124
- - name : Download ccache
125
- id : ccache
126
- shell : cmake -P {0}
127
- run : |
128
- set(ccache_url "https://github.com/cristianadam/ccache/releases/download/v$ENV{CCACHE_VERSION}/${{ runner.os }}.tar.xz")
129
- file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS)
130
- execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ccache.tar.xz)
131
-
132
105
- name : Prepare ccache timestamp
133
106
id : ccache_cache_timestamp
134
107
shell : cmake -P {0}
@@ -145,115 +118,23 @@ jobs:
145
118
${{ matrix.config.name }}-ccache-
146
119
147
120
- name : Configure
148
- shell : cmake -P {0}
121
+ env :
122
+ CC : ${{ matrix.config.cc }}
123
+ CXX : ${{ matrix.config.cxx }}
124
+ ENVIRONMENT_SCRIPT : ${{ matrix.config.environment_script }}
125
+ RUNNER_OS : ${{ runner.os }}
126
+ VCPKG_TRIPLET : ${{ matrix.config.vcpkg_triplet }}
149
127
run : |
150
- set(ENV{CC} ${{ matrix.config.cc }})
151
- set(ENV{CXX} ${{ matrix.config.cxx }})
152
-
153
- if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
154
- execute_process(
155
- COMMAND "${{ matrix.config.environment_script }}" && set
156
- OUTPUT_FILE environment_script_output.txt
157
- )
158
- file(STRINGS environment_script_output.txt output_lines)
159
- foreach(line IN LISTS output_lines)
160
- if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
161
- set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
162
- endif()
163
- endforeach()
164
- endif()
165
-
166
- set(path_separator ":")
167
- if ("${{ runner.os }}" STREQUAL "Windows")
168
- set(path_separator ";")
169
- endif()
170
- set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
171
-
172
- if (NOT "${{ runner.os }}" STREQUAL "Linux")
173
- file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/vcpkg/scripts/buildsystems/vcpkg.cmake" toolchain_file)
174
-
175
- if("${{ runner.os }}" STREQUAL "Windows" AND ${{ matrix.config.cxx }} STREQUAL "g++")
176
- execute_process(
177
- COMMAND cmake
178
- -S .
179
- -B build
180
- -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
181
- -G "MinGW Makefiles"
182
- -D CMAKE_C_COMPILER_LAUNCHER=ccache
183
- -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
184
- -D CMAKE_TOOLCHAIN_FILE=${toolchain_file} -DVCPKG_TARGET_TRIPLET=${{ matrix.config.vcpkg_triplet }} -DVCPKG_HOST_TRIPLET=${{ matrix.config.vcpkg_triplet }}
185
- RESULT_VARIABLE result
186
- )
187
- else()
188
- execute_process(
189
- COMMAND cmake
190
- -S .
191
- -B build
192
- -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
193
- -D CMAKE_C_COMPILER_LAUNCHER=ccache
194
- -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
195
- -D CMAKE_TOOLCHAIN_FILE=${toolchain_file} -DVCPKG_TARGET_TRIPLET=${{ matrix.config.vcpkg_triplet }} -DVCPKG_HOST_TRIPLET=${{ matrix.config.vcpkg_triplet }}
196
- RESULT_VARIABLE result
197
- )
198
- endif()
199
- else()
200
- execute_process(
201
- COMMAND cmake
202
- -S .
203
- -B build
204
- -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
205
- -G Ninja
206
- -D CMAKE_MAKE_PROGRAM=ninja
207
- -D CMAKE_C_COMPILER_LAUNCHER=ccache
208
- -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
209
- RESULT_VARIABLE result
210
- )
211
- endif()
212
-
213
- if (NOT result EQUAL 0)
214
- message(FATAL_ERROR "Bad exit status")
215
- endif()
128
+ chmod a+x ./.github/scripts/*.cmake
129
+ cmake -P ./.github/scripts/configure.cmake
216
130
217
131
- name : Build
218
- shell : cmake -P {0}
132
+ env :
133
+ CXX : ${{ matrix.config.cxx }}
134
+ ENVIRONMENT_SCRIPT : ${{ matrix.config.environment_script }}
135
+ RUNNER_OS : ${{ runner.os }}
219
136
run : |
220
- set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
221
-
222
- if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
223
- file(STRINGS environment_script_output.txt output_lines)
224
- foreach(line IN LISTS output_lines)
225
- if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
226
- set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
227
- endif()
228
- endforeach()
229
- endif()
230
-
231
- file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}" ccache_basedir)
232
- set(ENV{CCACHE_BASEDIR} "${ccache_basedir}")
233
- set(ENV{CCACHE_DIR} "${ccache_basedir}/.ccache")
234
- set(ENV{CCACHE_COMPRESS} "true")
235
- set(ENV{CCACHE_COMPRESSLEVEL} "6")
236
- set(ENV{CCACHE_MAXSIZE} "400M")
237
- if ("${{ matrix.config.cxx }}" STREQUAL "cl")
238
- set(ENV{CCACHE_MAXSIZE} "600M")
239
- endif()
240
-
241
- execute_process(COMMAND ccache -p)
242
- execute_process(COMMAND ccache -z)
243
-
244
- execute_process(
245
- COMMAND cmake --build build --config $ENV{BUILD_TYPE}
246
- RESULT_VARIABLE result
247
- OUTPUT_VARIABLE output
248
- ERROR_VARIABLE output
249
- ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
250
- )
251
- if (NOT result EQUAL 0)
252
- string(REGEX MATCH "FAILED:.*$" error_message "${output}")
253
- string(REPLACE "\n" "%0A" error_message "${error_message}")
254
- message("::error::${error_message}")
255
- message(FATAL_ERROR "Build failed")
256
- endif()
137
+ cmake -P ./.github/scripts/build.cmake
257
138
258
139
- name : ccache statistics
259
140
shell : cmake -P {0}
@@ -265,27 +146,7 @@ jobs:
265
146
execute_process(COMMAND ccache -s)
266
147
267
148
- name : Run tests
268
- shell : cmake -P {0}
269
- run : |
270
- include(ProcessorCount)
271
- ProcessorCount(N)
272
-
273
- set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")
274
-
275
- execute_process(
276
- COMMAND ctest -j ${N} -C $ENV{BUILD_TYPE}
277
- WORKING_DIRECTORY build
278
- RESULT_VARIABLE result
279
- OUTPUT_VARIABLE output
280
- ERROR_VARIABLE output
281
- ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
282
- )
283
- if (NOT result EQUAL 0)
284
- string(REGEX MATCH "[0-9]+% tests.*[0-9.]+ sec.*$" test_results "${output}")
285
- string(REPLACE "\n" "%0A" test_results "${test_results}")
286
- message("::error::${test_results}")
287
- message(FATAL_ERROR "Running tests failed!")
288
- endif()
149
+ run : cmake -P ./.github/scripts/test.cmake
289
150
290
151
- name : Install Strip
291
152
run : cmake --install build --prefix instdir --strip
0 commit comments