From f926cd4a81a85d8315bb6968603fcc96e3b6d382 Mon Sep 17 00:00:00 2001 From: "jonath.re@gmail.com" Date: Fri, 22 Jul 2022 18:00:05 +0200 Subject: [PATCH 1/2] Add a CI workflow to build the code and run tests Example output here: https://github.com/jonathangjertsen/nanoMODBUS/runs/7471676743 I'll try to build the Arduino examples as well, but this is a start --- .github/workflows/ci.yml | 15 +++++++++++++++ 1 file changed, 15 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..07cf8b6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,15 @@ +name: ci +on: [push] +jobs: + Build: + runs-on: ubuntu-latest + steps: + - name: Clone repo + uses: actions/checkout@v2 + - name: build + run: | + mkdir build + cd build + cmake .. + make + ./nanomodbus_tests From 949cad80cf9a23f7b281afd8f119422b561f06dd Mon Sep 17 00:00:00 2001 From: "jonath.re@gmail.com" Date: Fri, 22 Jul 2022 18:37:14 +0200 Subject: [PATCH 2/2] Compile Arduino examples in CI --- .github/workflows/ci.yml | 7 +++++++ examples/arduino/README.md | 4 ++++ examples/arduino/compile-examples.sh | 24 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100755 examples/arduino/compile-examples.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07cf8b6..fac6880 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,3 +13,10 @@ jobs: cmake .. make ./nanomodbus_tests + - name: Compile Arduino examples + run: | + pushd build + curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh + popd + export PATH="build/bin:$PATH" + ./examples/arduino/compile-examples.sh diff --git a/examples/arduino/README.md b/examples/arduino/README.md index f1ca0d5..f84e66e 100644 --- a/examples/arduino/README.md +++ b/examples/arduino/README.md @@ -4,3 +4,7 @@ This folder contains nanoMODBUS examples for Arduino. To build and load a sketch with the Arduino IDE, copy `nanomodbus.c` and `nanomodbus.h` inside its folder. `client-rtu` and `server-rtu` are meant to be used with two Arduinos connected via their TX0/RX0 serial pins. + +If you have [arduino-cli](https://github.com/arduino/arduino-cli) installed, you can run +`examples/arduino/compile-examples.sh` from the top-level nanoMODBUS directory to compile the examples. +They will be available in the `build` folder. diff --git a/examples/arduino/compile-examples.sh b/examples/arduino/compile-examples.sh new file mode 100755 index 0000000..f0e8928 --- /dev/null +++ b/examples/arduino/compile-examples.sh @@ -0,0 +1,24 @@ +#!/bin/env bash +set -e -o pipefail + +# Set default board +BOARD=$1 +if [ -z "${BOARD}" ] +then + echo No board specified, using arduino:avr:uno + BOARD=arduino:avr:uno +fi + +# Set up example folders +mkdir -p build/arduino +cp -r examples/arduino build +cp nanomodbus.h nanomodbus.c build/arduino/server-rtu/ +cp nanomodbus.h nanomodbus.c build/arduino/client-rtu/ + +# Ensure ardunio-cli is up to date +arduino-cli core update-index +arduino-cli core install arduino:avr + +# Compile both examples +arduino-cli compile -b $BOARD --output-dir build/arduino -- build/arduino/server-rtu/server-rtu.ino +arduino-cli compile -b $BOARD --output-dir build/arduino -- build/arduino/client-rtu/client-rtu.ino