Skip to content

Commit 95de9ad

Browse files
authored
Merge pull request #273 from milesburton/fix/include-ESPWebServer-for-testing
fix: Separate AVR and ESP platforms from the test pipeline.
2 parents c228b5e + a1e6352 commit 95de9ad

File tree

2 files changed

+158
-5
lines changed

2 files changed

+158
-5
lines changed

.github/workflows/README.md

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# 📂 GitHub Workflows for Arduino Temperature Control Library
2+
3+
Automate testing, compilation, and validation of the Arduino Temperature Control Library across multiple platforms using GitHub Actions.
4+
5+
## 🛠️ Workflows Overview
6+
7+
### 1. 📦 Arduino CI Workflow
8+
9+
**Purpose:**
10+
Compiles the library and its examples for both AVR and ESP8266 platforms.
11+
12+
**Trigger:**
13+
Runs on every `push` and `pull_request`.
14+
15+
**Key Features:**
16+
- **AVR Compilation:** Compiles all examples for the AVR platform (e.g., Arduino Uno).
17+
- **ESP8266 Compilation:** Compiles all examples for the ESP8266 platform (e.g., NodeMCU v2).
18+
- **Selective Compilation:** Skips ESP-specific examples (e.g., ESP-WebServer) when compiling for AVR.
19+
- **Unit Testing:** Executes unit tests using the `arduino_ci` framework.
20+
21+
### 2. 🔄 Why Separate AVR and ESP Platforms?
22+
23+
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:
24+
25+
- **AVR Compatibility:** Skips ESP-specific examples to prevent compilation errors.
26+
- **ESP Compatibility:** Compiles all examples, including ESP-specific ones, for the ESP8266 platform.
27+
28+
### 3. ⚙️ Workflow Steps
29+
30+
The workflow follows these steps:
31+
32+
1. **Setup Environment:**
33+
- Installs dependencies (e.g., `gcc-avr`, `avr-libc`).
34+
- Configures the Arduino CLI and installs required cores (`arduino:avr` and `esp8266:esp8266`).
35+
36+
2. **Install Libraries:**
37+
- Installs the OneWire library.
38+
- Applies a custom CRC implementation.
39+
40+
3. **Run Unit Tests:**
41+
- Executes unit tests using the `arduino_ci` framework for the AVR platform.
42+
43+
4. **Compile Examples for AVR:**
44+
- Compiles all examples (excluding ESP-specific ones) for the AVR platform.
45+
46+
5. **Compile Examples for ESP8266:**
47+
- Compiles all examples (including ESP-specific ones) for the ESP8266 platform.
48+
49+
### 4. 📁 File Structure
50+
51+
Understanding the project’s file structure is crucial for effective navigation and contribution. Below is an overview of the key files and directories:
52+
53+
- **`Gemfile`**
54+
- **Description:**
55+
Manages Ruby dependencies required for the project. It ensures that the correct versions of gems (like `arduino_ci`) are used.
56+
- **Usage:**
57+
Run `bundle install` to install the necessary gems.
58+
59+
- **`.arduino-ci.yml`**
60+
- **Description:**
61+
Configuration file for the `arduino_ci` tool. It defines how the Arduino CI should run tests and compile sketches.
62+
- **Key Configurations:**
63+
- Specifies which boards to target.
64+
- Defines libraries and dependencies needed for testing.
65+
- Sets up compilation and testing parameters.
66+
67+
- **`.arduino_ci/`**
68+
- **Description:**
69+
Contains supporting files and configurations for the `arduino_ci.rb` tool.
70+
- **Contents:**
71+
- **`config.rb`:**
72+
Custom configuration settings for the Arduino CI.
73+
- **`helpers.rb`:**
74+
Helper methods and utilities used by the CI scripts.
75+
- **Other supporting scripts and assets.**
76+
77+
- **`arduino-ci.yml`**
78+
- **Description:**
79+
GitHub Actions workflow file that defines the CI pipeline for the project.
80+
- **Key Sections:**
81+
- **Jobs:**
82+
Defines the sequence of steps for setting up the environment, installing dependencies, running tests, and compiling examples.
83+
- **Triggers:**
84+
Specifies when the workflow should run (e.g., on push or pull request).
85+
86+
- **`examples/`**
87+
- **Description:**
88+
Contains example sketches demonstrating how to use the Arduino Temperature Control Library.
89+
- **Structure:**
90+
- **`ESP-WebServer/`**
91+
ESP-specific examples that utilize libraries like `ESP8266WiFi.h`.
92+
93+
- **`LICENSE`**
94+
- **Description:**
95+
Contains the MIT License under which the project is released.
96+
97+
- **Other Files and Directories:**
98+
- **`.github/`**
99+
- Contains GitHub-specific configurations, issues templates, and additional workflows.
100+
- **`src/`**
101+
- Contains the source code of the Arduino Temperature Control Library.
102+
103+
### 5. 🔧 Workflow Configuration
104+
105+
The workflow is defined in the `arduino-ci.yml` file. Key configurations include:
106+
107+
- **Cores Installed:**
108+
```yaml
109+
arduino-cli core install arduino:avr
110+
arduino-cli core install esp8266:esp8266
111+
```
112+
113+
- **Skipping ESP-Specific Examples:**
114+
```yaml
115+
export ARDUINO_CI_SKIP_EXAMPLES="ESP-WebServer"
116+
```
117+
118+
- **Compiling for AVR and ESP Platforms:**
119+
```yaml
120+
arduino-cli compile --fqbn arduino:avr:uno "$sketch"
121+
arduino-cli compile --fqbn esp8266:esp8266:nodemcuv2 "$sketch"
122+
```
123+
124+
### 6. 🤝 Contributing
125+
126+
If you’re contributing to the workflows, please ensure that:
127+
128+
- **Compatibility:** New examples are compatible with both AVR and ESP platforms (if applicable).
129+
- **Organization:** ESP-specific examples are placed in a clearly labeled directory (e.g., `examples/ESP-WebServer`).
130+
- **Testing:** Unit tests are added or updated as needed.
131+
132+
### 7. 🐞 Troubleshooting
133+
134+
If the workflow fails:
135+
136+
1. **Check Logs:** Navigate to the Actions tab in GitHub for detailed logs.
137+
2. **Local Replication:** Try to replicate the issue locally using the dev container.
138+
3. **Dependencies:** Ensure all dependencies are installed correctly.
139+
140+
## 📄 License
141+
142+
This workflow configuration and scripts are released under the [MIT License](LICENSE).

