-
Notifications
You must be signed in to change notification settings - Fork 6
375 lines (309 loc) · 13.8 KB
/
dev-ci.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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
name: Dev CI
on:
workflow_dispatch:
inputs:
generate_artifacts:
description: 'Generate and upload build artifacts'
required: true
default: false
type: boolean
pull_request:
permissions: { }
# Cancel previous workflows if they are the same workflow on same ref (branch/tags)
# with the same event (push/pull_request) even they are in progress.
# This setting will help reduce the number of duplicated workflows.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
java:
name: Build Java ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- name: Set up JDK 17
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
distribution: 'temurin'
java-version: '17'
- name: Checkout sources
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Build with Maven (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: ./mvnw --batch-mode -Pjacoco install
- name: Build with Maven (Windows)
if: matrix.os == 'windows-latest'
run: mvnw.cmd --batch-mode install
shell: cmd
- name: Build with Maven (MacOS)
if: matrix.os == 'macos-latest'
run: ./mvnw --batch-mode install
- name: Run SonarCloud analysis
if: matrix.os == 'ubuntu-latest'
run: >
./mvnw --batch-mode -DskipTests sonar:sonar
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=powsybl-ci-github
-Dsonar.projectKey=com.powsybl:powsybl-metrix
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Get Maven version
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name == 'workflow_dispatch' && inputs.generate_artifacts }}
run: echo "MAVEN_PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: Upload Metrix iTools archive
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name == 'workflow_dispatch' && inputs.generate_artifacts }}
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # 4.3.3
with:
name: itools-metrix-${{ env.MAVEN_PROJECT_VERSION }}
path: ${{ github.workspace }}/metrix-distribution/target/metrix
cpp_centos7:
name: Build C++ CentOS7
runs-on: ubuntu-latest
container: 'centos:centos7'
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: Update mirrors
run: |
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
- name: Update Dependencies
run: |
yum update -y
- name: Install Dependencies 1
run: |
yum install -y epel-release
- name: Install Dependencies 2
run: |
yum install -y git redhat-lsb-core make wget centos-release-scl scl-utils
- name: Update mirrors again because why not
run: |
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
- name: Install Dependencies 3
run: |
yum install -y devtoolset-9
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.22.x'
- name: Checkout sources
uses: actions/checkout@v3
- name: Download Boost-release
uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 # v1.1.1
with:
repo: 'ARnDOSrte/Boost'
file: 'boost_1_73_0.zip'
target: 'boost_1_73_0.zip'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Unzip Boost
run: unzip boost_1_73_0.zip
- name: Configure 3rd parties
run: |
source /opt/rh/devtoolset-9/enable
cmake -S $GITHUB_WORKSPACE/metrix-simulator/external -B $GITHUB_WORKSPACE/metrix-simulator/build/external
- name: Build 3rd parties
run: |
cmake --build $GITHUB_WORKSPACE/metrix-simulator/build/external --parallel 2
- name: Configure CMake
run: |
source /opt/rh/devtoolset-9/enable
cmake -S $GITHUB_WORKSPACE/metrix-simulator -Wno-dev -DCMAKE_BUILD_TYPE=Release -DBoost_ROOT=$GITHUB_WORKSPACE/__w/Boost/Boost/boost_1_73_0/installBoost -DBoost_INCLUDE_DIR=$GITHUB_WORKSPACE/__w/Boost/Boost/boost_1_73_0/installBoost -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/metrix-simulator/build/install -B $GITHUB_WORKSPACE/metrix-simulator/build
- name: Build
run: cmake --build $GITHUB_WORKSPACE/metrix-simulator/build --target install --parallel 2
- name: Tests
run: cd $GITHUB_WORKSPACE/metrix-simulator/build && ctest -j2 --output-on-failure
- name: Upload Metrix Simulator archive
if: ${{ github.event_name == 'workflow_dispatch' && inputs.generate_artifacts }}
uses: actions/upload-artifact@v3
with:
name: metrix-simulator-centos7
path: |
metrix-simulator/build/install/bin
metrix-simulator/build/install/etc
cpp_oraclelinux8:
name: Build C++ Oracle Linux 8
runs-on: ubuntu-latest
container: 'oraclelinux:8'
steps:
- name: Install Boost
run: |
yum update -y
yum install cmake make gcc gcc-c++ which git
dnf --enablerepo=ol8_codeready_builder install boost-static
- name: Checkout sources
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Configure 3rd parties
run: >
cmake -S $GITHUB_WORKSPACE/metrix-simulator/external -B $GITHUB_WORKSPACE/metrix-simulator/build/external
- name: Build 3rd parties
run: >
cmake --build $GITHUB_WORKSPACE/metrix-simulator/build/external --parallel 2
- name: Configure CMake
run: >
cmake -Wno-dev -S $GITHUB_WORKSPACE/metrix-simulator -B $GITHUB_WORKSPACE/metrix-simulator/build
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/metrix-simulator/build/install
- name: Build
run: cmake --build $GITHUB_WORKSPACE/metrix-simulator/build --target install --parallel 2
- name: Tests
run: cd $GITHUB_WORKSPACE/metrix-simulator/build && ctest -j2 --output-on-failure
- name: Upload Metrix Simulator archive
if: ${{ github.event_name == 'workflow_dispatch' && inputs.generate_artifacts }}
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # 4.3.3
with:
name: metrix-simulator-ol8
path: |
metrix-simulator/build/install/bin
metrix-simulator/build/install/etc
cpp_ubuntu:
name: Build C++ Ubuntu
runs-on: ubuntu-latest
steps:
- name: Install Boost
run: |
sudo apt-get update -y
sudo apt-get install -y libboost-all-dev
- name: Checkout sources
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Configure 3rd parties
run: >
cmake -S $GITHUB_WORKSPACE/metrix-simulator/external -B $GITHUB_WORKSPACE/metrix-simulator/build/external
- name: Build 3rd parties
run: >
cmake --build $GITHUB_WORKSPACE/metrix-simulator/build/external --parallel 2
- name: Configure CMake
run: >
cmake -Wno-dev -S $GITHUB_WORKSPACE/metrix-simulator -B $GITHUB_WORKSPACE/metrix-simulator/build
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/metrix-simulator/build/install
- name: Build
run: cmake --build $GITHUB_WORKSPACE/metrix-simulator/build --target install --parallel 2
- name: Tests
run: cd $GITHUB_WORKSPACE/metrix-simulator/build && ctest -j2 --output-on-failure
- name: Upload Metrix Simulator archive
if: ${{ github.event_name == 'workflow_dispatch' && inputs.generate_artifacts }}
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # 4.3.3
with:
name: metrix-simulator-ubuntu
path: |
metrix-simulator/build/install/bin
metrix-simulator/build/install/etc
cpp_ubuntu_qa:
name: Short QA C++ Ubuntu
runs-on: ubuntu-latest
steps:
- name: Install Java 17
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
distribution: 'temurin'
java-version: '17'
- name: Install gcovr
run: |
sudo apt-get update -y
sudo apt-get install -y gcovr
- name: Install Sonar wrapper
working-directory: ${{ runner.workspace }}
run: |
wget https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip build-wrapper-linux-x86.zip
- name: Install Sonar scanner
working-directory: ${{ runner.workspace }}
run: |
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}.zip
unzip sonar-scanner-cli-${SONAR_SCANNER_VERSION}.zip
ln -s sonar-scanner-${SONAR_SCANNER_VERSION} sonar
rm sonar-scanner-cli-${SONAR_SCANNER_VERSION}.zip
env:
SONAR_SCANNER_VERSION: 3.3.0.1492
- name: Install Boost
run: |
sudo apt-get update -y
sudo apt-get install -y libboost-all-dev
- name: Checkout sources
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Configure 3rd parties
run: >
cmake -S $GITHUB_WORKSPACE/metrix-simulator/external -B $GITHUB_WORKSPACE/metrix-simulator/build/external
- name: Build 3rd parties
run: >
cmake --build $GITHUB_WORKSPACE/metrix-simulator/build/external --parallel 2
- name: Configure CMake
run: >
cmake -Wno-dev -S $GITHUB_WORKSPACE/metrix-simulator -B $GITHUB_WORKSPACE/metrix-simulator/build
-DCMAKE_BUILD_TYPE=Debug
-DCODE_COVERAGE=TRUE
-DMETRIX_RUN_ALL_TESTS=OFF
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/metrix-simulator/build/install
- name: Build
run: >
${{ runner.workspace }}/build-wrapper-linux-x86/build-wrapper-linux-x86-64
--out-dir $GITHUB_WORKSPACE/metrix-simulator/build/output
cmake --build $GITHUB_WORKSPACE/metrix-simulator/build --parallel 2 --target install
- name: Tests
run: cd $GITHUB_WORKSPACE/metrix-simulator/build && ctest -j2 --output-on-failure
- name: Code coverage
run: cmake --build $GITHUB_WORKSPACE/metrix-simulator/build --target code-coverage
- name: Sonarcloud
working-directory: ${{ runner.workspace }}/powsybl-metrix/metrix-simulator
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >
${{ runner.workspace }}/sonar/bin/sonar-scanner
-Dsonar.host.url=https://sonarcloud.io
cpp_clang_tidy:
name: Clang Tidy Report (PR only)
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' # github.base_ref exists only for PRs
steps:
- name: Install Boost
run: |
sudo apt-get update -y
sudo apt-get install -y libboost-all-dev
- name: Install clang-tidy
run: |
sudo apt install -y clang-tidy-15
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-15 100
- name: Checkout sources
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Git fetch base_ref and head_ref
run: |
git fetch --no-tags --depth=1 origin ${{ github.base_ref }} ${{ github.head_ref }}
git show-ref
- name: Configure 3rd parties
run: >
cmake -S $GITHUB_WORKSPACE/metrix-simulator/external -B $GITHUB_WORKSPACE/metrix-simulator/build/external
- name: Build 3rd parties
run: >
cmake --build $GITHUB_WORKSPACE/metrix-simulator/build/external --parallel 2
- name: Configure CMake
run: >
cmake -S $GITHUB_WORKSPACE/metrix-simulator -B $GITHUB_WORKSPACE/metrix-simulator/build
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Generate Clang Tidy Report (Modified C++ sources only)
id: clang-pr
run: |
REPORT_NAME="clang_tidy_report_pr.txt"
REPORT_PATH="$PWD/${REPORT_NAME}"
export METRIX_CPP_SOURCES=$(git diff --name-only --diff-filter=d origin/${{ github.base_ref }} origin/${{ github.head_ref }} | grep -E ".*(metrix-simulator/src|metrix-simulator/log).*\.(cpp|hpp)$")
if [ -n "$METRIX_CPP_SOURCES" ]; then
clang-tidy $METRIX_CPP_SOURCES -p $GITHUB_WORKSPACE/metrix-simulator/build > $REPORT_NAME || true
echo "report_exists=true" >> "$GITHUB_OUTPUT"
echo "report_name=$REPORT_NAME" >> "$GITHUB_OUTPUT"
echo "report_path=$REPORT_PATH" >> "$GITHUB_OUTPUT"
else
echo "No C++ source file modification found in this PR, no Clang Tidy report will be generated"
fi
- name: Upload Clang Tidy Report (Modified C++ sources in PR)
if: steps.clang-pr.outputs.report_exists
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # 4.3.3
with:
name: ${{ steps.clang-pr.outputs.report_name }}
path: ${{ steps.clang-pr.outputs.report_path }}