Skip to content

Commit 4aa379e

Browse files
committed
sync
2 parents d97bb3d + ff4137f commit 4aa379e

29 files changed

+1943
-1444
lines changed

.arduino-ci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
# .arduino-ci.yml
2+
3+
# Compilation settings
14
compile:
2-
# Choosing to run compilation tests on 2 different Arduino platforms
35
platforms:
46
- uno
5-
- due
6-
# - zero # SAMD covered by M4
7-
# - leonardo # AVR covered by UNO
8-
- m4
9-
# - esp32 # errors on OneWire => util/crc16.h vs rom/crc.h
10-
- esp8266
11-
# - mega2560 # AVR covered by UNO
12-
unittest:
13-
# These dependent libraries will be installed
147
libraries:
158
- "OneWire"
9+
10+
# Unit testing settings
11+
unittest:
12+
platforms:
13+
- uno
14+
libraries:
15+
- "OneWire"

.arduino_ci/.arduino-ci.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#define ARDUINO_CI 1
2+
3+
// Mock OneWire GPIO functions
4+
uint8_t digitalPinToBitMask(uint8_t pin) { return 1 << (pin % 8); }
5+
void* digitalPinToPort(uint8_t pin) { static uint8_t dummy; return &dummy; }
6+
void* portModeRegister(void* port) { return port; }

.arduino_ci/util/crc16.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef CRC16_H
2+
#define CRC16_H
3+
4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
8+
// Pure C implementation to replace the ASM version
9+
static inline uint16_t _crc16_update(uint16_t crc, uint8_t data) {
10+
unsigned int i;
11+
crc ^= data;
12+
for (i = 0; i < 8; ++i) {
13+
if (crc & 1)
14+
crc = (crc >> 1) ^ 0xA001;
15+
else
16+
crc = (crc >> 1);
17+
}
18+
return crc;
19+
}
20+
21+
#ifdef __cplusplus
22+
}
23+
#endif
24+
25+
#endif

