Skip to content

Commit d4ab17f

Browse files
PLeVasseursophokles73
authored andcommitted
[#8] Initial implementation of up-streamer-rust
* Supports up-spec 1.5.8 * Implemented as a generic library which can be integrated with any UPClients that implement UTransport Implements #3
1 parent a01d093 commit d4ab17f

26 files changed

+6438
-2
lines changed

.github/workflows/build.yaml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# ********************************************************************************
2+
# Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************/
13+
14+
name: Build checks and tests
15+
16+
on:
17+
push:
18+
branches: [ main ]
19+
pull_request:
20+
paths:
21+
- "up-streamer/src/**"
22+
- "Cargo.*"
23+
workflow_call:
24+
workflow_dispatch:
25+
26+
concurrency:
27+
group: ${{ github.ref }}-${{ github.workflow }}
28+
cancel-in-progress: true
29+
30+
jobs:
31+
lint:
32+
name: Lint
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: cargo fmt
38+
working-directory: ${{github.workspace}}
39+
run: cargo fmt -- --check
40+
- name: cargo clippy
41+
working-directory: ${{github.workspace}}
42+
run: cargo clippy --all-targets -- -W warnings -D warnings
43+
44+
test:
45+
name: Test
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
- uses: dtolnay/rust-toolchain@stable
51+
- name: Install dependencies
52+
run: |
53+
cargo install cargo-all-features
54+
- name: Show toolchain information
55+
working-directory: ${{github.workspace}}
56+
run: |
57+
rustup toolchain list
58+
cargo --version
59+
- name: cargo-check all possible feature combinations
60+
run: |
61+
cargo check-all-features
62+
- name: cargo-test all possible feature combinations
63+
run: |
64+
cargo test-all-features
65+
66+
coverage:
67+
name: Collect coverage info
68+
runs-on: ubuntu-latest
69+
70+
steps:
71+
- uses: actions/checkout@v4
72+
- uses: dtolnay/rust-toolchain@stable
73+
- name: Install dependencies
74+
run: |
75+
cargo install cargo-tarpaulin
76+
- name: Show toolchain information
77+
working-directory: ${{github.workspace}}
78+
run: |
79+
rustup toolchain list
80+
cargo --version
81+
- name: Run tests to collect code coverage information
82+
run: |
83+
# enable nightly features so that we can also include Doctests
84+
RUSTC_BOOTSTRAP=1 cargo tarpaulin -o xml -o lcov -o html --doc --tests --all-features
85+
- name: Upload coverage report (xml)
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: Test Coverage Results (xml)
89+
path: cobertura.xml
90+
- name: Upload coverage report (lcov)
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: Test Coverage Results (lcov)
94+
path: lcov.info
95+
- name: Upload coverage report (html)
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: Test Coverage Results (html)
99+
path: tarpaulin-report.html
100+
101+
build-docs:
102+
name: Build documentation
103+
runs-on: ubuntu-latest
104+
105+
steps:
106+
- uses: actions/checkout@v4
107+
- name: Create Documentation
108+
working-directory: ${{github.workspace}}
109+
run: RUSTDOCFLAGS=-Dwarnings cargo doc -p up-streamer --no-deps

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
debug/
4+
target/
5+
6+
# These are backup files generated by rustfmt
7+
**/*.rs.bk
8+
9+
# MSVC Windows builds of rustc generate these, which store debugging information
10+
*.pdb
11+
12+
# cargo-tarpaulin
13+
cobertura.xml
14+
lcov.info
15+
tarpaulin-report.html
16+
17+
.idea/

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Contributing to Eclipse uProtocol
2+
3+
Thanks for your interest in this project. Contributions are welcome!
4+
5+
Please refer to the main [CONTRIBUTING](https://github.com/eclipse-uprotocol/.github/blob/main/CONTRIBUTING.adoc) resource for Eclipse uProtocol to get most of the general overview.
6+
7+
The following is from [`up-rust`](https://github.com/eclipse-uprotocol/up-rust) project and is specific to Rust development for uProtocol.
8+
9+
## Setting up a development environment
10+
11+
You can use any development environment you like to contribute to `up-streamer-rust`. However, it is mandatory to use the Rust linter ('[clippy](<https://github.com/rust-lang/rust-clippy>)') for any pull requests you do.
12+
To set up VSCode to run clippy per default every time you save your code, have a look here: [How to use Clippy in VS Code with rust-analyzer?](https://users.rust-lang.org/t/how-to-use-clippy-in-vs-code-with-rust-analyzer/41881)
13+
14+
Similarly, the project requests that markdown is formatted and linted properly - to help with this, it is recommended to use [markdown linters](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint).
15+
16+
During development, before submitting a PR, you can use `./tools/fmt_clippy_doc.sh` to run these checks on the workspace.
17+
18+
There also exists a helper script in ./tools to generate test results and test code coverage reports. These reports are placed in the `./target/tarpaulin` directory. If you use VSCode with the [Coverage Gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters) extension, you can enable display of code coverage information with these settings:
19+
20+
``` json
21+
"coverage-gutters.coverageBaseDir": "**",
22+
"coverage-gutters.coverageFileNames": [
23+
"target/tarpaulin/lcov.info",
24+
],
25+
```
26+
27+
## DevContainer
28+
29+
All of these prerequisites are made available as a VSCode devcontainer, configured at the usual place (`.devcontainer`).
30+
31+
## Contact
32+
33+
Contact the project developers via the project's "dev" list.
34+
35+
<https://accounts.eclipse.org/mailing-list/uprotocol-dev>

0 commit comments

Comments
 (0)