Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
name: CI
on:
push:
branches: [main, "claude/**", "feature/**"]
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
# Both officially supported firmware targets must compile from a clean
# dependency cache (every library is pinned to an exact version in
# firmware/platformio.ini). A compile error in any supported
# optional-feature combination fails the build.
#
# The compiled images are also uploaded as run artifacts, so any commit — a
# branch, a PR, or main — can be downloaded and flashed without a local
# toolchain. GitHub keeps run artifacts for 90 days; tagged releases carry the
# same files permanently (see firmware-release.yml).
firmware-build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
env: [esp32dev, xiao_esp32c6]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install PlatformIO
# esptool is pinned to the 4.x line: package_build.sh calls the v4
# `esptool.py merge_bin` spelling, which 5.x renamed.
run: pip install platformio "esptool~=4.8"
- name: Build ${{ matrix.env }}
run: pio run -e ${{ matrix.env }}
working-directory: firmware
- name: Package flashable images
run: ./firmware/ci/package_build.sh ${{ matrix.env }}
- name: Upload firmware images
uses: actions/upload-artifact@v4
with:
name: firmware-${{ matrix.env }}
path: firmware/dist/
if-no-files-found: error
# Host-level tests for the checked I2C layer: the exact production headers
# (nau7802_checked.h, scale_math.h, scale_topology.h) run against a scripted
# mock TwoWire so failed mux writes/readbacks, stale channel selections,
# failed NAU channel switches, short reads, partial sample sets, timeouts,
# railed values, excessive variance and invalid topologies are all injected
# deterministically.
firmware-host-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and run host tests
run: ./firmware/host_test/run_tests.sh
# The pure BLE-decoder headers also have host unit tests (real captured
# payloads). They were previously not run in CI, which let a decode
# regression ship unnoticed — keep them wired in here.
- name: Build and run BLE decoder tests
run: |
set -e
g++ -std=gnu++17 -Wall -Wextra -Werror -I firmware/include \
-o /tmp/test_ruuvi_decode test-data/test_ruuvi_decode.cpp
/tmp/test_ruuvi_decode
g++ -std=gnu++17 -Wall -Wextra -Werror -I firmware/include \
-o /tmp/test_beehive_decode test-data/test_beehive_decode.cpp
/tmp/test_beehive_decode
# The HiveTraffic measurement decoder is a two-repo wire contract: it has
# to keep reading fw:2 documents from counters the OTA relay has not
# reached yet, as well as the fw:3, fw:4 and fw:5 ones newer firmware
# emits. A captured document of each revision is asserted here.
- name: Build and run bee counter wire tests
run: |
set -e
g++ -std=gnu++17 -Wall -Wextra -Werror -I firmware/include \
-o /tmp/test_bee_counter_wire test-data/test_bee_counter_wire.cpp
/tmp/test_bee_counter_wire
# Night mode decides whether to blind a bee counter, and gets it wrong
# quietly in both directions — a lost day of foraging looks like bad
# weather, and a counter that never sleeps looks like nothing at all.
# Midnight wrap, an unsynced clock and the traffic gate are all pinned
# here rather than left to a season of field observation.
- name: Build and run night mode tests
run: |
set -e
g++ -std=gnu++17 -Wall -Wextra -Werror -I firmware/include \
-o /tmp/test_night_mode test-data/test_night_mode.cpp
/tmp/test_night_mode
server-tests:
runs-on: ubuntu-latest
# The pairing-lifecycle suite needs a real database: the claim/release bug it
# guards lived in SQL, so there is nothing to unit-test around it. Every other
# suite here is pure logic and ignores this service.
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: hivehub_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install server dependencies
run: |
sudo apt-get update -q && sudo apt-get install -y -q build-essential python3-dev
pip install -r server/requirements.txt pytest
- name: Run server test suite
env:
DATABASE_URL: postgresql://ci-not-used/ci
PYTHONPATH: server
run: |
python3 test-data/test_counter_rules.py
python3 test-data/test_accel_rules.py
python3 test-data/test_ble_sensor_rules.py
python3 test-data/test_sd_import.py
python3 test-data/test_data_export.py
python3 test-data/test_bee_counter_banks.py
python3 -m pytest -q test-data/test_tempcomp.py test-data/test_hive_tempcomp.py \
test-data/test_hiveheart_fft.py \
test-data/test_mqtt_ha_discovery.py \
test-data/test_relay_ota_gate.py test-data/test_publish.py
# --require-db turns an unreachable database into a failure rather than a
# skip, so a broken service container can never leave this job green while
# silently testing nothing.
- name: Run pairing lifecycle tests against PostgreSQL
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/hivehub_test
PYTHONPATH: server
run: python3 test-data/test_pairing_lifecycle.py --require-db
# The website/configurator and dashboard have no test suite yet; keep them at
# least syntactically sound so a broken script cannot ship unnoticed.
website-js-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Syntax-check website and dashboard scripts
run: |
set -e
for f in website/assets/*.js website/dashboard-demo/assets/*.js server/dashboard/assets/*.js; do
node --check "$f"
done
695b4ef90This file is pinned to the selected release. Download the original to open it in your design tool.