-
Notifications
You must be signed in to change notification settings - Fork 57
136 lines (115 loc) · 4.92 KB
/
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
name: CI
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
schedule:
- cron: "0 6 * * 1-5"
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
CARGO_PROFILE_DEV_DEBUG: false
jobs:
check_format:
name: Check codebase format with clang-format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run clang-format dry-run
run: find include/ src/ tests/ examples/ -iname "*.h" -o -iname "*.c" | xargs clang-format -n -Werror
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
shm: [false, true]
unstable: [false, true]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
run: rustup component add rustfmt clippy
- name: Run clippy
run: cargo clippy --all-targets --all-features -- --deny warnings
- name: Run rustfmt
run: cargo fmt --check -- --config "unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate"
- name: Check for feature leaks
run: cargo test --no-default-features
- name: Build and install
shell: bash
run: |
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake --build . --target install --config Release
- name: Install valgrind
uses: taiki-e/install-action@valgrind
if: matrix.os == 'ubuntu-latest'
- name: Run cmake tests with zenoh-c as dynamic library
shell: bash
run: |
cd build
cmake .. -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake --build . --target tests --config Release
ctest -C Release --output-on-failure -E "(unit_z_api_alignment_test|build_z_build_static)"
- name: Build cmake tests with C++ compiler to make sure that C API is C++ compatible
shell: bash
run: |
cd build
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DZENOHC_BUILD_TESTS_WITH_CXX=TRUE -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake --build . --target tests --config Debug
- name: Run cmake tests with zenoh-c as static library
shell: bash
run: |
cd build
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DZENOHC_BUILD_WITH_SHARED_MEMORY=${{ matrix.shm }} -DZENOHC_BUILD_WITH_UNSTABLE_API=${{ matrix.unstable }}
cmake --build . --target tests --config Release
ctest -C Release --output-on-failure -E "(unit_z_api_alignment_test|build_z_build_shared)"
- name: Build examples with zenoh-c
shell: bash
run: |
cd build
cmake --build . --target examples
- name: Build examples with zenoh-c as subbroject and static library and in debug mode and in separate directory
shell: bash
run: |
mkdir -p ../build_examples
cmake -S examples -B ../build_examples -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF
cmake --build ../build_examples --config Debug
rm -rf ../build_examples
- name: Build examples with zenoh-c as installed package
shell: bash
run: |
mkdir -p build_examples && cd build_examples
cmake ../examples -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local -DZENOHC_SOURCE=PACKAGE
cmake --build . --config Release
cd .. && rm -rf build_examples
- name: Run rust tests
run: cargo test --verbose --release --features=logger-autoinit
- name: Upload artifact
if: ${{ matrix.unstable == 'false' && matrix.shm == 'false' }}
uses: actions/upload-artifact@v4
with:
# Artifact name
name: zenoh-c-${{ matrix.os }}
# Directory containing files to upload
path: |
target/release
!target/release/build
!target/release/deps
!target/release/.*
!target/release/*.d
# NOTE: In GitHub repository settings, the "Require status checks to pass
# before merging" branch protection rule ensures that commits are only merged
# from branches where specific status checks have passed. These checks are
# specified manually as a list of workflow job names. Thus we use this extra
# job to signal whether all CI checks have passed.
ci:
name: CI status checks
runs-on: ubuntu-latest
needs: build
if: always()
steps:
- name: Check whether all jobs pass
run: echo '${{ toJson(needs) }}' | jq -e 'all(.result == "success")'