-
Notifications
You must be signed in to change notification settings - Fork 1
215 lines (197 loc) · 7.5 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
name: CMake
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
name: OS ${{ matrix.os }} | Compiler ${{ matrix.compiler-name }} | Version ${{ matrix.compiler-version }}
strategy:
fail-fast: false
matrix:
os: [ macos-latest, ubuntu-latest ]
compiler-version: [ '' ]
compiler-name: [ '' ]
cc: [ '' ]
cxx: [ '' ]
include:
# MacOS CLANG
- os: macos-latest
compiler-name: llvm
compiler-version: 14
cc: /usr/local/opt/llvm@14/bin/clang-14
cxx: /usr/local/opt/llvm@14/bin/clang++
- os: macos-latest
compiler-name: llvm
compiler-version: 15
cc: /usr/local/opt/llvm@15/bin/clang-15
cxx: /usr/local/opt/llvm@15/bin/clang++
- os: macos-latest
compiler-name: llvm
compiler-version: 16
cc: /usr/local/opt/llvm@16/bin/clang-16
cxx: /usr/local/opt/llvm@16/bin/clang++
- os: macos-latest
compiler-name: llvm
compiler-version: 17
cc: /usr/local/opt/llvm@17/bin/clang-17
cxx: /usr/local/opt/llvm@17/bin/clang++
# MacOS GCC
- os: macos-latest
compiler-name: gcc
compiler-version: 10
cc: gcc-10
cxx: g++-10
- os: macos-latest
compiler-name: gcc
compiler-version: 11
cc: gcc-11
cxx: g++-11
- os: macos-latest
compiler-name: gcc
compiler-version: 12
cc: gcc-12
cxx: g++-12
- os: macos-latest
compiler-name: gcc
compiler-version: 13
cc: gcc-13
cxx: g++-13
# Ubuntu CLANG
- os: ubuntu-latest
compiler-name: llvm
compiler-version: 14
cc: clang-14
cxx: clang++-14
- os: ubuntu-latest
compiler-name: llvm
compiler-version: 15
cc: clang-15
cxx: clang++-15
# - os: ubuntu-latest
# compiler-name: llvm
# compiler-version: 16
# cc: clang-16
# cxx: clang++-16
# - os: ubuntu-latest
# compiler-name: llvm
# compiler-version: 17
# cc: clang-17
# cxx: clang++-17
# Ubuntu GCC
- os: ubuntu-latest
compiler-name: gcc
compiler-version: 10
cc: gcc-10
cxx: g++-10
- os: ubuntu-latest
compiler-name: gcc
compiler-version: 11
cc: gcc-11
cxx: g++-11
- os: ubuntu-latest
compiler-name: gcc
compiler-version: 12
cc: gcc-12
cxx: g++-12
- os: ubuntu-latest
compiler-name: gcc
compiler-version: 13
cc: gcc-13
cxx: g++-13
# Exclude the "base cases"
exclude:
- os: macos-latest
compiler-version: ''
compiler-name: ''
cc: ''
cxx: ''
- os: ubuntu-latest
compiler-version: ''
compiler-name: ''
cc: ''
cxx: ''
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install LLVM on MacOS
if: ${{ matrix.os == 'macos-latest' && matrix.compiler-name == 'llvm' }}
run: brew update && brew install llvm@${{ matrix.compiler-version }}
- name: Install GCC on MacOS
if: ${{ matrix.os == 'macos-latest' && matrix.compiler-name == 'gcc' }}
run: brew update && brew install gcc@${{ matrix.compiler-version }}
- name: Install LLVM on Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' && matrix.compiler-name == 'llvm' }}
run: sudo apt-get install -y clang-${{ matrix.compiler-version }} libomp-${{ matrix.compiler-version }}-dev
- name: Install GCC on Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' && matrix.compiler-name == 'gcc' }}
run: sudo apt-get install -y g++-${{ matrix.compiler-version }}
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.extra-cmake-arguments }}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}} -V
sonar:
name: SonarCloud
runs-on: ubuntu-latest
env:
SONAR_SCANNER_VERSION: 5.0.1.3006 # Find the latest version in the "Linux" link on this page:
# https://sonarcloud.io/documentation/analysis/scan/sonarscanner/
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Download and set up sonar-scanner
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
run: |
mkdir -p $HOME/.sonar
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
- name: Download and set up build-wrapper
env:
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
run: |
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
- name: Run build-wrapper
run: |
mkdir build
cmake -S . -B build
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"