Skip to content

Commit b85f221

Browse files
committed
Add .github
1 parent e9a37a7 commit b85f221

File tree

1 file changed

+241
-0
lines changed

1 file changed

+241
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
jobs:
10+
matrix:
11+
12+
13+
check_rust:
14+
needs: determine-runner
15+
name: Check zenoh using Rust 1.75
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: ${{ fromJSON(needs.determine-runner.outputs.runner) }}
21+
22+
steps:
23+
- name: Clone this repository
24+
uses: actions/checkout@v4
25+
26+
- name: Update Rust 1.75.0 toolchain
27+
run: rustup update 1.75.0
28+
29+
- name: Check zenoh with rust 1.75.0
30+
run: cargo +1.75.0 check --release --bins --lib
31+
32+
- name: Install latest cargo-machete
33+
uses: taiki-e/install-action@cargo-machete
34+
35+
check:
36+
needs: determine-runner
37+
name: Lints and doc tests on ${{ matrix.os }}
38+
runs-on: ${{ matrix.os }}
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
os: ${{ fromJSON(needs.determine-runner.outputs.runner) }}
43+
44+
steps:
45+
- name: Clone this repository
46+
uses: actions/checkout@v4
47+
48+
- name: Update Stable Rust toolchain
49+
run: rustup update stable
50+
51+
- name: Make sure necessary tools are installed
52+
run: |
53+
rustup component add clippy --toolchain stable
54+
rustup component add rustfmt --toolchain nightly
55+
56+
- name: Setup rust-cache
57+
uses: Swatinem/rust-cache@v2
58+
with:
59+
cache-bin: false
60+
61+
- name: Clippy all features
62+
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
63+
run: cargo +stable clippy --all-targets --all-features -- --deny warnings
64+
65+
- name: Install generic no_std target
66+
# Generic no_std target architecture is x86_64-unknown-none
67+
run: rustup target add x86_64-unknown-none
68+
69+
- name: Perform no_std checks
70+
run: cargo check --bin nostd_check --target x86_64-unknown-none --manifest-path ci/nostd-check/Cargo.toml
71+
72+
- name: Run doctests
73+
run: cargo test --doc
74+
75+
- name: Check licenses
76+
run: cargo deny check licenses
77+
78+
- name: Check unused dependencies
79+
run: cargo machete
80+
81+
- name: Check SemVer Compatibility
82+
run: cargo +stable semver-checks --verbose --default-features --package zenoh --release-type ${{ env.CARGO_SEMVER_CHECKS_RELEASE_TYPE }} --baseline-version ${{ env.CARGO_SEMVER_CHECKS_BASELINE_VERSION }}
83+
84+
- name: Check TOML formatting
85+
if: ${{ !contains(matrix.os, 'windows') }}
86+
run: taplo fmt --check --diff
87+
88+
test:
89+
needs: determine-runner
90+
name: Unit tests on ${{ matrix.os }}
91+
runs-on: ${{ matrix.os }}
92+
strategy:
93+
fail-fast: false
94+
matrix:
95+
os: ${{ fromJSON(needs.determine-runner.outputs.runner) }}
96+
97+
steps:
98+
- name: Clone this repository
99+
uses: actions/checkout@v4
100+
101+
- name: Install latest Rust toolchain
102+
run: rustup show
103+
104+
- name: Setup rust-cache
105+
uses: Swatinem/rust-cache@v2
106+
with:
107+
cache-bin: false
108+
109+
- name: Set rustflags
110+
if: ${{ matrix.os == 'windows-latest' }}
111+
shell: bash
112+
run: |
113+
echo "RUSTFLAGS=-Clink-arg=/DEBUG:NONE" >> $GITHUB_ENV
114+
115+
- name: Install latest nextest
116+
uses: taiki-e/install-action@nextest
117+
118+
- name: Run tests stable (sudo macos)
119+
if: ${{ matrix.os == 'macos-latest' }}
120+
run: sudo cargo nextest run -p zenoh -F internal_config
121+
122+
- name: Run tests stable
123+
if: ${{ matrix.os != 'macos-latest' }}
124+
run: cargo nextest run -p zenoh -F internal_config
125+
126+
- name: Run tests with unstable (sudo macos)
127+
if: ${{ matrix.os == 'macos-latest' }}
128+
run: sudo cargo nextest run -F test -F internal_config --exclude zenoh-examples --exclude zenoh-plugin-example --workspace
129+
130+
- name: Run tests with unstable
131+
if: ${{ matrix.os != 'macos-latest' }}
132+
run: cargo nextest run -F test -F internal_config --exclude zenoh-examples --exclude zenoh-plugin-example --workspace
133+
134+
- name: Rename junit test report (sudo macos)
135+
if: ${{ matrix.os == 'macos-latest' }}
136+
run: sudo mv target/nextest/default/junit.xml target/nextest/default/tests.junit.xml
137+
138+
- name: Rename junit test report
139+
if: ${{ matrix.os != 'macos-latest' }}
140+
run: mv target/nextest/default/junit.xml target/nextest/default/tests.junit.xml
141+
142+
- name: Run tests with SHM (sudo macos)
143+
if: ${{ matrix.os == 'macos-latest' }}
144+
run: sudo cargo nextest run -F test -F shared-memory -F unstable -F internal_config -E 'not (test(test_default_features))' --exclude zenoh-examples --exclude zenoh-plugin-example --workspace
145+
env:
146+
RUST_BACKTRACE: 1
147+
148+
- name: Run tests with SHM
149+
if: ${{ matrix.os == 'windows-latest' }}
150+
run: cargo nextest run -F test -F shared-memory -F unstable -F internal_config -E 'not (test(test_default_features))' --exclude zenoh-examples --exclude zenoh-plugin-example --workspace
151+
152+
- name: Rename junit test report (sudo macos)
153+
if: ${{ matrix.os == 'macos-latest' }}
154+
run: sudo mv target/nextest/default/junit.xml target/nextest/default/tests-shm.junit.xml
155+
156+
- name: Rename junit test report
157+
if: ${{ matrix.os == 'windows-latest' }}
158+
run: mv target/nextest/default/junit.xml target/nextest/default/tests-shm.junit.xml
159+
160+
- name: Run tests with SHM + unixpipe
161+
if: ${{ matrix.os == 'ubuntu-latest' }}
162+
run: |
163+
sudo prlimit --memlock=unlimited --pid=$$
164+
cargo nextest run -F test -F shared-memory -F unstable -F internal_config -F transport_unixpipe -E 'not (test(test_default_features))' --exclude zenoh-examples --exclude zenoh-plugin-example --workspace
165+
166+
- name: Rename junit test report
167+
if: ${{ matrix.os == 'ubuntu-latest' }}
168+
run: mv target/nextest/default/junit.xml target/nextest/default/tests-shm-unixpipe.junit.xml
169+
170+
- name: Check for feature leaks
171+
if: ${{ matrix.os == 'ubuntu-latest' }}
172+
run: cargo nextest run -p zenohd --no-default-features
173+
174+
- name: Rename junit test report
175+
if: ${{ matrix.os == 'ubuntu-latest' }}
176+
run: mv target/nextest/default/junit.xml target/nextest/default/tests-feature-leaks.junit.xml
177+
178+
- name: Upload test results to Codecov
179+
if: ${{ !cancelled() }}
180+
uses: codecov/test-results-action@v1
181+
with:
182+
token: ${{ secrets.CODECOV_TOKEN }}
183+
184+
valgrind:
185+
name: Memory leak checks
186+
runs-on: ubuntu-latest
187+
needs: check
188+
steps:
189+
- name: Clone this repository
190+
uses: actions/checkout@v4
191+
192+
- name: Install latest Rust toolchain
193+
run: rustup show
194+
195+
- name: Install valgrind
196+
uses: taiki-e/install-action@valgrind
197+
198+
- uses: Swatinem/rust-cache@v2
199+
with:
200+
cache-bin: false
201+
202+
- name: Run memory leaks check
203+
run: ci/valgrind-check/run.sh
204+
shell: bash
205+
206+
typos:
207+
name: Typos Check
208+
runs-on: ubuntu-latest
209+
steps:
210+
- name: Clone this repository
211+
uses: actions/checkout@v4
212+
213+
- name: Check spelling
214+
uses: crate-ci/typos@master
215+
216+
markdown_lint:
217+
runs-on: ubuntu-latest
218+
steps:
219+
- uses: actions/checkout@v4
220+
- uses: DavidAnson/markdownlint-cli2-action@v18
221+
with:
222+
config: '.markdownlint.yaml'
223+
globs: '**/README.md'
224+
225+
doc:
226+
name: Generate documentation
227+
runs-on: ubuntu-latest
228+
steps:
229+
- name: Clone this repository
230+
uses: actions/checkout@v4
231+
232+
# Use a similar command than docs.rs build: rustdoc with nightly toolchain
233+
- name: Install Rust toolchain nightly for docs gen
234+
run: rustup toolchain install nightly
235+
236+
- name: Run rustdoc using Nightly Rust and Zenoh unstable
237+
# NOTE: force 'unstable' feature for doc generation, as forced for docs.rs build in zenoh/Cargo.toml
238+
run: |
239+
cargo +nightly rustdoc --manifest-path ./zenoh/Cargo.toml --lib --features "shared-memory unstable" -j3 \
240+
-Z rustdoc-map -Z unstable-options -Z rustdoc-scrape-examples \
241+
--config build.rustdocflags='["--cfg", "docsrs", "-Z", "unstable-options", "--emit=invocation-specific", "--cap-lints", "warn", "--extern-html-root-takes-precedence"]'

0 commit comments

Comments
 (0)