Automate testing, compilation, and validation of the Arduino Temperature Control Library across multiple platforms using GitHub Actions.
Purpose:
Compiles the library and its examples for both AVR and ESP8266 platforms.
Trigger:
Runs on every push and pull_request.
Key Features:
- AVR Compilation: Compiles all examples for the AVR platform (e.g., Arduino Uno).
- ESP8266 Compilation: Compiles all examples for the ESP8266 platform (e.g., NodeMCU v2).
- Selective Compilation: Skips ESP-specific examples (e.g., ESP-WebServer) when compiling for AVR.
- Unit Testing: Executes unit tests using the
arduino_ciframework.
The library supports both AVR-based boards (e.g., Arduino Uno) and ESP8266-based boards (e.g., NodeMCU). Some examples utilize ESP-specific libraries like ESP8266WiFi.h, which are incompatible with AVR platforms. Separating the compilation ensures:
- AVR Compatibility: Skips ESP-specific examples to prevent compilation errors.
- ESP Compatibility: Compiles all examples, including ESP-specific ones, for the ESP8266 platform.
The workflow follows these steps:
-
Setup Environment:
- Installs dependencies (e.g.,
gcc-avr,avr-libc). - Configures the Arduino CLI and installs required cores (
arduino:avrandesp8266:esp8266).
- Installs dependencies (e.g.,
-
Install Libraries:
- Installs the OneWire library.
- Applies a custom CRC implementation.
-
Run Unit Tests:
- Executes unit tests using the
arduino_ciframework for the AVR platform.
- Executes unit tests using the
-
Compile Examples for AVR:
- Compiles all examples (excluding ESP-specific ones) for the AVR platform.
-
Compile Examples for ESP8266:
- Compiles all examples (including ESP-specific ones) for the ESP8266 platform.
Understanding the project’s file structure is crucial for effective navigation and contribution. Below is an overview of the key files and directories:
-
Gemfile- Description:
Manages Ruby dependencies required for the project. It ensures that the correct versions of gems (likearduino_ci) are used. - Usage:
Runbundle installto install the necessary gems.
- Description:
-
.arduino-ci.yml- Description:
Configuration file for thearduino_citool. It defines how the Arduino CI should run tests and compile sketches. - Key Configurations:
- Specifies which boards to target.
- Defines libraries and dependencies needed for testing.
- Sets up compilation and testing parameters.
- Description:
-
.arduino_ci/- Description:
Contains supporting files and configurations for thearduino_ci.rbtool. - Contents:
config.rb:
Custom configuration settings for the Arduino CI.helpers.rb:
Helper methods and utilities used by the CI scripts.- Other supporting scripts and assets.
- Description:
-
arduino-ci.yml- Description:
GitHub Actions workflow file that defines the CI pipeline for the project. - Key Sections:
- Jobs:
Defines the sequence of steps for setting up the environment, installing dependencies, running tests, and compiling examples. - Triggers:
Specifies when the workflow should run (e.g., on push or pull request).
- Jobs:
- Description:
-
examples/- Description:
Contains example sketches demonstrating how to use the Arduino Temperature Control Library. - Structure:
ESP-WebServer/
ESP-specific examples that utilize libraries likeESP8266WiFi.h.
- Description:
-
LICENSE- Description:
Contains the MIT License under which the project is released.
- Description:
-
Other Files and Directories:
.github/- Contains GitHub-specific configurations, issues templates, and additional workflows.
src/- Contains the source code of the Arduino Temperature Control Library.
The workflow is defined in the arduino-ci.yml file. Key configurations include:
-
Cores Installed:
arduino-cli core install arduino:avr arduino-cli core install esp8266:esp8266
-
Skipping ESP-Specific Examples:
export ARDUINO_CI_SKIP_EXAMPLES="ESP-WebServer" -
Compiling for AVR and ESP Platforms:
arduino-cli compile --fqbn arduino:avr:uno "$sketch" arduino-cli compile --fqbn esp8266:esp8266:nodemcuv2 "$sketch"
If you’re contributing to the workflows, please ensure that:
- Compatibility: New examples are compatible with both AVR and ESP platforms (if applicable).
- Organization: ESP-specific examples are placed in a clearly labeled directory (e.g.,
examples/ESP-WebServer). - Testing: Unit tests are added or updated as needed.
If the workflow fails:
- Check Logs: Navigate to the Actions tab in GitHub for detailed logs.
- Local Replication: Try to replicate the issue locally using the dev container.
- Dependencies: Ensure all dependencies are installed correctly.
This workflow configuration and scripts are released under the MIT License.