.github/workflows/arduino-ci.yml

+16-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,22 @@ jobs:
7272
run: |
7373
ls -R
7474
75-
- name: Remove Blacklisted Example Sketches
75+
- name: Run tests (skip example compilation)
7676
run: |
77-
echo "Removing blacklisted example sketches..."
78-
rm -f examples/ESP-WebServer/ESP-WebServer.ino
77+
# Run arduino_ci for unit tests only (skip example compilation)
78+
export ARDUINO_CI_SELECTED_BOARD="arduino:avr:uno"
79+
bundle exec arduino_ci.rb --skip-examples-compilation
7980
80-
- name: Run tests
81+
- name: Compile all sketches for AVR platform
8182
run: |
82-
bundle exec arduino_ci.rb
83+
# Compile all sketches for AVR platform (Arduino Uno), excluding ESP-WebServer
84+
for sketch in $(find examples -name "*.ino" ! -path "*/ESP-WebServer/*"); do
85+
arduino-cli compile --fqbn arduino:avr:uno $sketch
86+
done
87+
88+
- name: Compile all sketches for ESP8266 platform
89+
run: |
90+
# Compile all sketches for ESP8266 platform (NodeMCU v2)
91+
for sketch in $(find examples -name "*.ino"); do
92+
arduino-cli compile --fqbn esp8266:esp8266:nodemcuv2 $sketch
93+
done

0 commit comments

Comments
 (0)