diff --git a/.github/actions/setup-environment/action.yml b/.github/actions/setup-environment/action.yml new file mode 100644 index 0000000..1b4e642 --- /dev/null +++ b/.github/actions/setup-environment/action.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0419ac5..8692ae6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 7af55f7..361cdad 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -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 diff --git a/src/lib.rs b/src/lib.rs index 170def5..e169627 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,4 @@ #![allow(non_camel_case_types)] +// because of the generated code by tonic +#![allow(clippy::redundant_async_block)] pub mod grpc; diff --git a/src/main.rs b/src/main.rs index 9a79dcd..596d4f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,8 @@ use tracing::{debug, info, trace, Level}; use tracing_subscriber::FmtSubscriber; type StdError = Box; type Result = ::std::result::Result; +type TwistSender = tokio::sync::mpsc::Sender>; +type TwistReceiver = tokio::sync::mpsc::Receiver>; struct AmgigRosBridgeGrpcClient { client: CanbusServiceClient, @@ -185,10 +187,7 @@ fn main() -> Result<(), Box> { .build()?; // Async channels to pass messages across threads in an async tokio context. - let (tx, rx): ( - tokio::sync::mpsc::Sender>, - tokio::sync::mpsc::Receiver>, - ) = mpsc::channel(128); + let (tx, rx): (TwistSender, TwistReceiver) = mpsc::channel(128); let (shutdown_tx, shutdown_rx1) = broadcast::channel(16);