From c1a8c6e9cde7537366748470d2b74eb7f5a1744d Mon Sep 17 00:00:00 2001 From: Willian Galvani Date: Mon, 12 Jul 2021 22:16:54 -0300 Subject: [PATCH] CI: proof of concept --- .github/workflows/hardware-test.yml | 19 +++++++++++++++++++ test.py | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/hardware-test.yml create mode 100644 test.py diff --git a/.github/workflows/hardware-test.yml b/.github/workflows/hardware-test.yml new file mode 100644 index 0000000..0f73480 --- /dev/null +++ b/.github/workflows/hardware-test.yml @@ -0,0 +1,19 @@ +name: Linux hardware test + +on: [push, pull_request] + +jobs: + build: + + runs-on: self-hosted + + steps: + - uses: actions/checkout@master + - name: Install necessary tools + run: | + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo apt -y update + sudo apt -y install i2c-tools python3-smbus + - name: Build it + run: | + python3 test.py diff --git a/test.py b/test.py new file mode 100644 index 0000000..50ab41a --- /dev/null +++ b/test.py @@ -0,0 +1,21 @@ +from kellerLD import KellerLD +import time + +sensor = KellerLD(4) + +if not sensor.init(): + print("Failed to initialize Keller LD sensor!") + exit(1) + +print("Testing Keller LD series pressure sensor") + +for i in range(10): + try: + sensor.read() + print("pressure: %7.4f bar\ttemperature: %0.2f C" % (sensor.pressure(), sensor.temperature())) + # we shouldn't get anything out of these values in the test hardware + assert 5 < sensor.temperature() < 50 + assert -1 < sensor.pressure() < 1 + time.sleep(0.2) + except Exception as e: + print(e)