.devcontainer/Dockerfile

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
FROM mcr.microsoft.com/vscode/devcontainers/cpp:debian
2+
3+
# Install required packages
4+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5+
&& apt-get -y install --no-install-recommends \
6+
python3 \
7+
python3-pip \
8+
git \
9+
curl \
10+
fish \
11+
&& apt-get clean \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
RUN mkdir -p /home/vscode/.local/share/CMakeTools \
15+
&& chown -R vscode:vscode /home/vscode/.local/share/CMakeTools
16+
17+
RUN mkdir -p /home/vscode/.ssh \
18+
&& chown vscode:vscode /home/vscode/.ssh \
19+
&& chmod 700 /home/vscode/.ssh
20+
21+
# Install arduino-cli
22+
RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
23+
24+
# Set up arduino-cli config
25+
RUN arduino-cli config init
26+
27+
# Add arduino-cli to PATH
28+
ENV PATH="/usr/local/bin:${PATH}"
29+
30+
# Create workspace directory
31+
WORKDIR /workspace
32+
33+
# Copy arduino-cli configuration (customise to your actual path)
34+
COPY arduino-cli.yaml /root/.arduino15/arduino-cli.yaml
35+
36+
# Install build essentials
37+
RUN apt-get update && apt-get install -y build-essential && rm -rf /var/lib/apt/lists/*
38+
39+
# (Optional) Install Arduino cores for ESP8266 and ESP32 if needed
40+
RUN arduino-cli core install esp8266:esp8266 esp32:esp32
41+
42+
# Install only required dependencies for DallasTemperature library and others
43+
RUN arduino-cli lib install \
44+
"OneWire" \
45+
"ArduinoUnit" # For testing
46+
47+
# Verify library installation
48+
RUN arduino-cli lib list
49+
50+
# Copy update script
51+
COPY update-libraries.sh /usr/local/bin/
52+
RUN chmod +x /usr/local/bin/update-libraries.sh
53+
54+
# Add aliases for build operations (for Bash)
55+
RUN echo 'alias arduino-build="./build.sh build"' >> /home/vscode/.bashrc && \
56+
echo 'alias arduino-test="./build.sh test"' >> /home/vscode/.bashrc && \
57+
echo 'alias arduino-build-test="./build.sh all"' >> /home/vscode/.bashrc
58+
59+
# Add a welcome message to .bashrc
60+
RUN echo '\n# Welcome to the dev container! Here are some useful aliases:' >> /home/vscode/.bashrc && \
61+
echo 'echo " - arduino-build: Build the project"' >> /home/vscode/.bashrc && \
62+
echo 'echo " - arduino-test: Run tests for the project"' >> /home/vscode/.bashrc && \
63+
echo 'echo " - arduino-build-test: Build and test the project"' >> /home/vscode/.bashrc
64+
65+
# (Optional) Add fish-specific configuration if desired
66+
# For example, you might add an alias file or welcome message for fish:
67+
RUN mkdir -p /home/vscode/.config/fish && \
68+
echo 'set -gx PATH /usr/local/bin $PATH' >> /home/vscode/.config/fish/config.fish && \
69+
echo '# Welcome to the Fish shell inside the dev container!' >> /home/vscode/.config/fish/config.fish
70+
71+
# Generate SSH keys and set proper ownership and permissions
72+
RUN if [ ! -f /home/vscode/.ssh/id_rsa ]; then \
73+
ssh-keygen -t rsa -b 4096 -N "" -C "devcontainer@local" -f /home/vscode/.ssh/id_rsa && \
74+
chmod 600 /home/vscode/.ssh/id_rsa && \
75+
chmod 644 /home/vscode/.ssh/id_rsa.pub && \
76+
chown vscode:vscode /home/vscode/.ssh/id_rsa /home/vscode/.ssh/id_rsa.pub ; \
77+
fi

.devcontainer/arduino-cli.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
compile:
2+
# Choosing to run compilation tests on 2 different Arduino platforms
3+
platforms:
4+
- uno
5+
- due
6+
# - zero # SAMD covered by M4
7+
# - leonardo # AVR covered by UNO
8+
- m4
9+
# - esp32 # errors on OneWire => util/crc16.h vs rom/crc.h
10+
# - esp8266
11+
# - mega2560 # AVR covered by UNO
12+
unittest:
13+
# These dependent libraries will be installed
14+
libraries:
15+
- "OneWire"
16+
board_manager:
17+
additional_urls:
18+
- https://arduino.esp8266.com/stable/package_esp8266com_index.json
19+
- https://dl.espressif.com/dl/package_esp32_index.json

.devcontainer/devcontainer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "Arduino Library Development",
3+
"dockerFile": "Dockerfile",
4+
"mounts": [
5+
"source=devcontainer_ssh,target=/home/vscode/.ssh,type=volume",
6+
"source=devcontainer_bash_history,target=/home/vscode/.bash_history,type=volume",
7+
"source=devcontainer_fish_history,target=/home/vscode/.local/share/fish/fish_history,type=volume"
8+
],
9+
"customizations": {
10+
"vscode": {
11+
"extensions": [
12+
"vsciot-vscode.vscode-arduino",
13+
"ms-vscode.cpptools",
14+
"ms-azuretools.vscode-docker",
15+
"yzhang.markdown-all-in-one"
16+
]
17+
}
18+
},
19+
"postCreateCommand": "arduino-cli core install arduino:avr && arduino-cli lib install ArduinoUnit && /usr/local/bin/update-libraries.sh",
20+
"updateContentCommand": "/usr/local/bin/update-libraries.sh",
21+
"remoteUser": "vscode"
22+
}
23+

.devcontainer/update-libraries.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
echo "Updating arduino-cli core and index..."
4+
arduino-cli core update-index
5+
arduino-cli update
6+
7+
echo "Updating installed libraries..."
8+
arduino-cli lib update-index
9+
arduino-cli lib upgrade
10+
11+
# Update Arduino cores
12+
echo "Updating ESP8266 and ESP32 cores..."
13+
arduino-cli core install esp8266:esp8266
14+
arduino-cli core install esp32:esp32
15+
16+
# List of libraries to ensure are installed/updated
17+
LIBRARIES=(
18+
"OneWire"
19+
"ArduinoUnit"
20+
)
21+
22+
echo "Checking and installing libraries..."
23+
for lib in "${LIBRARIES[@]}"; do
24+
echo "Processing library: $lib"
25+
if ! arduino-cli lib list | grep -q "$lib"; then
26+
echo "Installing $lib..."
27+
arduino-cli lib install "$lib"
28+
else
29+
echo "$lib is already installed"
30+
fi
31+
done
32+
33+
echo "Verifying all libraries are up to date..."
34+
arduino-cli lib list
35+
36+
echo "Library update complete!"

.github/workflows/README.md

Lines changed: 142 additions & 0 deletions
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).

0 commit comments

Comments
 (0)