-
Notifications
You must be signed in to change notification settings - Fork 40
553 lines (480 loc) · 19.3 KB
/
build-test.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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main, release* ]
# env:
# RUSTFLAGS: "-C debug-assertions"
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
source-code: ${{ steps.filter.outputs.source-code }}
markdown: ${{ steps.filter.outputs.markdown }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Check for changed file types
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
source-code:
- '!**/*.md'
markdown:
- '**/*.md'
preflight-check:
needs: changes
if: ${{ needs.changes.outputs.source-code == 'true' }}
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Check format of all commit messages
run: ./internal/scripts/ci_test_commit_msg.sh
- name: Check license header
run: ./internal/scripts/ci_test_spdx_license_header.sh
linting-markdown:
needs: changes
if: ${{ needs.changes.outputs.markdown == 'true' }}
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup GitHub CLI
run: |
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install linters
run: npm install -g markdownlint-cli prettier
- name: Check linting
env:
GH_TOKEN: ${{ github.token }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_BEFORE: ${{ github.event.before }}
GITHUB_AFTER: ${{ github.event.after }}
run: ./internal/scripts/check_markdown_linting.sh
static-code-analysis-rust:
needs: preflight-check
if: ${{ needs.changes.outputs.source-code == 'true' }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macOS-latest]
timeout-minutes: 10
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Run cargo clippy
run: cargo clippy -- -D warnings
- name: Run code examples in documentation
run: cargo test --workspace --doc
- name: Build documentation
run: cargo doc
static-code-analysis-cpp:
needs: preflight-check
if: ${{ needs.changes.outputs.source-code == 'true' }}
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install clang-tidy and clang-format
uses: ./.github/actions/install-iceoryx-deps-and-clang
- name: clang-format and clang-tidy versions
run: |
clang-format --version
clang-tidy --version
- name: Run clang-format
run: git ls-files | grep -E "\.(c|cc|cpp|cxx|inl|h|hh|hpp|hxx)$" | xargs clang-format -i -style=file --Werror --dry-run
- name: Run clang-tidy
run: |
git fetch origin main
internal/scripts/clang_tidy_scan.sh warning-as-error diff-to-main
# just to have a sync point for the C++ and Rust static code analysis
static-code-analysis:
needs: [static-code-analysis-cpp, static-code-analysis-rust]
runs-on: ubuntu-latest
steps:
- name: Static code analysis sync point
run: echo "Nothing to see, move along!"
cargo-nextest:
needs: preflight-check
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Build and cache cargo-nextest
uses: ./.github/actions/build-and-cache-rust-tool
with:
rust-toolchain: stable
check-and-install-cmd: cargo-nextest --version > /dev/null || cargo install cargo-nextest --locked
print-version-cmd: cargo-nextest --version
# increment cache-N-${{}} if a new nextest version is required
cache-key: cache-2-${{ runner.os }}-cargo-nextest
artifact-bin-name: cargo-nextest
artifact-upload-name: ${{ runner.os }}-cargo-nextest
x86_32:
needs: [preflight-check, static-code-analysis, cargo-nextest]
if: ${{ needs.changes.outputs.source-code == 'true' }}
strategy:
matrix:
os: [ubuntu-latest] # [windows-latest, ubuntu-latest, macos-latest]
toolchain: [stable] # [stable, 1.75.0, beta, nightly]
mode:
- name: "release"
arg: "--release"
cmake-build-type: "-DCMAKE_BUILD_TYPE=Release"
- name: "debug"
arg: ""
cmake-build-type: "-DCMAKE_BUILD_TYPE=Debug"
timeout-minutes: 60
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
targets: i686-unknown-linux-gnu
components: rustfmt, clippy
- name: Download artifact cargo-nextest
uses: ./.github/actions/download-cached-rust-tool
with:
artifact-bin-name: cargo-nextest
artifact-upload-name: ${{ runner.os }}-cargo-nextest
- name: Prepare Windows
if: ${{ matrix.os == 'windows-latest' }}
run: internal\scripts\ci_prepare_windows.ps1
- name: Prepare Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
internal/scripts/ci_prepare_ubuntu.sh
uname -a
- name: Run cargo build
run: cargo build --workspace --all-targets ${{ matrix.mode.arg }} --target i686-unknown-linux-gnu
- name: Run cargo nextest
run: cargo nextest run --workspace --all-targets --no-fail-fast ${{ matrix.mode.arg }} --target i686-unknown-linux-gnu
- name: Build language bindings
run: |
cmake -S . \
-B target/ffi/build \
-DCMAKE_INSTALL_PREFIX=target/ffi/install \
-DBUILD_CXX_BINDING=OFF \
-DBUILD_EXAMPLES=ON \
-DBUILD_TESTING=ON \
-DRUST_TARGET_TRIPLET="i686-unknown-linux-gnu" \
-DCMAKE_C_FLAGS="-m32" \
-DCMAKE_CXX_FLAGS="-m32" \
${{ matrix.mode.cmake-build-type }}
cmake --build target/ffi/build
cmake --install target/ffi/build
- name: Run language binding tests
run: target/ffi/build/tests/iceoryx2-c-tests
- name: Build C language binding examples in out-of-tree configuration
if: false # TODO: [#262] out-of-tree cross-compilation is currently not supported
run: |
rm -rf target/ffi/build
cmake -S examples/c \
-B target/ffi/out-of-tree-c \
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/target/ffi/install \
-DCMAKE_C_FLAGS="-m32" \
-DCMAKE_CXX_FLAGS="-m32" \
-${{ matrix.mode.cmake-build-type }}
cmake --build target/ffi/out-of-tree-c
- name: Build C++ language binding examples in out-of-tree configuration
if: false # TODO: [#262] out-of-tree cross-compilation is currently not supported
run: |
cmake -S examples/cxx \
-B target/ffi/out-of-tree-cxx \
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/target/ffi/install \
-DCMAKE_C_FLAGS="-m32" \
-DCMAKE_CXX_FLAGS="-m32" \
-${{ matrix.mode.cmake-build-type }}
cmake --build target/ffi/out-of-tree-cxx
x86_64:
needs: [preflight-check, static-code-analysis, cargo-nextest]
if: ${{ needs.changes.outputs.source-code == 'true' }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
# NOTE: enable for MinGW
# toolchain: [stable, stable-gnu, 1.75.0]
toolchain: [stable, 1.75.0]
mode:
- name: "release"
arg: "--release"
cmake-build-type: "-DCMAKE_BUILD_TYPE=Release" # required for Makefile Generators at config time
cmake-build-config: "--config Release" # required for Visual Studio at build and install time
- name: "debug"
arg: ""
cmake-build-type: "-DCMAKE_BUILD_TYPE=Debug" # required for Makefile Generators at config time
cmake-build-config: "--config Debug" # required for Visual Studio at build and install time
include:
# NOTE: enable for MinGW
# - toolchain: stable-gnu
# cmake-build-system-generator: '-G "MinGW Makefiles"'
- os: windows-latest
toolchain: stable
cmake-cxx-flags: '-DCMAKE_CXX_FLAGS="/MP"'
# NOTE: enable for MinGW
# exclude:
# - os: ubuntu-latest
# toolchain: stable-gnu
# - os: macos-latest
# toolchain: stable-gnu
timeout-minutes: 60
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy
- name: Download artifact cargo-nextest
uses: ./.github/actions/download-cached-rust-tool
with:
artifact-bin-name: cargo-nextest
artifact-upload-name: ${{ runner.os }}-cargo-nextest
- name: Prepare Windows
if: ${{ matrix.os == 'windows-latest' }}
run: internal\scripts\ci_prepare_windows.ps1
- name: Prepare Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
internal/scripts/ci_prepare_ubuntu.sh
uname -a
- name: Run cargo build
run: cargo build --workspace --all-targets ${{ matrix.mode.arg }}
- name: Run cargo nextest
run: cargo nextest run --workspace --all-targets --no-fail-fast ${{ matrix.mode.arg }}
- name: Build iceoryx_hoofs on Windows
if: ${{ matrix.os == 'windows-latest' }}
run: internal\scripts\ci_build_and_install_iceoryx_hoofs.ps1 -mode ${{ matrix.mode.name }} -toolchain ${{ matrix.toolchain }}
- name: Build iceoryx_hoofs on non-Windows
if: ${{ matrix.os != 'windows-latest' }}
run: internal/scripts/ci_build_and_install_iceoryx_hoofs.sh
- name: Print native libs of FFI target
if: false # This step takes 1 to 2 minutes; only enable if there are linker issues with the FFI target
run: |
cd iceoryx2-ffi/ffi
cargo rustc -q -- --print=native-static-libs
- name: Build language bindings
run: |
cmake -S . -B target/ffi/build -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON ${{ matrix.mode.cmake-build-type }} ${{ matrix.mode.cmake-cxx-flags }} ${{ matrix.cmake-build-system-generator }} -DCMAKE_INSTALL_PREFIX=target/ffi/install -DCMAKE_PREFIX_PATH="${{ github.workspace }}/target/iceoryx/install"
cmake --build target/ffi/build ${{ matrix.mode.cmake-build-config }}
cmake --install target/ffi/build ${{ matrix.mode.cmake-build-config }}
- name: Run C language binding tests
run: target/ffi/build/tests/iceoryx2-c-tests
- name: Run C++ language binding tests
run: target/ffi/build/tests/iceoryx2-cxx-tests
- name: Remove language binding build artifacts on Windows
if: ${{ matrix.os == 'windows-latest' }}
run: rm -r -force target/ffi/build
- name: Remove language binding build artifacts on non-Windows
if: ${{ matrix.os != 'windows-latest' }}
run: rm -rf target/ffi/build
- name: Build C language binding examples in out-of-tree configuration
run: |
cmake -S examples/c -B target/ffi/out-of-tree-c ${{ matrix.mode.cmake-build-type }} ${{ matrix.mode.cmake-cxx-flags }} ${{ matrix.cmake-build-system-generator }} -DCMAKE_PREFIX_PATH="${{ github.workspace }}/target/ffi/install"
cmake --build target/ffi/out-of-tree-c ${{ matrix.mode.cmake-build-config }}
- name: Build C++ language binding examples in out-of-tree configuration
run: |
cmake -S examples/cxx -B target/ffi/out-of-tree-cxx ${{ matrix.mode.cmake-build-type }} ${{ matrix.mode.cmake-cxx-flags }} ${{ matrix.cmake-build-system-generator }} -DCMAKE_PREFIX_PATH="${{ github.workspace }}/target/ffi/install;${{ github.workspace }}/target/iceoryx/install"
cmake --build target/ffi/out-of-tree-cxx ${{ matrix.mode.cmake-build-config }}
x86_64_unstable:
needs: [preflight-check, static-code-analysis, cargo-nextest]
if: ${{ needs.changes.outputs.source-code == 'true' && github.ref != 'refs/heads/main' }}
continue-on-error: true
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
toolchain: [beta, nightly]
mode:
- name: "release"
arg: "--release"
- name: "debug"
arg: ""
timeout-minutes: 60
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy
- name: Download artifact cargo-nextest
uses: ./.github/actions/download-cached-rust-tool
with:
artifact-bin-name: cargo-nextest
artifact-upload-name: ${{ runner.os }}-cargo-nextest
- name: Prepare Windows
if: ${{ matrix.os == 'windows-latest' }}
run: internal\scripts\ci_prepare_windows.ps1
- name: Prepare Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
internal/scripts/ci_prepare_ubuntu.sh
uname -a
- name: Run cargo build
run: cargo build --workspace --all-targets ${{ matrix.mode.arg }}
- name: Run cargo nextest
run: cargo nextest run --workspace --all-targets --no-fail-fast ${{ matrix.mode.arg }}
### TODO: does not work yet reliable on the GitHub CI, seems to end up in an infinite loop
### current alternative is a cirrus.yml aarch64 target
# arm:
# runs-on: ubuntu-latest
# if: ${{ needs.changes.outputs.source-code == 'true' }}
# strategy:
# matrix:
# architecture: ["aarch64"] # ["aarch64", "armv7"]
# toolchain: [ stable ] # [stable, 1.75.0, beta, nightly]
# mode: ["--release", ""]
# timeout-minutes: 30
# steps:
# - uses: actions/checkout@v4
# - uses: uraimo/run-on-arch-action@v2
# name: Run commands
# with:
# arch: ${{ matrix.architecture }}
# distro: archarm_latest
# run: |
# ./internal/scripts/ci_prepare_archlinux.sh
# rustup default ${{ matrix.toolchain }}
# cargo fmt --all -- --check
# cargo clippy -- -D warnings
# cargo build --workspace --all-targets ${{ matrix.mode }}
# cargo test --workspace --all-targets --no-fail-fast ${{ matrix.mode }}
freebsd:
needs: [preflight-check, static-code-analysis]
if: ${{ needs.changes.outputs.source-code == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
freebsd_version: [ "14.0" ]
toolchain: [ "stable", "1.75.0" ] # [stable, 1.75.0, beta, nightly]
mode: ["debug"] # ["release", "debug"]
steps:
- uses: actions/checkout@v4
- uses: vmactions/freebsd-vm@v1
with:
release: ${{ matrix.freebsd_version }}
mem: 16384
copyback: false
prepare: pkg install -y cmake curl gcc git llvm
run: |
git config --global --add safe.directory /home/runner/work/iceoryx2/iceoryx2
./internal/scripts/ci_prepare_freebsd.sh
./internal/scripts/ci_build_and_test_freebsd.sh --toolchain ${{ matrix.toolchain }} --mode ${{ matrix.mode }}
x86_64_bazel:
needs: [preflight-check, static-code-analysis]
if: ${{ needs.changes.outputs.source-code == 'true' }}
strategy:
matrix:
os: [ubuntu-24.04]
toolchain: [stable]
timeout-minutes: 60
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy
- name: Prepare Linux
run: |
internal/scripts/ci_prepare_ubuntu.sh
uname -a
- name: Run bazel build
run: bazel build //...
- name: Run bazel test
run: bazel test //...
grcov:
needs: [preflight-check, static-code-analysis]
if: ${{ needs.changes.outputs.source-code == 'true' }}
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and cache grcov
uses: ./.github/actions/build-and-cache-rust-tool
with:
rust-toolchain: stable
rust-components: llvm-tools-preview
check-and-install-cmd: grcov --version > /dev/null || cargo install grcov
print-version-cmd: grcov --version
cache-key: cache-1-${{ runner.os }}-grcov
artifact-bin-name: grcov
artifact-upload-name: ${{ runner.os }}-grcov
coverage:
needs: grcov
if: ${{ needs.changes.outputs.source-code == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get -y install libacl1-dev llvm
- name: Create test users and groups
run: |
sudo useradd testuser1
sudo useradd testuser2
sudo groupadd testgroup1
sudo groupadd testgroup2
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: llvm-tools-preview
- name: Download artifact grcov
uses: ./.github/actions/download-cached-rust-tool
with:
artifact-bin-name: grcov
artifact-upload-name: ${{ runner.os }}-grcov
- name: Generate raw coverage results
run: ./internal/scripts/generate-cov-report.sh --generate
- name: Generate coverage results for html artifacts
run: ./internal/scripts/generate-cov-report.sh --html
- name: Archive coverage-html artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: target/debug/coverage/html/*
retention-days: 90
- name: Generate coverage report for Codecov
run: ./internal/scripts/generate-cov-report.sh --lcov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: target/debug/coverage/lcov.info
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}