Skip to content

CI - build with arduino-cli #9241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/workflows/build-ide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
- name: Build Sketches
env:
ESP8266_ARDUINO_BUILDER: "arduino"
ESP8266_ARDUINO_IDE: "${{ runner.temp }}/arduino_ide"
ESP8266_ARDUINO_LWIP: ${{ matrix.lwip }}
run: |
bash ./tests/build.sh 8 ${{ matrix.chunk }}
Expand All @@ -75,8 +74,6 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh', 'tests/build.sh') }}
- name: Build Sketch
env:
ESP8266_ARDUINO_HARDWARE: "${{ runner.temp }}/hardware"
ESP8266_ARDUINO_IDE: "${{ runner.temp }}/arduino_ide"
ESP8266_ARDUINO_SKETCHES: "libraries/esp8266/examples/Blink/Blink.ino"
run: |
bash ./tests/build.sh
Expand All @@ -100,8 +97,6 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('package/package_esp8266com_index.template.json', 'tests/common.sh', 'tests/build.sh') }}
- name: Build Sketch
env:
ESP8266_ARDUINO_HARDWARE: "${{ runner.temp }}/hardware"
ESP8266_ARDUINO_IDE: "${{ runner.temp }}/arduino_ide"
ESP8266_ARDUINO_SKETCHES: "libraries/esp8266/examples/Blink/Blink.ino"
run: |
bash ./tests/build.sh
6 changes: 3 additions & 3 deletions libraries/esp8266/examples/ConfigFile/ConfigFile.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <LittleFS.h>

// more and possibly updated information can be found at:
// https://arduinojson.org/v6/example/config/
// https://arduinojson.org/v7/example/config/

bool loadConfig() {
File configFile = LittleFS.open("/config.json", "r");
Expand All @@ -21,7 +21,7 @@ bool loadConfig() {
return false;
}

StaticJsonDocument<200> doc;
JsonDocument doc;
auto error = deserializeJson(doc, configFile);
if (error) {
Serial.println("Failed to parse config file");
Expand All @@ -42,7 +42,7 @@ bool loadConfig() {
}

bool saveConfig() {
StaticJsonDocument<200> doc;
JsonDocument doc;
doc["serverName"] = "api.example.com";
doc["accessToken"] = "128du9as8du12eoue8da98h123ueh9h98";

Expand Down
49 changes: 39 additions & 10 deletions tests/build.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
#!/usr/bin/env bash

# expect to have git available
root=$(git rev-parse --show-toplevel)

# general configuration related to the builder itself
ESP8266_ARDUINO_BUILD_DIR=${ESP8266_ARDUINO_BUILD_DIR:-$root}
ESP8266_ARDUINO_BUILDER=${ESP8266_ARDUINO_BUILDER:-arduino}
ESP8266_ARDUINO_PRESERVE_CACHE=${ESP8266_ARDUINO_PRESERVE_CACHE:-}

ESP8266_ARDUINO_IDE=${ESP8266_ARDUINO_IDE:-$HOME/arduino_ide}
ESP8266_ARDUINO_HARDWARE=${ESP8266_ARDUINO_HARDWARE:-$HOME/Arduino/hardware}
ESP8266_ARDUINO_LIBRARIES=${ESP8266_ARDUINO_LIBRARIES:-$HOME/Arduino/libraries}

# sketch build options
ESP8266_ARDUINO_DEBUG=${ESP8266_ARDUINO_DEBUG:-nodebug}
ESP8266_ARDUINO_LWIP=${ESP8266_ARDUINO_LWIP:-default}
ESP8266_ARDUINO_SKETCHES=${ESP8266_ARDUINO_SKETCHES:-}

ESP8266_ARDUINO_CLI=${ESP8266_ARDUINO_CLI:-$HOME/.local/bin/arduino-cli}

# ref. https://arduino.github.io/arduino-cli/1.2/configuration/#default-directories
case "${RUNNER_OS:-Linux}" in
"Linux")
ESP8266_ARDUINO_HARDWARE=${ESP8266_ARDUINO_HARDWARE:-$HOME/Arduino/hardware}
ESP8266_ARDUINO_LIBRARIES=${ESP8266_ARDUINO_LIBRARIES:-$HOME/Arduino/libraries}
;;
"macOS")
ESP8266_ARDUINO_HARDWARE=${ESP8266_ARDUINO_HARDWARE:-$HOME/Documents/Arduino/hardware}
ESP8266_ARDUINO_LIBRARIES=${ESP8266_ARDUINO_LIBRARIES:-$HOME/Documents/Arduino/libraries}
;;
"Windows")
ESP8266_ARDUINO_HARDWARE=${ESP8266_ARDUINO_HARDWARE:-$HOME/Documents/Arduino/hardware}
ESP8266_ARDUINO_LIBRARIES=${ESP8266_ARDUINO_LIBRARIES:-$HOME/Documents/Arduino/libraries}
;;
*)
echo 'Unknown ${RUNNER_OS} = "' ${RUNNER_OS} '"'
exit 2
esac

source "$root/tests/lib-skip-ino.sh"
source "$root/tests/common.sh"

cmd=${0##*/}
Expand All @@ -22,21 +43,22 @@ ENVIRONMENT:
ESP8266_ARDUINO_SKETCHES - list of .ino files; defaults to **all available examples**
ESP8266_ARDUINO_BUILDER - arduino or platformio

For Arduino IDE:
ESP8266_ARDUINO_IDE - path to the IDE (portable)
For Arduino CLI:
ESP8266_ARDUINO_HARDWARE - path to the hardware directory (usually, containing our repo)
ESP8266_ARDUINO_LIBRATIES - path to the libraries directory (external dependencies)
ESP8266_ARDUINO_DEBUG - debug or nodebug
ESP8266_ARDUINO_LWIP - v4 or v6

USAGE:
$cmd <[even | odd]> - build every Nth, when '<N> % 2' is either even or odd
$cmd <mod> <rem> - build every Nth, when '<N> % <mod>' is equal to 'rem'
$cmd <mod> <rem> <[cnt]> - build every Nth, when '<N> % <mod>' is equal to 'rem'
optionally, set <cnt> to start with the Nth sketch
$cmd - build every .ino file from ESP8266_ARDUINO_SKETCHES
"

mod=1
rem=0
cnt=0

if [ "$#" -eq 1 ] ; then
case "$1" in
Expand All @@ -60,6 +82,10 @@ if [ "$#" -eq 1 ] ; then
elif [ "$#" -eq 2 ] ; then
mod=$1
rem=$2
elif [ "$#" -eq 3 ] ; then
mod=$1
rem=$2
cnt=$3
elif [ "$#" -gt 2 ] ; then
echo "$usage"
exit 1
Expand All @@ -72,14 +98,17 @@ fi
case "$ESP8266_ARDUINO_BUILDER" in
"arduino")
install_arduino "$ESP8266_ARDUINO_DEBUG"
build_sketches_with_arduino "$mod" "$rem" "$ESP8266_ARDUINO_LWIP"
build_sketches_with_arduino "$ESP8266_ARDUINO_LWIP" "$mod" "$rem" "$cnt"
;;
"platformio")
install_platformio nodemcuv2
build_sketches_with_platformio "$mod" "$rem"
build_sketches_with_platformio "$mod" "$rem" "$cnt"
;;
"print")
print_sketch_info "$mod" "$rem"
;;
*)
echo "Unknown builder! Must be either arduino or platformio"
echo "Unknown builder! Must be one of - arduino, platformio or print"
exit 1
;;
esac
Loading