From f449a4f022e835c9c921ab8646c9a32eca4d772a Mon Sep 17 00:00:00 2001 From: Leon Lux Date: Tue, 12 Mar 2024 08:47:19 +0100 Subject: [PATCH 1/3] update CI to be more readable and concise. Publishes now only occur on manual trigger --- .github/workflows/publish.yml | 56 ++++------------------------- .github/workflows/rust.yml | 67 +++++++++++++++++------------------ 2 files changed, 38 insertions(+), 85 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3ed6e0f..722eaf7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,58 +1,14 @@ -on: - push: - tags: - - '*' - -jobs: - test: - name: Build and Test Project - runs-on: ubuntu-latest - - env: - CARGO_TERM_COLORS: always - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - components: rustfmt, clippy - - - name: Setup Cargo Cache - uses: actions/cache@v3 - continue-on-error: false - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-cargo- - - - name: Setup Protobuf Compiler - uses: arduino/setup-protoc@v2 - - - name: Run Unit Tests - run: cargo test +on: workflow_dispatch +jobs: publish: name: Publish crate to crates.io needs: test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - name: Setup Protobuf Compiler - uses: arduino/setup-protoc@v2 + - uses: actions/checkout@v4 + - uses: arduino/setup-protoc@v2 + - uses: dtolnay/rust-toolchain@stable - uses: katyo/publish-crates@v2 with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} \ No newline at end of file + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c0d1032..b435ce1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,46 +1,43 @@ name: CI +env: + CARGO_TERM_COLOR: always + MSRV: '1.70' + on: push: - branches: [ "dev" ] - pull_request: - branches: [ "dev" ] + branches: + - "main" + pull_request: {} jobs: - test: - - name: Test `cargo check/test/build` on ${{ matrix.os }} - runs-on: ubuntu-latest - env: - CARGO_TERM_COLOR: always + # Check Project for Clippy Lints and ensure that it is properly formatted + check: + name: Check clippy lints and format + runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Rust - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: taiki-e/install-action@protoc + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: stable - components: rustfmt, clippy - - - name: Setup Cargo Cache - uses: actions/cache@v3 - continue-on-error: false - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-cargo- - - - name: Setup Protobuf Compiler - uses: arduino/setup-protoc@v2 + components: clippy, rustfmt + - uses: Swatinem/rust-cache@v2 + - name: Check + run: cargo clippy --workspace --all-targets --all-features -- -D warnings + - name: Format + run: cargo fmt --all --check + + # Run Unit tests for the project + test: + name: Run Tests - - name: Run Unit Tests - run: cargo test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: taiki-e/install-action@protoc + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - name: Tests + run: cargo test --workspace --all-features --all-targets From e24acafc11629accd8f9f0723f6c46cc52b2c564 Mon Sep 17 00:00:00 2001 From: Leon Lux Date: Tue, 12 Mar 2024 08:48:16 +0100 Subject: [PATCH 2/3] add clippy attribute to ignore generated code --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 686f180..6225d32 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,10 +4,12 @@ //! as well as various telemetry data. #![cfg_attr(docsrs, feature(doc_cfg))] + mod auth; pub mod client; pub mod error; +#[allow(clippy::all)] pub(crate) mod gen { pub mod gnmi { tonic::include_proto!("gnmi"); From 7b2d40ebce0a99d1b72d34add975766429468309 Mon Sep 17 00:00:00 2001 From: Leon Lux Date: Tue, 12 Mar 2024 08:49:25 +0100 Subject: [PATCH 3/3] change name of client module to make clippy happy --- src/client/{client.rs => gnmi_client.rs} | 0 src/client/mod.rs | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/client/{client.rs => gnmi_client.rs} (100%) diff --git a/src/client/client.rs b/src/client/gnmi_client.rs similarity index 100% rename from src/client/client.rs rename to src/client/gnmi_client.rs diff --git a/src/client/mod.rs b/src/client/mod.rs index 7abe15b..655cd51 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -18,11 +18,11 @@ //! # })} //! ``` mod capabilities; -mod client; #[cfg(feature = "dangerous_configuration")] #[cfg_attr(docsrs, doc(cfg(feature = "dangerous_configuration")))] pub mod dangerous; +mod gnmi_client; -pub use client::{Client, ClientBuilder}; +pub use gnmi_client::{Client, ClientBuilder}; pub use capabilities::{Capabilities, Encoding};