From 8365c25fd03b9d8cd1530fe2b3075638d9321073 Mon Sep 17 00:00:00 2001 From: Bo Jeanes Date: Tue, 30 Aug 2022 20:27:56 +1000 Subject: [PATCH] Add GH action for tests/clippy --- .github/workflows/ci.yml | 111 +++++++++++++++++++++++++++++++ modbus-mqtt/src/modbus/config.rs | 2 +- 2 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9e5ecfb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,111 @@ +# TODO: incorporate some learnings from https://www.infinyon.com/blog/2021/04/github-actions-best-practices/, esp `sccache` stuff +# TODO: dispatch event technique from https://mateuscosta.me/rust-releases-with-github-actions looks handy for triggering another workflow, such as to share logic for building binaries + +name: CI +on: + push: + branches: + - '**' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + + - uses: actions-rs/toolchain@v1 + id: rust-toolchain + with: + toolchain: stable + profile: default + override: true + + - name: Install Dependencies + run: | + export DEBIAN_FRONTEND=noninteractive + sudo apt-get clean && sudo apt-get update + sudo apt-get install -y pkg-config libudev-dev + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry- + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-index- + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-cargo-build-target-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-build-target-${{ steps.rust-toolchain.outputs.rustc_hash }}- + ${{ runner.os }}-cargo-build-target- + + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --verbose + + checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + + - uses: actions-rs/toolchain@v1 + id: rust-toolchain + with: + toolchain: stable + profile: default + override: true + + - name: Install Dependencies + run: | + export DEBIAN_FRONTEND=noninteractive + sudo apt-get clean && sudo apt-get update + sudo apt-get install -y pkg-config libudev-dev + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry-${{ steps.rust-toolchain.outputs.rustc_hash }}- + ${{ runner.os }}-cargo-registry- + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-index-${{ steps.rust-toolchain.outputs.rustc_hash }}- + ${{ runner.os }}-cargo-index- + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-cargo-build-target-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-build-target-${{ steps.rust-toolchain.outputs.rustc_hash }}- + ${{ runner.os }}-cargo-build-target- + + - name: Check rustfmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: Check clippy warnings + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D clippy::all \ No newline at end of file diff --git a/modbus-mqtt/src/modbus/config.rs b/modbus-mqtt/src/modbus/config.rs index dfca1e2..25c8c51 100644 --- a/modbus-mqtt/src/modbus/config.rs +++ b/modbus-mqtt/src/modbus/config.rs @@ -194,7 +194,7 @@ where } } -#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] pub struct RegisterParse { #[serde(default, skip_serializing_if = "IsDefault::is_default")] pub swap_bytes: Swap,