forked from triSYCL/triSYCL
-
Notifications
You must be signed in to change notification settings - Fork 1
259 lines (229 loc) · 10.6 KB
/
cmake.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
name: CMake
on:
# Triggers the workflow on push, PR or manual dispatch
push:
branches:
# Also launch the CI when creating a tag
tags:
pull_request:
# Allows you to run this workflow manually from the Actions tab by
# selection CMake and then "Run workflow" menu on the right branch
# and clicking on "launch_tmate_terminal_for_debug".
# Unfortunately this works only for the default branch.
# So you can either
# - change as the default one default the branch of the PR on the
# GitHub repository owning the PR and launching in Actions tab;
# - or edit directly the step below which runs tmate and push to the
# PR, ignoring the manual workflow launch.
workflow_dispatch:
inputs:
launch_tmate_terminal_for_debug:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
compilation_time_out:
type: number
description: Run the build with a timeout in minutes to have
partial compilation to bootstrap ccache
required: false
default: 10
defaults:
run:
# This is already the default, except when running inside another Docker
# image, which is the case here. So set it up globally to avoid
# repeating elsewhere.
shell: bash
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build-and-test:
name: Run the validation inside Docker with specific OS and options
# By latest GitHub means actually latest LTS only
runs-on: ubuntu-latest
# Run into an even more recent Ubuntu inside Docker to have recent
# compilers and C++ standard library
container:
# Ubuntu 24.10
image: docker://ubuntu:oracular
strategy:
# Run all the test even if there are some which fail
fail-fast: false
matrix:
include:
- c_compiler: gcc-14
cxx_compiler: g++-14
OpenMP: ON
OpenCL: OFF
- c_compiler: gcc-14
cxx_compiler: g++-14
OpenMP: ON
OpenCL: ON
- c_compiler: clang-20
cxx_compiler: clang++-20
OpenMP: ON
OpenCL: OFF
- c_compiler: clang-20
cxx_compiler: clang++-20
OpenMP: ON
OpenCL: ON
# Cancel old CI jobs for a PR when the PR is updated
concurrency:
# Create a job equivalence class with an id crafted to only
# cancel in-progress runs of the same workflow and same
# job-index in the matrix
group: '${{ github.workflow }}-job-index-${{ strategy.job-index }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }} for ${{ matrix }}'
# Cancel only pull-request related events
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
steps:
- name: Display environment variables
run: env
- name: User and group ids
run: id -a
- name: Execution context information
# Display a lot of information to help further development
# https://docs.github.com/en/actions/learn-github-actions/variables
# https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/contexts
# The problem is that echo-ing directly "${{ toJSON(github) }}"
# in the shell is not escaped and for example '&' breaks
# things or can lead to server-side script injection. :-(
# So, use environment setting and display the environment
# variable in the shell between "" to avoid unsafe
# interpretation.
env:
execution_context_var_github: ${{ toJSON(github) }}
execution_context_var_env: ${{ toJSON(env) }}
execution_context_var_vars: ${{ toJSON(vars) }}
execution_context_var_job: ${{ toJSON(job) }}
execution_context_var_steps: ${{ toJSON(steps) }}
execution_context_var_runner: ${{ toJSON(runner) }}
execution_context_var_strategy: ${{ toJSON(strategy) }}
execution_context_var_matrix: ${{ toJSON(matrix) }}
execution_context_var_needs: ${{ toJSON(needs) }}
execution_context_var_inputs: ${{ toJSON(inputs) }}
run: |
echo "::group::github context"
echo "$execution_context_var_github"
echo "::endgroup::"
echo "::group::env context"
echo "$execution_context_var_env"
echo "::endgroup::"
echo "::group::vars context"
echo "$execution_context_var_vars"
echo "::endgroup::"
echo "::group::job context"
echo "$execution_context_var_job"
echo "::endgroup::"
echo "::group::steps context"
echo "$execution_context_var_steps"
echo "::endgroup::"
echo "::group::runner context"
echo "$execution_context_var_runner"
echo "::endgroup::"
echo "::group::strategy context"
echo "$execution_context_var_strategy"
echo "::endgroup::"
echo "::group::matrix context"
echo "$execution_context_var_matrix"
echo "::endgroup::"
echo "::group::needs context"
echo "$execution_context_var_needs"
echo "::endgroup::"
echo "::group::inputs context"
echo "$execution_context_var_inputs"
echo "::endgroup::"
- name: Install required packages
run: |
apt-get update
apt-get install -y build-essential cmake g++ gdb git \
libboost-all-dev libgtkmm-3.0-dev librange-v3-dev \
pkgconf
- name: Check out repository code
uses: actions/checkout@v4
- name: Declare LLVM package repository if needed
if: startsWith(matrix.c_compiler, 'clang') || startsWith(matrix.cxx_compiler, 'clang')
run: |
apt-get install -y wget
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
# "Parse" the Linux distribution parameters
source /etc/os-release
echo "deb http://apt.llvm.org/$VERSION_CODENAME llvm-toolchain-$VERSION_CODENAME main" \
> /etc/apt/sources.list.d/llvm.list
echo "deb-src http://apt.llvm.org/$VERSION_CODENAME llvm-toolchain-$VERSION_CODENAME main" \
>> /etc/apt/sources.list.d/llvm.list
apt-get update
- name: Install the C compiler
run: apt-get install -y ${{matrix.c_compiler}}
- name: Install the C++ compiler
# Do not install the C++ compiler if it is clang++ since it comes
# along the Clang C compiler. Need "${{ }}" because it starts
# with "!"
if: ${{ !startsWith(matrix.cxx_compiler, 'clang') }}
run: apt-get install -y ${{matrix.cxx_compiler}}
- name: Install OpenMP support if needed
# Clang requires a specific OpenMP library to run
if: matrix.OpenMP == 'ON' && startsWith(matrix.cxx_compiler, 'clang')
run: |
# Get the clang++ version, which is what is left when we remove "clang++-"
CXX_COMPILER=${{matrix.cxx_compiler}}
cxx_compiler_version=${CXX_COMPILER#clang++-}
apt-get install -y libomp-${cxx_compiler_version}-dev
- name: Install OpenCL with PoCL if needed
if: matrix.OpenCL == 'ON'
run: apt-get install -y opencl-headers ocl-icd-opencl-dev libpocl-dev
# Use ccache to speed-up compilation to also fit into GitHub Actions
# resource limitations, see:
# https://github.com/hendrikmuhs/ccache-action
# The cache is saved in a "Post install-ccache" step, even if
# the job is canceled or some previous step fails, which is good
# to avoid wasting constrained compilation resources
- name: install-ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
max-size: "1G"
key: ${{runner.os}}-${{matrix.c_compiler}}-${{matrix.cxx_compiler}}-${{matrix.OpenMP}}-${{matrix.OpenCL}}
- name: Configure CMake for ${{matrix.c_compiler}}, ${{matrix.cxx_compiler}},
OpenMP=${{matrix.OpenMP}}, OpenCL=${{matrix.OpenCL}}
# Create the build directory in ${{github.workspace}}/build
# and inject ccache in the build system
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DTRISYCL_OPENCL=${{matrix.OpenCL}} -DTRISYCL_OPENMP=${{matrix.OpenMP}}
-DCMAKE_C_COMPILER=${{matrix.c_compiler}} -DCMAKE_CXX_COMPILER=${{matrix.cxx_compiler}}
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Build for ${{matrix.c_compiler}}, ${{matrix.cxx_compiler}},
OpenMP=${{matrix.OpenMP}}, OpenCL=${{matrix.OpenCL}}
# Some atrocities here because if the time-out value comes
# from a variable of type 'number' it actually is interpreted
# as a string and parsing fails. GitHub bug or expression
# typing fuzziness? So, first use toJSON() to test for
# non-existence of the variable to return null which is
# implicitly up-casted to a string by the comparison and
# returns a default timeout value for 1 day. Otherwise, if the
# variable is set, interpret the string number as JSON to
# force the type to be a number.
timeout-minutes: ${{ ((toJSON(inputs.compilation_time_out) == 'null') && 1440)
|| fromJSON(inputs.compilation_time_out) }}
# Compile all the tests using all the available cores
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
--verbose --parallel `nproc`
# Launch an ssh session via a proxy server if there is a need
# for debug. This seems to live for 35 min max
# https://github.com/mxschmitt/action-tmate
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
# To run this, launch it manually on the default branch and
# click on "launch_tmate_terminal_for_debug"
if: github.event_name == 'workflow_dispatch'
&& inputs.launch_tmate_terminal_for_debug
with:
# Since we run in Docker, no need to use sudo
sudo: false
- name: Test for ${{matrix.c_compiler}}, ${{matrix.cxx_compiler}},
OpenMP=${{matrix.OpenMP}}, OpenCL=${{matrix.OpenCL}}
# Run the tests which do not use the GUI since there is no
# display or user
run: |
# Request unlimited stack size needed for some tests
ulimit -s unlimited
ctest --label-exclude GUI --test-dir ${{github.workspace}}/build --build-config ${{env.BUILD_TYPE}}