Skip to content

Commit

Permalink
add clippy, fmt, cargo-check (#15)
Browse files Browse the repository at this point in the history
* add clippy, fmt, cargo-check

* separate from pre-commit

* add missing shell

* rename action

* rename action

* add sudo

* add sudo

* update to ubuntu 20.04

* update to ubuntu 20.04

* add cargo fmt

* add setup env in main ci

* use rust nightly in ci

* add rustfmt, clippy in components
  • Loading branch information
edgarriba authored Mar 20, 2023
1 parent ba5e760 commit a894cb8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 15 deletions.
20 changes: 20 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: setup-environment

runs:
using: "composite"
steps:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt, clippy
override: true
- name: Install ROS
uses: ros-tooling/setup-ros@v0.6
with:
required-ros-distributions: noetic
- uses: Swatinem/rust-cache@v2
- name: Install dependencies
shell: bash
run: sudo apt install -y protobuf-compiler
13 changes: 2 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,8 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: ros-tooling/setup-ros@v0.6
with:
required-ros-distributions: noetic
- uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: sudo apt install -y protobuf-compiler
- name: Setting environment
uses: ./.github/actions/setup-environment
- name: Compile the project
run: |
source /opt/ros/noetic/setup.bash
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,27 @@ jobs:
pre-commit install
- name: Run pre-commit checks
run: pre-commit run --all-files
clippy:
runs-on: ubuntu-20.04
steps:
- name: Checkout workspace
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Setting environment
uses: ./.github/actions/setup-environment
- name: Run clippy
run: |
source /opt/ros/noetic/setup.bash
cargo clippy -- -Dwarnings
fmt:
runs-on: ubuntu-20.04
steps:
- name: Checkout workspace
uses: actions/checkout@v3
- name: Setting environment
uses: ./.github/actions/setup-environment
- name: Run fmt
run: |
source /opt/ros/noetic/setup.bash
cargo fmt --all -- --check
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#![allow(non_camel_case_types)]
// because of the generated code by tonic
#![allow(clippy::redundant_async_block)]
pub mod grpc;
7 changes: 3 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use tracing::{debug, info, trace, Level};
use tracing_subscriber::FmtSubscriber;
type StdError = Box<dyn std::error::Error + Send + Sync + 'static>;
type Result<T, E = StdError> = ::std::result::Result<T, E>;
type TwistSender = tokio::sync::mpsc::Sender<Result<rosrust_msg::geometry_msgs::Twist, Status>>;
type TwistReceiver = tokio::sync::mpsc::Receiver<Result<rosrust_msg::geometry_msgs::Twist, Status>>;

struct AmgigRosBridgeGrpcClient {
client: CanbusServiceClient<tonic::transport::Channel>,
Expand Down Expand Up @@ -185,10 +187,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.build()?;

// Async channels to pass messages across threads in an async tokio context.
let (tx, rx): (
tokio::sync::mpsc::Sender<Result<rosrust_msg::geometry_msgs::Twist, Status>>,
tokio::sync::mpsc::Receiver<Result<rosrust_msg::geometry_msgs::Twist, Status>>,
) = mpsc::channel(128);
let (tx, rx): (TwistSender, TwistReceiver) = mpsc::channel(128);

let (shutdown_tx, shutdown_rx1) = broadcast::channel(16);

Expand Down

0 comments on commit a894cb8

Please sign in to comment.