fix: separate connection managers for Modbus and HTTP #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: ["master"] | |
pull_request: | |
branches: ["master"] | |
workflow_call: | |
env: | |
CARGO_TERM_COLOR: always | |
CARGO_INCREMENTAL: 0 | |
CARGO_NET_RETRY: 10 | |
RUSTUP_MAX_RETRIES: 10 | |
RUST_BACKTRACE: short | |
PKG_CONFIG_ALLOW_CROSS: 1 | |
jobs: | |
check: | |
name: Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libudev-dev pkg-config | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- name: Cache cargo | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Check formatting | |
run: cargo fmt --all -- --check | |
- name: Check clippy | |
run: cargo clippy -- -D warnings | |
- name: Run tests | |
run: cargo test --all-features | |
build-linux: | |
name: Build Linux | |
needs: check | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
- x86_64-unknown-linux-gnu | |
- aarch64-unknown-linux-gnu | |
- armv7-unknown-linux-gnueabihf | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Install cross | |
uses: taiki-e/install-action@cross | |
- name: Cache cargo | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-${{ matrix.target }}- | |
- name: Cache cross | |
uses: actions/cache@v3 | |
if: matrix.target != 'x86_64-unknown-linux-gnu' | |
with: | |
path: ~/.cargo/.cross | |
key: ${{ runner.os }}-cross-${{ matrix.target }}-${{ hashFiles('Cross.toml') }} | |
restore-keys: | | |
${{ runner.os }}-cross-${{ matrix.target }}- | |
- name: Install target specific dependencies | |
if: matrix.target == 'x86_64-unknown-linux-gnu' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libudev-dev dpkg-dev | |
- name: Set library path | |
if: matrix.target == 'x86_64-unknown-linux-gnu' | |
run: | | |
echo "LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH" >> $GITHUB_ENV | |
echo "LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH" >> $GITHUB_ENV | |
- name: Build | |
env: | |
PKG_CONFIG_ALLOW_CROSS: "1" | |
run: | | |
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then | |
# Native build uses standard system paths | |
cargo build --release --target ${{ matrix.target }} | |
else | |
# Cross compilation requires special paths | |
if [ "${{ matrix.target }}" = "armv7-unknown-linux-gnueabihf" ]; then | |
PKG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig" | |
elif [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then | |
PKG_PATH="/usr/lib/aarch64-linux-gnu/pkgconfig" | |
fi | |
PKG_CONFIG_PATH="$PKG_PATH" \ | |
PKG_CONFIG_SYSROOT_DIR="/usr" \ | |
PKG_CONFIG_LIBDIR="$PKG_PATH" \ | |
cross build --release --target ${{ matrix.target }} | |
fi |