From e8adebdd6e5712261d6201ded0dd0cec8a55e919 Mon Sep 17 00:00:00 2001 From: Matthias Wende Date: Mon, 6 Apr 2026 14:20:42 +0200 Subject: [PATCH 1/2] ci: add GitHub Actions workflow --- .github/workflows/ci.yml | 62 ++++++++++++++++++++++++++++++++++++++++ README.md | 3 ++ 2 files changed, 65 insertions(+) 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..d80b51d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + fmt: + name: Formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - run: cargo fmt -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + - run: cargo clippy --all-targets --all-features -- -D warnings + + test: + name: Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - run: cargo test --all-features + + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: llvm-tools-preview + - uses: Swatinem/rust-cache@v2 + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Generate coverage + run: cargo llvm-cov --all-features --lcov --output-path lcov.info + - name: Print coverage summary + run: cargo llvm-cov report --summary-only + - name: Upload to Codecov + uses: codecov/codecov-action@v5 + with: + files: lcov.info + fail_ci_if_error: false + # token: ${{ secrets.CODECOV_TOKEN }} # required for private repos diff --git a/README.md b/README.md index 942a789..709cbb8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # tiny-mb +[![CI](https://github.com/mattwend/tiny-mb/actions/workflows/ci.yml/badge.svg)](https://github.com/mattwend/tiny-mb/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/mattwend/tiny-mb/branch/main/graph/badge.svg)](https://codecov.io/gh/mattwend/tiny-mb) + Small Rust Modbus library with typed request/response PDUs and a reusable Modbus TCP transport. ## Features From 12cb8e5bf0ba6890830ef4fb17ec2d9061791bf1 Mon Sep 17 00:00:00 2001 From: Matthias Wende Date: Mon, 6 Apr 2026 14:21:19 +0200 Subject: [PATCH 2/2] ci: add codecov configuration --- codecov.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..4e6a1d1 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,22 @@ +codecov: + require_ci_to_pass: true + +coverage: + precision: 2 + round: nearest + range: 0...100 + + status: + project: + default: + target: auto + threshold: 1% + patch: + default: + target: auto + threshold: 1% + +comment: + layout: "diff, flags, files" + behavior: default + require_changes: false