From d28edde88f1dac04f0a2a57cb2da7001f09ce1e2 Mon Sep 17 00:00:00 2001 From: Cameron Tacklind Date: Tue, 26 May 2026 15:08:16 -0700 Subject: [PATCH] ci: add BDShot compile test + standardize workflow shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Goal 5 (BDShot in CI): adds tests/bdshot_compile_test.cpp that exercises BDShot.cpp the way the README documents — `#include ` plus an explicit `template class` instantiation. BDShotConfig::Debug::Pin defaults to a dummy IOpin (Pin=8), so no stub config is required. Previous CI skip-note ("needs user config") was wrong — the actual reason BDShot.cpp can't compile standalone is that it's not a translation unit, it's an include-only .cpp; comment fixed. Goal 6 (workflow standardization): adds `make` to the apt-install line and `make --version` to the toolchain-versions step so AVR matches the other firmware repos' CI shape, even though AVR doesn't use uMaker for its own builds. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/build.yml | 26 ++++++++++++++++++++++---- tests/bdshot_compile_test.cpp | 20 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 tests/bdshot_compile_test.cpp diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41f45a4..7cc4886 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,23 +23,26 @@ jobs: - name: Install AVR toolchain run: | sudo apt-get update - sudo apt-get install -y --no-install-recommends gcc-avr avr-libc binutils-avr + sudo apt-get install -y --no-install-recommends gcc-avr avr-libc binutils-avr make - name: Toolchain versions run: | avr-gcc --version | head -1 avr-g++ --version | head -1 dpkg -s avr-libc | grep '^Version' + make --version | head -1 - name: Compile each .cpp standalone (-c, mmcu=${{ matrix.mcu }}) run: | set -e shopt -s nullglob for f in AVR++/*.cpp; do - # BDShot.cpp references `BDShotConfig::Debug::Pin` which the - # consumer is expected to declare. Can't compile standalone. + # BDShot.cpp is not a standalone translation unit — it's + # `#include`d by the consumer (along with an explicit template + # instantiation, per the README). Exercised separately below + # via tests/bdshot_compile_test.cpp. case "$f" in - AVR++/BDShot.cpp) echo "::notice::skipping $f (needs user config)"; continue;; + AVR++/BDShot.cpp) echo "::notice::skipping $f (intended to be included, not compiled standalone)"; continue;; esac echo "::group::$f" avr-g++ -c "$f" -o /dev/null \ @@ -71,3 +74,18 @@ jobs: -I . \ -DF_CPU=16000000UL \ -Wall + + - name: Compile BDShot test (user-facing #include pattern) + run: | + avr-g++ -c tests/bdshot_compile_test.cpp -o /dev/null \ + -mmcu=${{ matrix.mcu }} \ + -std=gnu++17 \ + -fno-exceptions \ + -funsigned-char \ + -funsigned-bitfields \ + -fpack-struct \ + -fshort-enums \ + -Os \ + -I . \ + -DF_CPU=16000000UL \ + -Wall diff --git a/tests/bdshot_compile_test.cpp b/tests/bdshot_compile_test.cpp new file mode 100644 index 0000000..7a7b7ce --- /dev/null +++ b/tests/bdshot_compile_test.cpp @@ -0,0 +1,20 @@ +// CI smoke test for the BDShot driver. BDShot.cpp is intended to be +// `#include`d by the consumer (yes, a .cpp file) — it has no separate +// translation unit. To exercise it in CI we follow the README pattern: the +// consumer includes the .cpp, declares an explicit template instantiation +// for the pin combination they want, then references the type. +// +// BDShotConfig::Debug::Pin defaults to AVR::Output which is +// the sentinel "dummy pin" (Pin 8 → no-op IOpin), so no stub config is +// required here. + +#include + +template class AVR::DShot::BDShot; + +namespace { +[[maybe_unused]] inline void touch() { + using ESC = AVR::DShot::BDShot; + ESC::init(); +} +} // namespace