Skip to content

Commit a53a494

Browse files
authored
add github actions
1 parent 3cef846 commit a53a494

File tree

1 file changed

+267
-0
lines changed

1 file changed

+267
-0
lines changed

.github/workflows/rxcpp-ci.yml

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
name: rxcpp CI
2+
3+
# Trigger on pushes to all branches and for all pull-requests
4+
on: [push, pull_request]
5+
6+
env:
7+
CMAKE_VERSION: 3.16.2
8+
NINJA_VERSION: 1.9.0
9+
10+
11+
jobs:
12+
build:
13+
name: ${{ matrix.config.name }}
14+
runs-on: ${{ matrix.config.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
config:
19+
- {
20+
name: "Linux GCC 9 Debug (C++17)", artifact: "Linux.tar.xz",
21+
os: ubuntu-latest,
22+
build_type: Debug,
23+
cc: "gcc-9", cxx: "g++-9"
24+
}
25+
- {
26+
name: "Linux GCC 9 Optimised (C++17)", artifact: "Linux.tar.xz",
27+
os: ubuntu-latest,
28+
build_type: RelWithDebInfo,
29+
cc: "gcc-9", cxx: "g++-9"
30+
}
31+
- {
32+
name: "Linux Clang 10 Debug (C++17)", artifact: "Linux.tar.xz",
33+
os: ubuntu-latest,
34+
build_type: Debug,
35+
cc: "clang-10", cxx: "clang++-10",
36+
cmake_args: "-D \"CMAKE_CXX_FLAGS:STRING=-fsanitize=address -fno-omit-frame-pointer\""
37+
}
38+
- {
39+
name: "Linux Clang 10 Optimised (C++17)", artifact: "Linux.tar.xz",
40+
os: ubuntu-latest,
41+
build_type: RelWithDebInfo,
42+
cc: "clang-10", cxx: "clang++-10",
43+
cmake_args: "-D \"CMAKE_CXX_FLAGS:STRING=-fsanitize=address -fno-omit-frame-pointer\""
44+
}
45+
- {
46+
name: "Linux Clang 11 Debug (C++17)", artifact: "Linux.tar.xz",
47+
os: ubuntu-latest,
48+
build_type: Debug,
49+
cc: "clang-11", cxx: "clang++-11",
50+
cmake_args: "-D \"CMAKE_CXX_FLAGS:STRING=-fsanitize=address -fno-omit-frame-pointer\""
51+
}
52+
- {
53+
name: "Linux Clang 11 Optimised (C++17)", artifact: "Linux.tar.xz",
54+
os: ubuntu-latest,
55+
build_type: RelWithDebInfo,
56+
cc: "clang-11", cxx: "clang++-11",
57+
cmake_args: "-D \"CMAKE_CXX_FLAGS:STRING=-fsanitize=address -fno-omit-frame-pointer\""
58+
}
59+
- {
60+
name: "Linux Clang 12 Debug (C++17)", artifact: "Linux.tar.xz",
61+
os: ubuntu-latest,
62+
build_type: Debug,
63+
cc: "clang-12", cxx: "clang++-12",
64+
cmake_args: "-D \"CMAKE_CXX_FLAGS:STRING=-fsanitize=address -fno-omit-frame-pointer\""
65+
}
66+
- {
67+
name: "Linux Clang 12 Optimised (C++17)", artifact: "Linux.tar.xz",
68+
os: ubuntu-latest,
69+
build_type: RelWithDebInfo,
70+
cc: "clang-12", cxx: "clang++-12",
71+
cmake_args: "-D \"CMAKE_CXX_FLAGS:STRING=-fsanitize=address -fno-omit-frame-pointer\""
72+
}
73+
- {
74+
name: "macOS Clang Debug (C++17)", artifact: "macOS.tar.xz",
75+
os: macos-latest,
76+
build_type: Debug,
77+
cc: "clang", cxx: "clang++",
78+
cmake_args: "-D \"CMAKE_CXX_FLAGS:STRING=-fsanitize=address -fno-omit-frame-pointer\""
79+
}
80+
- {
81+
name: "macOS Clang Optimised (C++17)", artifact: "macOS.tar.xz",
82+
os: macos-latest,
83+
build_type: RelWithDebInfo,
84+
cc: "clang", cxx: "clang++",
85+
cmake_args: "-D \"CMAKE_CXX_FLAGS:STRING=-fsanitize=address -fno-omit-frame-pointer\""
86+
}
87+
- {
88+
name: "Windows MSVC 2019 Debug (C++17)", artifact: "Windows-MSVC.tar.xz",
89+
os: windows-latest,
90+
build_type: Debug,
91+
cc: "cl", cxx: "cl",
92+
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
93+
cmake_args: "-D CMAKE_CXX_STANDARD:STRING=17",
94+
experimental: true
95+
}
96+
- {
97+
name: "Windows MSVC 2019 Optimised (C++17)", artifact: "Windows-MSVC.tar.xz",
98+
os: windows-latest,
99+
build_type: RelWithDebInfo,
100+
cc: "cl", cxx: "cl",
101+
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
102+
cmake_args: "-D CMAKE_CXX_STANDARD:STRING=17",
103+
experimental: true
104+
}
105+
106+
steps:
107+
- uses: actions/checkout@v1
108+
109+
- name: Download Ninja and CMake
110+
id: cmake_and_ninja
111+
shell: cmake -P {0}
112+
run: |
113+
set(cmake_version $ENV{CMAKE_VERSION})
114+
set(ninja_version $ENV{NINJA_VERSION})
115+
116+
message(STATUS "Using host CMake version: ${CMAKE_VERSION}")
117+
118+
if ("${{ runner.os }}" STREQUAL "Windows")
119+
set(ninja_suffix "win.zip")
120+
set(cmake_suffix "win64-x64.zip")
121+
set(cmake_dir "cmake-${cmake_version}-win64-x64/bin")
122+
elseif ("${{ runner.os }}" STREQUAL "Linux")
123+
set(ninja_suffix "linux.zip")
124+
set(cmake_suffix "Linux-x86_64.tar.gz")
125+
set(cmake_dir "cmake-${cmake_version}-Linux-x86_64/bin")
126+
elseif ("${{ runner.os }}" STREQUAL "macOS")
127+
set(ninja_suffix "mac.zip")
128+
set(cmake_suffix "Darwin-x86_64.tar.gz")
129+
set(cmake_dir "cmake-${cmake_version}-Darwin-x86_64/CMake.app/Contents/bin")
130+
endif()
131+
132+
set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}")
133+
file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS)
134+
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip)
135+
136+
set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}")
137+
file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS)
138+
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip)
139+
140+
# Save the path for other steps
141+
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir)
142+
message("::set-output name=cmake_dir::${cmake_dir}")
143+
144+
if (NOT "${{ runner.os }}" STREQUAL "Windows")
145+
execute_process(
146+
COMMAND chmod +x ninja
147+
COMMAND chmod +x ${cmake_dir}/cmake
148+
)
149+
endif()
150+
151+
- name: Install Clang 10
152+
id: install_clang_10
153+
if: startsWith(matrix.config.os, 'ubuntu') && ( matrix.config.cxx == 'clang++-10' )
154+
shell: bash
155+
working-directory: ${{ env.HOME }}
156+
run: |
157+
wget https://apt.llvm.org/llvm.sh
158+
chmod +x llvm.sh
159+
sudo ./llvm.sh 10
160+
161+
- name: Install Clang 11
162+
id: install_clang_11
163+
if: startsWith(matrix.config.os, 'ubuntu') && ( matrix.config.cxx == 'clang++-11' )
164+
shell: bash
165+
working-directory: ${{ env.HOME }}
166+
run: |
167+
wget https://apt.llvm.org/llvm.sh
168+
chmod +x llvm.sh
169+
sudo ./llvm.sh 11
170+
171+
- name: Install Clang 12
172+
id: install_clang_12
173+
if: startsWith(matrix.config.os, 'ubuntu') && ( matrix.config.cxx == 'clang++-12' )
174+
shell: bash
175+
working-directory: ${{ env.HOME }}
176+
run: |
177+
wget https://apt.llvm.org/llvm.sh
178+
chmod +x llvm.sh
179+
sudo ./llvm.sh 12
180+
181+
- name: Configure
182+
shell: cmake -P {0}
183+
run: |
184+
set(ENV{CC} ${{ matrix.config.cc }})
185+
set(ENV{CXX} ${{ matrix.config.cxx }})
186+
187+
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
188+
execute_process(
189+
COMMAND "${{ matrix.config.environment_script }}" && set
190+
OUTPUT_FILE environment_script_output.txt
191+
)
192+
set(ENV{CXXFLAGS} "/permissive- /Zc:externConstexpr")
193+
file(STRINGS environment_script_output.txt output_lines)
194+
foreach(line IN LISTS output_lines)
195+
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
196+
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
197+
endif()
198+
endforeach()
199+
endif()
200+
201+
set(path_separator ":")
202+
if ("${{ runner.os }}" STREQUAL "Windows")
203+
set(path_separator ";")
204+
endif()
205+
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
206+
207+
execute_process(
208+
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake
209+
-S .
210+
-B build
211+
-D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }}
212+
-G Ninja
213+
-D CMAKE_MAKE_PROGRAM=ninja
214+
-D CMAKE_VERBOSE_MAKEFILE=ON
215+
${{ matrix.config.cmake_args }}
216+
RESULT_VARIABLE result
217+
)
218+
if (NOT result EQUAL 0)
219+
message(FATAL_ERROR "Bad exit status")
220+
endif()
221+
222+
- name: Build
223+
shell: cmake -P {0}
224+
continue-on-error: ${{ matrix.config.experimental || false }}
225+
run: |
226+
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
227+
228+
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
229+
file(STRINGS environment_script_output.txt output_lines)
230+
foreach(line IN LISTS output_lines)
231+
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
232+
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
233+
endif()
234+
endforeach()
235+
endif()
236+
237+
set(path_separator ":")
238+
if ("${{ runner.os }}" STREQUAL "Windows")
239+
set(path_separator ";")
240+
endif()
241+
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
242+
243+
execute_process(
244+
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake --build build
245+
RESULT_VARIABLE result
246+
)
247+
if (NOT result EQUAL 0)
248+
message(FATAL_ERROR "Bad exit status")
249+
endif()
250+
251+
- name: Run tests
252+
shell: cmake -P {0}
253+
continue-on-error: ${{ matrix.config.experimental || false }}
254+
run: |
255+
include(ProcessorCount)
256+
ProcessorCount(N)
257+
258+
set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")
259+
260+
execute_process(
261+
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/ctest --verbose -j ${N}
262+
WORKING_DIRECTORY build
263+
RESULT_VARIABLE result
264+
)
265+
if (NOT result EQUAL 0)
266+
message(FATAL_ERROR "Running tests failed!")
267+
endif()

0 commit comments

Comments
 (0)