From d5f718a325929e7ac0679d21f4e92fc048be9526 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 15:05:00 +0200 Subject: [PATCH 01/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 97 +++++++++++++++++++++++ ReadMe.md | 120 +++++++++++++++++------------ 2 files changed, 167 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/ArduinoBuild.yml diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml new file mode 100644 index 0000000..ccf2ba1 --- /dev/null +++ b/.github/workflows/ArduinoBuild.yml @@ -0,0 +1,97 @@ +name: ArduinoBuild + +env: + SKETCH_NAME: test.ino + +on: + push: # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request + paths: + - '**.ino' + - '**.cpp' + - '**.hpp' + - '**.h' + - '**.c' + - '**ArduinoBuild.yml' + pull_request: + +jobs: + build: + name: ${{matrix.board}}@${{matrix.platform-version}} + + runs-on: ubuntu-latest + + strategy: + matrix: + + platform-url: + - https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json + + board: + # ESP32 devices for 3D matrix + - esp32 + - esp32s2 + - esp32s3 + - esp33c3 + + platform-version: + # ESP32 Core versions for 3D matrix + - 1.0.6 + - 2.0.0 + - 2.0.1 + - 2.0.2 + - 2.0.3 + - 2.0.4 + - latest + + include: + # 3D matrix doesn't apply to these profiles, so they are implicitely listed + - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, platform-url: 'https://arduino.esp8266.com/stable/package_esp8266com_index.json', ... } + - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.2, platform-url: 'https://arduino.esp8266.com/stable/package_esp8266com_index.json', ... } + - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, platform-url: 'https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json', ... } + - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: 2.3.3, cli-args: '--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST', platform-url: 'https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json', ... } + + # 3D matrix applies to these: + - { board: esp32, platform: esp32, archi: esp32, ... } + - { board: esp32s2, platform: esp32, archi: esp32, ... } + - { board: esp32s3, platform: esp32, archi: esp32, ... } + - { board: esp32c3, platform: esp32, archi: esp32, ... } + + exclude: + # 3D matrix excludes these: + - { board: esp32s2, platform-version: 1.0.6 } + - { board: esp32s2, platform-version: 2.0.0 } + + - { board: esp32s3, platform-version: 1.0.6 } + - { board: esp32s3, platform-version: 2.0.0 } + - { board: esp32s3, platform-version: 2.0.1 } + - { board: esp32s3, platform-version: 2.0.2 } + - { board: esp32s3, platform-version: 2.0.4 } + + - { board: esp32c3, platform-version: 1.0.6 } + - { board: esp32c3, platform-version: 2.0.0 } + + + + + + fail-fast: false + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Compile example + uses: ArminJo/arduino-test-compile@v3 + with: + arduino-board-fqbn: ${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}} + arduino-platform: ${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} + platform-url: ${{ matrix.platform-url }} + required-libraries: ${{ matrix.required-libraries }} + extra-arduino-cli-args: ${{ matrix.cli-args }} + #build-properties: ${{ toJson(matrix.build-properties) }} + sketch-names: ${{ env.SKETCH_NAME }} + #sketches-exclude: ${{ matrix.sketches-exclude }} + + diff --git a/ReadMe.md b/ReadMe.md index 1f039ab..62933b2 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -49,23 +49,23 @@ or YAML is a superset of JSON, so native conversion from/to JSON is possible without any additional JSON library. ```cpp - // JSON <=> YAML stream to stream conversion (both ways!), accepts valid JSON or YAML as the input - // Available values for output format: - // YAMLParser::OUTPUT_YAML - // YAMLParser::OUTPUT_JSON - // YAMLParser::OUTPUT_JSON_PRETTY - size_t serializeYml( Stream &source, Stream &destination, OutputFormat_t format ); +// JSON <=> YAML stream to stream conversion (both ways!). +// Accepts valid JSON or YAML as the input. +// Available values for output format: +// YAMLParser::OUTPUT_YAML +// YAMLParser::OUTPUT_JSON +// YAMLParser::OUTPUT_JSON_PRETTY +size_t serializeYml( Stream &source, Stream &destination, OutputFormat_t format ); ``` **Convert YAML to JSON** ```cpp +String yaml_str = "hello: world\nboolean: true\nfloat: 1.2345"; +StringStream yaml_stream( yaml_str ); - String yaml_str = "hello: world\nboolean: true\nfloat: 1.2345"; - StringStream yaml_stream( yaml_str ); - - serializeYml( yaml_stream, Serial, YAMLParser::OUTPUT_JSON_PRETTY ); +serializeYml( yaml_stream, Serial, YAMLParser::OUTPUT_JSON_PRETTY ); ``` @@ -73,11 +73,10 @@ YAML is a superset of JSON, so native conversion from/to JSON is possible withou **Convert JSON to YAML** ```cpp +String json_str = "{\"hello\": \"world\", \"boolean\": true, \"float\":1.2345}"; +StringStream json_stream( json_str ); - String json_str = "{\"hello\": \"world\", \"boolean\": true, \"float\":1.2345}"; - StringStream json_stream( json_str ); - - serializeYml( json_stream, Serial, YAMLParser::OUTPUT_YAML ); +serializeYml( json_stream, Serial, YAMLParser::OUTPUT_YAML ); ``` @@ -102,7 +101,7 @@ So all ArduinoJson functions will be disabled unless `#include ` On ESP8266/RP2040/SAMD platforms it is assumed that ArduinoJson is already available as a dependency. -In order to save flash space and/or memory, the defaults bindings can be disabled independently by setting one or all of the +In order to save flash space and/or memory, the default bindings can be disabled independently by setting one or all of the following macros before including ArduinoYaml: ```cpp @@ -120,29 +119,32 @@ Note to readers: should ArduinoJson and/or cJSON be implicitely loaded? ## ArduinoJson bindings -The support is implicitely enabled on most platforms. +See the [motivational post](https://github.com/bblanchon/ArduinoJson/issues/1808) for this implementation. + +ArduinoJson support is implicitely enabled on most platforms except for ESP32 where dependencies can be detected. ```cpp - #include // ESP32 plaforms must include this before ArduinoYaml or functions will be disabled - #include +// ESP32 plaforms must include ArduinoJson before ArduinoYaml or functions will be disabled +#include +#include ``` Enabling support will expose the following functions: ```cpp - // ArduinoJSON object to YAML string - size_t serializeYml( JsonVariant src_obj, String &dest_string ); - // ArduinoJSON object to YAML stream - size_t serializeYml( JsonVariant src_obj, Stream &dest_stream ); - // Deserialize YAML string to ArduinoJSON object - DeserializationError deserializeYml( JsonObject &dest_obj, const char* src_yaml_str ); - // Deserialize YAML stream to ArduinoJSON object - DeserializationError deserializeYml( JsonObject &dest_obj, Stream &src_stream ); - // Deserialize YAML string to ArduinoJSON document - DeserializationError deserializeYml( JsonDocument &dest_doc, Stream &src_stream ); - // Deserialize YAML string to ArduinoJSON document - DeserializationError deserializeYml( JsonDocument &dest_doc, const char *src_yaml_str) ; +// ArduinoJSON object to YAML string +size_t serializeYml( JsonVariant src_obj, String &dest_string ); +// ArduinoJSON object to YAML stream +size_t serializeYml( JsonVariant src_obj, Stream &dest_stream ); +// Deserialize YAML string to ArduinoJSON object +DeserializationError deserializeYml( JsonObject &dest_obj, const char* src_yaml_str ); +// Deserialize YAML stream to ArduinoJSON object +DeserializationError deserializeYml( JsonObject &dest_obj, Stream &src_stream ); +// Deserialize YAML string to ArduinoJSON document +DeserializationError deserializeYml( JsonDocument &dest_doc, Stream &src_stream ); +// Deserialize YAML string to ArduinoJSON document +DeserializationError deserializeYml( JsonDocument &dest_doc, const char *src_yaml_str) ; ``` @@ -150,11 +152,11 @@ Enabling support will expose the following functions: ## cJSON bindinds -The support is implicitely enabled on most platforms and will use the bundled cJSON version. -ESP32 will use the built-in version. +cJSON support is implicitely enabled on most platforms, and will use the bundled cJSON version unless ESP32 platform is detected. +ESP32 will use the built-in cJSON version from esp-idf instead of the YAMLDuino bundled version. -⚠️ both versions of cJSON have a memory leak with floats, the leak happens only once though, and +⚠️ Both versions of cJSON have a memory leak with floats, the leak happens only once though, and may be avoided by quoting the float, which won't affect yaml output. @@ -162,14 +164,14 @@ Enabling support will expose the following functions: ```cpp - // cJSON object to YAML string - size_t serializeYml( cJSON* src_obj, String &dest_string ); - // cJSON object to YAML stream - size_t serializeYml( cJSON* src_obj, Stream &dest_stream ); - // YAML string to cJSON object - int deserializeYml( cJSON* dest_obj, const char* src_yaml_str ); - // YAML stream to cJSON object - int deserializeYml( cJSON* dest_obj, Stream &src_stream ); +// cJSON object to YAML string +size_t serializeYml( cJSON* src_obj, String &dest_string ); +// cJSON object to YAML stream +size_t serializeYml( cJSON* src_obj, Stream &dest_stream ); +// YAML string to cJSON object +int deserializeYml( cJSON* dest_obj, const char* src_yaml_str ); +// YAML stream to cJSON object +int deserializeYml( cJSON* dest_obj, Stream &src_stream ); ``` @@ -183,12 +185,11 @@ The `StringStream` class is provided with this library as a helper. ```cpp - String my_json = "{\"blah\":true}"; +String my_json = "{\"blah\":true}"; +StringStream json_input_stream(my_json); - StringStream json_input_stream(my_json); - - String my_output; - StringStream output_stream(my_output); +String my_output; +StringStream output_stream(my_output); ``` @@ -224,8 +225,8 @@ JSON and YAML indentation levels can be customized: ```cpp - void YAML::setYAMLIndent( int spaces_per_indent=2 ); // min=2, max=16 - void YAML::setJSONIndent( const char* spaces_or_tabs=JSON_SCALAR_TAB, int folding_depth=JSON_FOLDING_DEPTH ); +void YAML::setYAMLIndent( int spaces_per_indent=2 ); // min=2, max=16 +void YAML::setJSONIndent( const char* spaces_or_tabs="\t", int folding_depth=4 ); ``` @@ -233,7 +234,7 @@ JSON and YAML indentation levels can be customized: Set custom JSON indentation and folding depth: ```cpp -// two spaces per indentation level, unfold up to 8 nesting levels +// this set two spaces per indentation level, unfolds up to 8 nesting levels YAMLParser::setJSONIndent(" ", 8 ); // lame fact: folds on objects, not on arrays ``` @@ -258,7 +259,7 @@ The debug level can be changed at runtime: ```cpp - void YAML::setLogLevel( LogLevel_t level ); +void YAML::setLogLevel( LogLevel_t level ); ``` Set library debug level: @@ -275,6 +276,23 @@ Set library debug level: YAMLParser::setLogLevel( YAML::LogLevelDebug ); ``` +---------------------------- + + +## Support the Project + +There are a few things you can do to support the project: + + - Star 🌟 this [repository](https://github.com/tobozo/YAMLDuino) and/or [follow me](https://github.com/tobozo/) on GitHub + - Share and upvote on sites like Twitter, Reddit, and Hacker News + - [Report](https://github.com/tobozo/YAMLDuino/issues) any bugs, glitches, or errors that you find + + +These things motivate me to to keep sharing what I build, and they provide +validation that my work is appreciated! They also help me improve the +project. Thanks in advance! + + ---------------------------- ## Credits and special thanks to: @@ -284,6 +302,8 @@ YAMLParser::setLogLevel( YAML::LogLevelDebug ); - [@bblanchon](https://github.com/bblanchon) - [@vikman90](https://github.com/vikman90/yaml2json) + + ## Additional resources: - ArduinoJson : https://github.com/bblanchon/ArduinoJson From c769a722746ac82152655761bf72658caa0ba430 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 15:08:28 +0200 Subject: [PATCH 02/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index ccf2ba1..20d507d 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -31,7 +31,7 @@ jobs: - esp32 - esp32s2 - esp32s3 - - esp33c3 + - esp32c3 platform-version: # ESP32 Core versions for 3D matrix @@ -41,7 +41,8 @@ jobs: - 2.0.2 - 2.0.3 - 2.0.4 - - latest + - 2.0.5 + #- latest include: # 3D matrix doesn't apply to these profiles, so they are implicitely listed From 9e06414f061531f0534a3b1cd8dfdfe32434c4fa Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 15:10:12 +0200 Subject: [PATCH 03/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 20d507d..947f99d 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -25,6 +25,8 @@ jobs: platform-url: - https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json + required-libraries: + - ArduinoJson board: # ESP32 devices for 3D matrix @@ -42,6 +44,7 @@ jobs: - 2.0.3 - 2.0.4 - 2.0.5 + - #- latest include: From eeec3769adabf600d759c56678b60ed34524f78e Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 15:30:07 +0200 Subject: [PATCH 04/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 947f99d..6809af0 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -29,14 +29,14 @@ jobs: - ArduinoJson board: - # ESP32 devices for 3D matrix + # ESP32 devices for multidimensional matrix - esp32 - esp32s2 - esp32s3 - esp32c3 platform-version: - # ESP32 Core versions for 3D matrix + # ESP32 Core versions for multidimensional matrix - 1.0.6 - 2.0.0 - 2.0.1 @@ -44,24 +44,23 @@ jobs: - 2.0.3 - 2.0.4 - 2.0.5 - - - #- latest + - latest include: - # 3D matrix doesn't apply to these profiles, so they are implicitely listed + # multidimensional matrix doesn't apply to these profiles, so they are implicitely listed - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, platform-url: 'https://arduino.esp8266.com/stable/package_esp8266com_index.json', ... } - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.2, platform-url: 'https://arduino.esp8266.com/stable/package_esp8266com_index.json', ... } - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, platform-url: 'https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json', ... } - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: 2.3.3, cli-args: '--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST', platform-url: 'https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json', ... } - # 3D matrix applies to these: + # multidimensional matrix applies to these: - { board: esp32, platform: esp32, archi: esp32, ... } - { board: esp32s2, platform: esp32, archi: esp32, ... } - { board: esp32s3, platform: esp32, archi: esp32, ... } - { board: esp32c3, platform: esp32, archi: esp32, ... } exclude: - # 3D matrix excludes these: + # multidimensional matrix excludes these: - { board: esp32s2, platform-version: 1.0.6 } - { board: esp32s2, platform-version: 2.0.0 } From fa2ee09e2bc8f1a9a036270aadfc6c48f40b93ca Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:00:52 +0200 Subject: [PATCH 05/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 6809af0..31361dd 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -25,8 +25,6 @@ jobs: platform-url: - https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json - required-libraries: - - ArduinoJson board: # ESP32 devices for multidimensional matrix @@ -44,7 +42,7 @@ jobs: - 2.0.3 - 2.0.4 - 2.0.5 - - latest + #- latest include: # multidimensional matrix doesn't apply to these profiles, so they are implicitely listed @@ -91,7 +89,8 @@ jobs: arduino-board-fqbn: ${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}} arduino-platform: ${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} platform-url: ${{ matrix.platform-url }} - required-libraries: ${{ matrix.required-libraries }} + required-libraries: ArduinoJson + #required-libraries: ${{ matrix.required-libraries }} extra-arduino-cli-args: ${{ matrix.cli-args }} #build-properties: ${{ toJson(matrix.build-properties) }} sketch-names: ${{ env.SKETCH_NAME }} From a145d89fe3d08e221d99b7071468d1f85873b94c Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:03:23 +0200 Subject: [PATCH 06/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 31361dd..3ec2627 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -59,6 +59,8 @@ jobs: exclude: # multidimensional matrix excludes these: + - { board: esp32, platform-version: 2.0.1 } + - { board: esp32s2, platform-version: 1.0.6 } - { board: esp32s2, platform-version: 2.0.0 } From 89a39a847272984a577a45c62e609f3202f464a7 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:17:30 +0200 Subject: [PATCH 07/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 3ec2627..cb23e62 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -42,7 +42,7 @@ jobs: - 2.0.3 - 2.0.4 - 2.0.5 - #- latest + - latest include: # multidimensional matrix doesn't apply to these profiles, so they are implicitely listed @@ -59,7 +59,6 @@ jobs: exclude: # multidimensional matrix excludes these: - - { board: esp32, platform-version: 2.0.1 } - { board: esp32s2, platform-version: 1.0.6 } - { board: esp32s2, platform-version: 2.0.0 } @@ -85,11 +84,16 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} + - name: FBQN Check + run: | + export ARDUINO_PLATFORM="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" + echo "::set-env name=ARDUINO_PLATFORM::$ARDUINO_PLATFORM" + - name: Compile example uses: ArminJo/arduino-test-compile@v3 with: arduino-board-fqbn: ${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}} - arduino-platform: ${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} + arduino-platform: ${{ARDUINO_PLATFORM}} platform-url: ${{ matrix.platform-url }} required-libraries: ArduinoJson #required-libraries: ${{ matrix.required-libraries }} From 3ef81a191b4131e09b130901a0966233a7416a22 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:18:25 +0200 Subject: [PATCH 08/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index cb23e62..ad8b38f 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -93,7 +93,7 @@ jobs: uses: ArminJo/arduino-test-compile@v3 with: arduino-board-fqbn: ${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}} - arduino-platform: ${{ARDUINO_PLATFORM}} + arduino-platform: ${{env.ARDUINO_PLATFORM}} platform-url: ${{ matrix.platform-url }} required-libraries: ArduinoJson #required-libraries: ${{ matrix.required-libraries }} From dcdd6352c33677e01e6918aea16a56b3ed33d0bd Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:21:37 +0200 Subject: [PATCH 09/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index ad8b38f..16c5c57 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -87,7 +87,7 @@ jobs: - name: FBQN Check run: | export ARDUINO_PLATFORM="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" - echo "::set-env name=ARDUINO_PLATFORM::$ARDUINO_PLATFORM" + echo "ARDUINO_PLATFORM=$ARDUINO_PLATFORM" >> $GITHUB_ENV - name: Compile example uses: ArminJo/arduino-test-compile@v3 From 37d70422991be811d5596553cc73688013dbcdda Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:36:09 +0200 Subject: [PATCH 10/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 16c5c57..e8bf546 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -15,6 +15,18 @@ on: pull_request: jobs: + + export-board-urls: + + - name: Board URLs exporter + run: | + echo "esp32-platform-url=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json" >> $GITHUB_ENV + echo "esp8266-platform-url=https://arduino.esp8266.com/stable/package_esp8266com_index.json" >> $GITHUB_ENV + echo "seeed-platform-url=https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json" >> $GITHUB_ENV + echo "pico-platform-url=https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json" >> $GITHUB_ENV + echo "pico-cli-args=${"--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST"}" >> $GITHUB_ENV + + build: name: ${{matrix.board}}@${{matrix.platform-version}} @@ -46,10 +58,10 @@ jobs: include: # multidimensional matrix doesn't apply to these profiles, so they are implicitely listed - - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, platform-url: 'https://arduino.esp8266.com/stable/package_esp8266com_index.json', ... } - - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.2, platform-url: 'https://arduino.esp8266.com/stable/package_esp8266com_index.json', ... } + - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, platform-url: '${env.esp8266-platform-url}', ... } + - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: latest, platform-url: 'https://arduino.esp8266.com/stable/package_esp8266com_index.json', ... } - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, platform-url: 'https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json', ... } - - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: 2.3.3, cli-args: '--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST', platform-url: 'https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json', ... } + - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: latest, cli-args: '--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST', platform-url: 'https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json', ... } # multidimensional matrix applies to these: - { board: esp32, platform: esp32, archi: esp32, ... } From 0234f0617383b36ae798300b89f7d8bf5769aa95 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:40:54 +0200 Subject: [PATCH 11/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 31 ++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index e8bf546..900972e 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -16,21 +16,36 @@ on: jobs: - export-board-urls: - - name: Board URLs exporter - run: | - echo "esp32-platform-url=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json" >> $GITHUB_ENV - echo "esp8266-platform-url=https://arduino.esp8266.com/stable/package_esp8266com_index.json" >> $GITHUB_ENV - echo "seeed-platform-url=https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json" >> $GITHUB_ENV - echo "pico-platform-url=https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json" >> $GITHUB_ENV - echo "pico-cli-args=${"--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST"}" >> $GITHUB_ENV + set_env: + name: "Set environment" + runs-on: ubuntu-latest + env: + esp32-platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json + esp8266-platform-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json + seeed-platform-url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json + pico-platform-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + pico-cli-args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST + + outputs: + env: ${{steps.set-env.outputs.env}} + steps: + # Avoid multiline: flatten JSON + - id: set-env + run: | + content='${{ toJson(env) }}' + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + echo "::set-output name=env::$content" build: name: ${{matrix.board}}@${{matrix.platform-version}} runs-on: ubuntu-latest + needs: set_env + env: ${{fromJSON(needs.set_env.outputs.env)}} strategy: matrix: From 91480c9b48d0031a9a7212033901715ede670fec Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:42:58 +0200 Subject: [PATCH 12/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 900972e..0732b0c 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -73,7 +73,7 @@ jobs: include: # multidimensional matrix doesn't apply to these profiles, so they are implicitely listed - - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, platform-url: '${env.esp8266-platform-url}', ... } + - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, platform-url: ${env.esp8266-platform-url}, ... } - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: latest, platform-url: 'https://arduino.esp8266.com/stable/package_esp8266com_index.json', ... } - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, platform-url: 'https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json', ... } - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: latest, cli-args: '--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST', platform-url: 'https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json', ... } From f7dba2cdc3bda49892b774ca314a5fa384142dd8 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:45:00 +0200 Subject: [PATCH 13/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 0732b0c..b7b275d 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -73,7 +73,7 @@ jobs: include: # multidimensional matrix doesn't apply to these profiles, so they are implicitely listed - - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, platform-url: ${env.esp8266-platform-url}, ... } + - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, platform-url: '${{env.esp8266-platform-url}}', ... } - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: latest, platform-url: 'https://arduino.esp8266.com/stable/package_esp8266com_index.json', ... } - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, platform-url: 'https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json', ... } - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: latest, cli-args: '--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST', platform-url: 'https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json', ... } From f94aa730a399b3d427014dedad32d5b6193b3084 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:47:08 +0200 Subject: [PATCH 14/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index b7b275d..f6d1482 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -22,11 +22,11 @@ jobs: name: "Set environment" runs-on: ubuntu-latest env: - esp32-platform-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json - esp8266-platform-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json - seeed-platform-url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json - pico-platform-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - pico-cli-args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST + esp32_platform_url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json + esp8266_platform_url: https://arduino.esp8266.com/stable/package_esp8266com_index.json + seeed_platform_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json + pico_platform_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + pico_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST outputs: env: ${{steps.set-env.outputs.env}} @@ -73,7 +73,7 @@ jobs: include: # multidimensional matrix doesn't apply to these profiles, so they are implicitely listed - - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, platform-url: '${{env.esp8266-platform-url}}', ... } + - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, platform-url: '${{env.esp8266_platform_url}}', ... } - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: latest, platform-url: 'https://arduino.esp8266.com/stable/package_esp8266com_index.json', ... } - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, platform-url: 'https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json', ... } - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: latest, cli-args: '--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST', platform-url: 'https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json', ... } From 1456ea470f71c3e91c5dbfce00c1bcf28f151e4d Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:50:04 +0200 Subject: [PATCH 15/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index f6d1482..dbb4818 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -26,7 +26,7 @@ jobs: esp8266_platform_url: https://arduino.esp8266.com/stable/package_esp8266com_index.json seeed_platform_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json pico_platform_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - pico_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST + #pico_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST outputs: env: ${{steps.set-env.outputs.env}} @@ -42,7 +42,6 @@ jobs: build: name: ${{matrix.board}}@${{matrix.platform-version}} - runs-on: ubuntu-latest needs: set_env env: ${{fromJSON(needs.set_env.outputs.env)}} From ac93b8ece071259d81cb5281712345a821a9cfcc Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:59:25 +0200 Subject: [PATCH 16/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 57 +++++++++++------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index dbb4818..df98e33 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -16,41 +16,15 @@ on: jobs: - - set_env: - - name: "Set environment" - runs-on: ubuntu-latest - env: - esp32_platform_url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json - esp8266_platform_url: https://arduino.esp8266.com/stable/package_esp8266com_index.json - seeed_platform_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json - pico_platform_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - #pico_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST - - outputs: - env: ${{steps.set-env.outputs.env}} - steps: - # Avoid multiline: flatten JSON - - id: set-env - run: | - content='${{ toJson(env) }}' - content="${content//'%'/'%25'}" - content="${content//$'\n'/'%0A'}" - content="${content//$'\r'/'%0D'}" - echo "::set-output name=env::$content" - build: name: ${{matrix.board}}@${{matrix.platform-version}} runs-on: ubuntu-latest - needs: set_env - env: ${{fromJSON(needs.set_env.outputs.env)}} strategy: matrix: - platform-url: - - https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json + #platform-url: + #- https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json board: # ESP32 devices for multidimensional matrix @@ -72,10 +46,10 @@ jobs: include: # multidimensional matrix doesn't apply to these profiles, so they are implicitely listed - - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, platform-url: '${{env.esp8266_platform_url}}', ... } - - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: latest, platform-url: 'https://arduino.esp8266.com/stable/package_esp8266com_index.json', ... } - - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, platform-url: 'https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json', ... } - - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: latest, cli-args: '--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST', platform-url: 'https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json', ... } + - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, , ... } + - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: latest, ... } + - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, ... } + - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: latest, ... } # multidimensional matrix applies to these: - { board: esp32, platform: esp32, archi: esp32, ... } @@ -99,9 +73,6 @@ jobs: - { board: esp32c3, platform-version: 2.0.0 } - - - fail-fast: false steps: @@ -115,15 +86,27 @@ jobs: export ARDUINO_PLATFORM="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" echo "ARDUINO_PLATFORM=$ARDUINO_PLATFORM" >> $GITHUB_ENV + board[esp32]=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json + board[esp8266]=https://arduino.esp8266.com/stable/package_esp8266com_index.json + board[seeed]=https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json + board[rp2040]=https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + args[rp2040]=--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST + + echo "ARDUINO_PLATFORM_URL=${board[${{matrix.board}}]}" >> $GITHUB_ENV + echo "ARDUINO_CLI_ARGS=${args[${{matrix.board}}]}" >> $GITHUB_ENV + + - name: Compile example uses: ArminJo/arduino-test-compile@v3 with: arduino-board-fqbn: ${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}} arduino-platform: ${{env.ARDUINO_PLATFORM}} - platform-url: ${{ matrix.platform-url }} + platform-url: ${{env.ARDUINO_PLATFORM_URL}} + #platform-url: ${{ matrix.platform-url }} required-libraries: ArduinoJson #required-libraries: ${{ matrix.required-libraries }} - extra-arduino-cli-args: ${{ matrix.cli-args }} + extra-arduino-cli-args: ${{env.ARDUINO_CLI_ARGS}} + #extra-arduino-cli-args: ${{ matrix.cli-args }} #build-properties: ${{ toJson(matrix.build-properties) }} sketch-names: ${{ env.SKETCH_NAME }} #sketches-exclude: ${{ matrix.sketches-exclude }} From 3fa70daed981522c1b492b0989531fc1e5adff47 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 16:59:47 +0200 Subject: [PATCH 17/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index df98e33..0af6d2b 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -46,7 +46,7 @@ jobs: include: # multidimensional matrix doesn't apply to these profiles, so they are implicitely listed - - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, , ... } + - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, ... } - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: latest, ... } - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, ... } - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: latest, ... } From ca69ff9a7027cda91f0f01a9845ac3651e6ddfa5 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:01:55 +0200 Subject: [PATCH 18/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 0af6d2b..2be10f8 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -86,11 +86,11 @@ jobs: export ARDUINO_PLATFORM="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" echo "ARDUINO_PLATFORM=$ARDUINO_PLATFORM" >> $GITHUB_ENV - board[esp32]=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json - board[esp8266]=https://arduino.esp8266.com/stable/package_esp8266com_index.json - board[seeed]=https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json - board[rp2040]=https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - args[rp2040]=--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST + board[esp32]="https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json" + board[esp8266]="https://arduino.esp8266.com/stable/package_esp8266com_index.json" + board[seeed]="https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json" + board[rp2040]="https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json" + args[rp2040]="--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST" echo "ARDUINO_PLATFORM_URL=${board[${{matrix.board}}]}" >> $GITHUB_ENV echo "ARDUINO_CLI_ARGS=${args[${{matrix.board}}]}" >> $GITHUB_ENV From 635d44303fdc862c5ed9f780749f58dfea9ee047 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:05:02 +0200 Subject: [PATCH 19/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 2be10f8..303950a 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -92,8 +92,13 @@ jobs: board[rp2040]="https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json" args[rp2040]="--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST" - echo "ARDUINO_PLATFORM_URL=${board[${{matrix.board}}]}" >> $GITHUB_ENV - echo "ARDUINO_CLI_ARGS=${args[${{matrix.board}}]}" >> $GITHUB_ENV + boardname=${{matrix.board}} + + boardurl=${board[$boardname]} + boardargs=${args[$boardname]} + + echo "ARDUINO_PLATFORM_URL=$boardurl" >> $GITHUB_ENV + echo "ARDUINO_CLI_ARGS=$boardargs" >> $GITHUB_ENV - name: Compile example From 38ee9f898fd807fa99b17d2c086c964a1ec6a159 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:09:01 +0200 Subject: [PATCH 20/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 303950a..def770d 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -88,11 +88,11 @@ jobs: board[esp32]="https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json" board[esp8266]="https://arduino.esp8266.com/stable/package_esp8266com_index.json" - board[seeed]="https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json" + board[Seeeduino]="https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json" board[rp2040]="https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json" args[rp2040]="--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST" - boardname=${{matrix.board}} + boardname=${{matrix.platform}} boardurl=${board[$boardname]} boardargs=${args[$boardname]} From 263c66f1d8bea0fc0db88a1df7f42c3db8ba18ca Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:17:14 +0200 Subject: [PATCH 21/54] Arduino CI Tests --- .github/workflows/.ArduinoBuild.yml.kate-swp | Bin 0 -> 518 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflows/.ArduinoBuild.yml.kate-swp diff --git a/.github/workflows/.ArduinoBuild.yml.kate-swp b/.github/workflows/.ArduinoBuild.yml.kate-swp new file mode 100644 index 0000000000000000000000000000000000000000..2ea25ae9c34bddeccb27b1f243f286a39b2d2007 GIT binary patch literal 518 zcmZQzU=Z?7EJ;-eE>A2_aLdd|RWQ;sU|?Vnx%a)`mZ`wQgv+}+TUh4ZtUtD3lSyzm zP$mqBom_)GffR@f0$d7k;0jg)lHh`0P&H`69n-U5b{DGzAl0<4B|T?_#$ZPMM3-|guEDtpO4^+ zgZN19kpS_L+#?C%1N{pMACUj0AX+1VOb|c`M^G4nBtT&#kdm65lUS6hpzElRl%H4x kG$IHp4RVqcOfA@bQ2Rl8!R~|F58{K}myWO$?7m`G0O9*Z;s5{u literal 0 HcmV?d00001 From e449f40f5f089372f427609b938800241210aa95 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:18:04 +0200 Subject: [PATCH 22/54] Arduino CI Tests --- .github/workflows/.ArduinoBuild.yml.kate-swp | Bin 518 -> 0 bytes .github/workflows/ArduinoBuild.yml | 3 +++ 2 files changed, 3 insertions(+) delete mode 100644 .github/workflows/.ArduinoBuild.yml.kate-swp diff --git a/.github/workflows/.ArduinoBuild.yml.kate-swp b/.github/workflows/.ArduinoBuild.yml.kate-swp deleted file mode 100644 index 2ea25ae9c34bddeccb27b1f243f286a39b2d2007..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 518 zcmZQzU=Z?7EJ;-eE>A2_aLdd|RWQ;sU|?Vnx%a)`mZ`wQgv+}+TUh4ZtUtD3lSyzm zP$mqBom_)GffR@f0$d7k;0jg)lHh`0P&H`69n-U5b{DGzAl0<4B|T?_#$ZPMM3-|guEDtpO4^+ zgZN19kpS_L+#?C%1N{pMACUj0AX+1VOb|c`M^G4nBtT&#kdm65lUS6hpzElRl%H4x kG$IHp4RVqcOfA@bQ2Rl8!R~|F58{K}myWO$?7m`G0O9*Z;s5{u diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index def770d..28db0de 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -86,6 +86,9 @@ jobs: export ARDUINO_PLATFORM="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" echo "ARDUINO_PLATFORM=$ARDUINO_PLATFORM" >> $GITHUB_ENV + declare -A board + declare -A args + board[esp32]="https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json" board[esp8266]="https://arduino.esp8266.com/stable/package_esp8266com_index.json" board[Seeeduino]="https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json" From 3e1fe3ab2ca91d16d3ce0e8b5db300f5b65afab4 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:29:49 +0200 Subject: [PATCH 23/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 32 +++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 28db0de..e7f5757 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -16,16 +16,37 @@ on: jobs: + set_env: + name: "Set environment" + runs-on: ubuntu-latest + env: + esp32_board_url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json + esp8266_board_url: https://arduino.esp8266.com/stable/package_esp8266com_index.json + Seeeduino_board_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json + rp2040_board_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST" + + outputs: + env: ${{steps.set-env.outputs.env}} + steps: + # Avoid multiline: flatten JSON + - id: set-env + run: | + content='${{ toJson(env) }}' + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + echo "::set-output name=env::$content" + build: name: ${{matrix.board}}@${{matrix.platform-version}} runs-on: ubuntu-latest + needs: set_env + env: ${{fromJSON(needs.set_env.outputs.env)}} strategy: matrix: - #platform-url: - #- https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json - board: # ESP32 devices for multidimensional matrix - esp32 @@ -41,7 +62,6 @@ jobs: - 2.0.2 - 2.0.3 - 2.0.4 - - 2.0.5 - latest include: @@ -49,6 +69,8 @@ jobs: - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, ... } - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: latest, ... } - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, ... } + - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: latest, ... } + - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: 2.3.3, ... } - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: latest, ... } # multidimensional matrix applies to these: @@ -89,7 +111,7 @@ jobs: declare -A board declare -A args - board[esp32]="https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json" + board[esp32]=${{env.esp32_board_url}} board[esp8266]="https://arduino.esp8266.com/stable/package_esp8266com_index.json" board[Seeeduino]="https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json" board[rp2040]="https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json" From 095251f2721d8cb0a8a46d4a665feab55be7d727 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:33:05 +0200 Subject: [PATCH 24/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index e7f5757..aba817c 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -36,7 +36,7 @@ jobs: content="${content//'%'/'%25'}" content="${content//$'\n'/'%0A'}" content="${content//$'\r'/'%0D'}" - echo "::set-output name=env::$content" + echo "env=$content" >> $GITHUB_OUTPUT build: name: ${{matrix.board}}@${{matrix.platform-version}} @@ -112,10 +112,10 @@ jobs: declare -A args board[esp32]=${{env.esp32_board_url}} - board[esp8266]="https://arduino.esp8266.com/stable/package_esp8266com_index.json" - board[Seeeduino]="https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json" - board[rp2040]="https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json" - args[rp2040]="--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST" + board[esp8266]=${{env.esp8266_board_url}} + board[Seeeduino]=${{env.Seeeduino_board_url}} + board[rp2040]=${{env.rp2040_board_url}} + args[rp2040]="${{env.rp2040_cli_args}}" boardname=${{matrix.platform}} From c90a40490db5f9bd476de9c3932825d59b4a22eb Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:47:01 +0200 Subject: [PATCH 25/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 42 ++++++++++++++---------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index aba817c..ca1f42f 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -17,19 +17,19 @@ on: jobs: set_env: - name: "Set environment" + name: "Set matrix env vars" runs-on: ubuntu-latest env: esp32_board_url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json esp8266_board_url: https://arduino.esp8266.com/stable/package_esp8266com_index.json Seeeduino_board_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json rp2040_board_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST" + rp2040_cli_args: "--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST" outputs: env: ${{steps.set-env.outputs.env}} steps: - # Avoid multiline: flatten JSON + # export at output variables, flatten as JSON - id: set-env run: | content='${{ toJson(env) }}' @@ -65,7 +65,7 @@ jobs: - latest include: - # multidimensional matrix doesn't apply to these profiles, so they are implicitely listed + # multidimensional matrix doesn't apply to these profiles, so they are explicitely populated - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, ... } - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: latest, ... } - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, ... } @@ -80,7 +80,7 @@ jobs: - { board: esp32c3, platform: esp32, archi: esp32, ... } exclude: - # multidimensional matrix excludes these: + # multidimensional matrix excludes these (no support or unstable): - { board: esp32s2, platform-version: 1.0.6 } - { board: esp32s2, platform-version: 2.0.0 } @@ -103,27 +103,27 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - - name: FBQN Check + - name: Prepare variables for arduino-test-compile run: | - export ARDUINO_PLATFORM="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" - echo "ARDUINO_PLATFORM=$ARDUINO_PLATFORM" >> $GITHUB_ENV + declare -A board_urls + declare -A cli_args - declare -A board - declare -A args + board_urls[esp32]=${{env.esp32_board_url}} + board_urls[esp8266]=${{env.esp8266_board_url}} + board_urls[Seeeduino]=${{env.Seeeduino_board_url}} + board_urls[rp2040]=${{env.rp2040_board_url}} - board[esp32]=${{env.esp32_board_url}} - board[esp8266]=${{env.esp8266_board_url}} - board[Seeeduino]=${{env.Seeeduino_board_url}} - board[rp2040]=${{env.rp2040_board_url}} - args[rp2040]="${{env.rp2040_cli_args}}" + cli_args[rp2040]="${{env.rp2040_cli_args}}" - boardname=${{matrix.platform}} + board_name=${{matrix.platform}} - boardurl=${board[$boardname]} - boardargs=${args[$boardname]} + board_url=${board_urls[$board_name]} + board_args=${cli_args[$board_name]} + platform="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" - echo "ARDUINO_PLATFORM_URL=$boardurl" >> $GITHUB_ENV - echo "ARDUINO_CLI_ARGS=$boardargs" >> $GITHUB_ENV + echo "ARDUINO_PLATFORM=$platform" >> $GITHUB_ENV + echo "ARDUINO_PLATFORM_URL=$board_url" >> $GITHUB_ENV + echo "ARDUINO_CLI_ARGS=$board_args" >> $GITHUB_ENV - name: Compile example @@ -132,9 +132,7 @@ jobs: arduino-board-fqbn: ${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}} arduino-platform: ${{env.ARDUINO_PLATFORM}} platform-url: ${{env.ARDUINO_PLATFORM_URL}} - #platform-url: ${{ matrix.platform-url }} required-libraries: ArduinoJson - #required-libraries: ${{ matrix.required-libraries }} extra-arduino-cli-args: ${{env.ARDUINO_CLI_ARGS}} #extra-arduino-cli-args: ${{ matrix.cli-args }} #build-properties: ${{ toJson(matrix.build-properties) }} From 4c23c54380fb7cb2cec769592567c1e65d89312f Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:48:15 +0200 Subject: [PATCH 26/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index ca1f42f..a6a8050 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -24,7 +24,7 @@ jobs: esp8266_board_url: https://arduino.esp8266.com/stable/package_esp8266com_index.json Seeeduino_board_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json rp2040_board_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - rp2040_cli_args: "--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST" + rp2040_cli_args: "'--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST'" outputs: env: ${{steps.set-env.outputs.env}} From d8a3749c14a86265609b2c1c6bbc07c91661d5ec Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:49:27 +0200 Subject: [PATCH 27/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index a6a8050..7389d36 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -24,7 +24,7 @@ jobs: esp8266_board_url: https://arduino.esp8266.com/stable/package_esp8266com_index.json Seeeduino_board_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json rp2040_board_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - rp2040_cli_args: "'--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST'" + #rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST outputs: env: ${{steps.set-env.outputs.env}} From 1028c8fc1fb2d366ac07dbea5645b3e499abc8d4 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:51:49 +0200 Subject: [PATCH 28/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 7389d36..8496cf4 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -113,7 +113,7 @@ jobs: board_urls[Seeeduino]=${{env.Seeeduino_board_url}} board_urls[rp2040]=${{env.rp2040_board_url}} - cli_args[rp2040]="${{env.rp2040_cli_args}}" +# cli_args[rp2040]="${{env.rp2040_cli_args}}" board_name=${{matrix.platform}} From 257693c69bcf0eb3eb7316707236e1b229974ae7 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:52:29 +0200 Subject: [PATCH 29/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 8496cf4..5be8ad6 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -25,6 +25,7 @@ jobs: Seeeduino_board_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json rp2040_board_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json #rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST + rp2040_cli_args: outputs: env: ${{steps.set-env.outputs.env}} @@ -113,7 +114,7 @@ jobs: board_urls[Seeeduino]=${{env.Seeeduino_board_url}} board_urls[rp2040]=${{env.rp2040_board_url}} -# cli_args[rp2040]="${{env.rp2040_cli_args}}" + cli_args[rp2040]="${{env.rp2040_cli_args}}" board_name=${{matrix.platform}} From 3011107a6701b55fce3a40fd2dd028e8f1a92601 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:55:05 +0200 Subject: [PATCH 30/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 5be8ad6..71cac0a 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -37,7 +37,8 @@ jobs: content="${content//'%'/'%25'}" content="${content//$'\n'/'%0A'}" content="${content//$'\r'/'%0D'}" - echo "env=$content" >> $GITHUB_OUTPUT + # echo "env=${content}" >> $GITHUB_OUTPUT + echo "::set-output name=env::${content}" build: name: ${{matrix.board}}@${{matrix.platform-version}} From 0cb993c03ef2e9d7f3719025fde4e0a63f112b9e Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 17:57:29 +0200 Subject: [PATCH 31/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 71cac0a..b147d59 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -24,8 +24,8 @@ jobs: esp8266_board_url: https://arduino.esp8266.com/stable/package_esp8266com_index.json Seeeduino_board_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json rp2040_board_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - #rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST - rp2040_cli_args: + rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST + #rp2040_cli_args: outputs: env: ${{steps.set-env.outputs.env}} From cfdde22ad50a598aa1f8a7fc266dcbe3ac6f8cdc Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:00:30 +0200 Subject: [PATCH 32/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index b147d59..d3b55b9 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -24,8 +24,8 @@ jobs: esp8266_board_url: https://arduino.esp8266.com/stable/package_esp8266com_index.json Seeeduino_board_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json rp2040_board_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST - #rp2040_cli_args: + #rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST + rp2040_cli_args: outputs: env: ${{steps.set-env.outputs.env}} @@ -37,8 +37,8 @@ jobs: content="${content//'%'/'%25'}" content="${content//$'\n'/'%0A'}" content="${content//$'\r'/'%0D'}" - # echo "env=${content}" >> $GITHUB_OUTPUT - echo "::set-output name=env::${content}" + echo "env=${content}" >> $GITHUB_OUTPUT + # echo "::set-output name=env::${content}" build: name: ${{matrix.board}}@${{matrix.platform-version}} From 59c66cb9bc15e1d996fd8502b163abc739673798 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:01:45 +0200 Subject: [PATCH 33/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index d3b55b9..98cd8a0 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -37,7 +37,7 @@ jobs: content="${content//'%'/'%25'}" content="${content//$'\n'/'%0A'}" content="${content//$'\r'/'%0D'}" - echo "env=${content}" >> $GITHUB_OUTPUT + echo "env=\"${content}\"" >> $GITHUB_OUTPUT # echo "::set-output name=env::${content}" build: From 35a91396d1f08b37508b7f60f92ebe3c41b3c5bf Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:03:21 +0200 Subject: [PATCH 34/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 98cd8a0..2e254a9 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -34,10 +34,10 @@ jobs: - id: set-env run: | content='${{ toJson(env) }}' - content="${content//'%'/'%25'}" - content="${content//$'\n'/'%0A'}" - content="${content//$'\r'/'%0D'}" - echo "env=\"${content}\"" >> $GITHUB_OUTPUT + # content="${content//'%'/'%25'}" + # content="${content//$'\n'/'%0A'}" + # content="${content//$'\r'/'%0D'}" + echo "env=$content" >> $GITHUB_OUTPUT # echo "::set-output name=env::${content}" build: From 10015d94e1a1f2525dd2550fdbb81c08d0ca50fa Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:11:54 +0200 Subject: [PATCH 35/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 2e254a9..25678b6 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -34,10 +34,11 @@ jobs: - id: set-env run: | content='${{ toJson(env) }}' - # content="${content//'%'/'%25'}" - # content="${content//$'\n'/'%0A'}" - # content="${content//$'\r'/'%0D'}" - echo "env=$content" >> $GITHUB_OUTPUT + echo $content + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + echo "env=\"${content}\"" >> $GITHUB_OUTPUT # echo "::set-output name=env::${content}" build: From b2933623c5ff1f190614df33eb04191a80ce9fa9 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:13:22 +0200 Subject: [PATCH 36/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 25678b6..bdd772c 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -38,7 +38,7 @@ jobs: content="${content//'%'/'%25'}" content="${content//$'\n'/'%0A'}" content="${content//$'\r'/'%0D'}" - echo "env=\"${content}\"" >> $GITHUB_OUTPUT + echo "env='${content}'" >> $GITHUB_OUTPUT # echo "::set-output name=env::${content}" build: From 66d582c61f8254dc104a670a0e08a3fee230cb6c Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:17:07 +0200 Subject: [PATCH 37/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index bdd772c..0051f45 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -36,8 +36,8 @@ jobs: content='${{ toJson(env) }}' echo $content content="${content//'%'/'%25'}" - content="${content//$'\n'/'%0A'}" - content="${content//$'\r'/'%0D'}" + content="${content//$'\n'/''}" + content="${content//$'\r'/''}" echo "env='${content}'" >> $GITHUB_OUTPUT # echo "::set-output name=env::${content}" @@ -122,7 +122,8 @@ jobs: board_url=${board_urls[$board_name]} board_args=${cli_args[$board_name]} - platform="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" + #platform="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" + platform=${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} echo "ARDUINO_PLATFORM=$platform" >> $GITHUB_ENV echo "ARDUINO_PLATFORM_URL=$board_url" >> $GITHUB_ENV @@ -130,7 +131,7 @@ jobs: - name: Compile example - uses: ArminJo/arduino-test-compile@v3 + uses: ArminJo/arduino-test-compile@master with: arduino-board-fqbn: ${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}} arduino-platform: ${{env.ARDUINO_PLATFORM}} From f9e889ba699da6e22359f23883912e0108b46219 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:17:57 +0200 Subject: [PATCH 38/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 0051f45..5716924 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -38,7 +38,7 @@ jobs: content="${content//'%'/'%25'}" content="${content//$'\n'/''}" content="${content//$'\r'/''}" - echo "env='${content}'" >> $GITHUB_OUTPUT + echo "env=${content}" >> $GITHUB_OUTPUT # echo "::set-output name=env::${content}" build: From 61458f81ae34399435fb734fba9d0c1fcf40663d Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:19:18 +0200 Subject: [PATCH 39/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 5716924..842b6ca 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -25,7 +25,7 @@ jobs: Seeeduino_board_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json rp2040_board_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json #rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST - rp2040_cli_args: + rp2040_cli_args: blah outputs: env: ${{steps.set-env.outputs.env}} @@ -36,8 +36,8 @@ jobs: content='${{ toJson(env) }}' echo $content content="${content//'%'/'%25'}" - content="${content//$'\n'/''}" - content="${content//$'\r'/''}" + content="${content//$'\n'/' '}" + content="${content//$'\r'/' '}" echo "env=${content}" >> $GITHUB_OUTPUT # echo "::set-output name=env::${content}" From 70e07bc99edd84d3bb73d312d7b25166e6024f12 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:21:02 +0200 Subject: [PATCH 40/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 842b6ca..0d92d68 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -122,7 +122,7 @@ jobs: board_url=${board_urls[$board_name]} board_args=${cli_args[$board_name]} - #platform="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" + platform=${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} echo "ARDUINO_PLATFORM=$platform" >> $GITHUB_ENV From e1354a2bdb4ce442b69d9f5cd3cf56f2b1ea0b1a Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:23:11 +0200 Subject: [PATCH 41/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 0d92d68..255fbd9 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -122,8 +122,8 @@ jobs: board_url=${board_urls[$board_name]} board_args=${cli_args[$board_name]} - - platform=${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} + #platform="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" + platform=${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} echo "ARDUINO_PLATFORM=$platform" >> $GITHUB_ENV echo "ARDUINO_PLATFORM_URL=$board_url" >> $GITHUB_ENV From 531efd046d0556da108ba5a0662973adacc1dff1 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:26:04 +0200 Subject: [PATCH 42/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 255fbd9..f08e618 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -24,8 +24,7 @@ jobs: esp8266_board_url: https://arduino.esp8266.com/stable/package_esp8266com_index.json Seeeduino_board_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json rp2040_board_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - #rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST - rp2040_cli_args: blah + rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST outputs: env: ${{steps.set-env.outputs.env}} From 681ca9dd185aec31aa7f767dcab63b721f668998 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 18:52:24 +0200 Subject: [PATCH 43/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index f08e618..2e4fdc2 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -35,8 +35,8 @@ jobs: content='${{ toJson(env) }}' echo $content content="${content//'%'/'%25'}" - content="${content//$'\n'/' '}" - content="${content//$'\r'/' '}" + content="${content//$'\n'/''}" + content="${content//$'\r'/''}" echo "env=${content}" >> $GITHUB_OUTPUT # echo "::set-output name=env::${content}" From eab469aea26671a78cdccc7b9713d413c4bad526 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 19:01:07 +0200 Subject: [PATCH 44/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 2e4fdc2..33ded99 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -24,7 +24,8 @@ jobs: esp8266_board_url: https://arduino.esp8266.com/stable/package_esp8266com_index.json Seeeduino_board_url: https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json rp2040_board_url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json - rp2040_cli_args: --build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST + rp2040_cli_args: "--build-property compiler.cpp.extra_flags=-DSKIP_I2C_TEST" + d1_mini_fbqn_extra: ":eesz=4M3M,xtal=80" outputs: env: ${{steps.set-env.outputs.env}} @@ -68,8 +69,8 @@ jobs: include: # multidimensional matrix doesn't apply to these profiles, so they are explicitely populated - - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: 3.0.1, ... } - - { board: 'd1_mini:eesz=4M3M,xtal=80', platform: esp8266, archi: esp8266, platform-version: latest, ... } + - { board: d1_mini, platform: esp8266, archi: esp8266, platform-version: 3.0.1, ... } + - { board: d1_mini, platform: esp8266, archi: esp8266, platform-version: latest, ... } - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, ... } - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: latest, ... } - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: 2.3.3, ... } @@ -109,6 +110,7 @@ jobs: run: | declare -A board_urls declare -A cli_args + declare -A fbqn_extras board_urls[esp32]=${{env.esp32_board_url}} board_urls[esp8266]=${{env.esp8266_board_url}} @@ -117,22 +119,28 @@ jobs: cli_args[rp2040]="${{env.rp2040_cli_args}}" + fbqn_extras[d1_mini]=${{env.d1_mini_fbqn_extra}} + board_name=${{matrix.platform}} board_url=${board_urls[$board_name]} board_args=${cli_args[$board_name]} - #platform="${${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}}/@latest/""}" + fqbn_extra=${fbqn_extras[$board_name]} + platform=${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} + fbqn=${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}}${fqbn_extra} echo "ARDUINO_PLATFORM=$platform" >> $GITHUB_ENV echo "ARDUINO_PLATFORM_URL=$board_url" >> $GITHUB_ENV echo "ARDUINO_CLI_ARGS=$board_args" >> $GITHUB_ENV + echo "ARDUINO_BOARD_FQBN=$fbqn" >> $GITHUB_ENV - name: Compile example uses: ArminJo/arduino-test-compile@master with: - arduino-board-fqbn: ${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}} + #arduino-board-fqbn: ${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}} + arduino-board-fqbn: ${{env.ARDUINO_BOARD_FQBN}} arduino-platform: ${{env.ARDUINO_PLATFORM}} platform-url: ${{env.ARDUINO_PLATFORM_URL}} required-libraries: ArduinoJson From 2d85898783e5344ac617c7f62c24712e4f3555a9 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 19:05:42 +0200 Subject: [PATCH 45/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 33ded99..2f820b5 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -119,7 +119,7 @@ jobs: cli_args[rp2040]="${{env.rp2040_cli_args}}" - fbqn_extras[d1_mini]=${{env.d1_mini_fbqn_extra}} + fbqn_extras[d1_mini]="${{env.d1_mini_fbqn_extra}}" board_name=${{matrix.platform}} @@ -128,7 +128,7 @@ jobs: fqbn_extra=${fbqn_extras[$board_name]} platform=${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} - fbqn=${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}}${fqbn_extra} + fbqn="${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}}$fqbn_extra" echo "ARDUINO_PLATFORM=$platform" >> $GITHUB_ENV echo "ARDUINO_PLATFORM_URL=$board_url" >> $GITHUB_ENV From 34db83dd945dc02c96862103c963c1968d8a4a0e Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 19:10:51 +0200 Subject: [PATCH 46/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 2f820b5..35095d8 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -121,14 +121,15 @@ jobs: fbqn_extras[d1_mini]="${{env.d1_mini_fbqn_extra}}" - board_name=${{matrix.platform}} + platform_name=${{matrix.platform}} + board_name=${{matrix.board}} - board_url=${board_urls[$board_name]} - board_args=${cli_args[$board_name]} + board_url=${board_urls[$platform_name]} + board_args=${cli_args[$platform_name]} fqbn_extra=${fbqn_extras[$board_name]} platform=${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} - fbqn="${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}}$fqbn_extra" + fbqn=${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}}${fqbn_extra} echo "ARDUINO_PLATFORM=$platform" >> $GITHUB_ENV echo "ARDUINO_PLATFORM_URL=$board_url" >> $GITHUB_ENV From a1815998e7ab1a192c3232787cdaa843ef00d667 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 19:25:36 +0200 Subject: [PATCH 47/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 31 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index 35095d8..bd424c4 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -48,6 +48,7 @@ jobs: env: ${{fromJSON(needs.set_env.outputs.env)}} strategy: + fail-fast: false matrix: board: @@ -98,7 +99,7 @@ jobs: - { board: esp32c3, platform-version: 2.0.0 } - fail-fast: false + steps: - name: Checkout @@ -108,33 +109,38 @@ jobs: - name: Prepare variables for arduino-test-compile run: | + # prepare some associative arrays to receive matrix-specific env vars declare -A board_urls declare -A cli_args declare -A fbqn_extras + # assign package URLs (per platform) board_urls[esp32]=${{env.esp32_board_url}} board_urls[esp8266]=${{env.esp8266_board_url}} board_urls[Seeeduino]=${{env.Seeeduino_board_url}} board_urls[rp2040]=${{env.rp2040_board_url}} + # assign optional cli args (per platform) cli_args[rp2040]="${{env.rp2040_cli_args}}" + # assign optional extra FQBN info (per board) fbqn_extras[d1_mini]="${{env.d1_mini_fbqn_extra}}" - platform_name=${{matrix.platform}} + # collect the index names that will be used to populate the associative array board_name=${{matrix.board}} + platform_name=${{matrix.platform}} - board_url=${board_urls[$platform_name]} - board_args=${cli_args[$platform_name]} - fqbn_extra=${fbqn_extras[$board_name]} - - platform=${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} - fbqn=${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}}${fqbn_extra} + # populate values for the next step + arduino_platform_url=${board_urls[$platform_name]} + arduino_cli_args=${cli_args[$platform_name]} + arduino_board_fqbn=${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}}${fbqn_extras[$board_name]} + arduino_platform=${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} - echo "ARDUINO_PLATFORM=$platform" >> $GITHUB_ENV - echo "ARDUINO_PLATFORM_URL=$board_url" >> $GITHUB_ENV - echo "ARDUINO_CLI_ARGS=$board_args" >> $GITHUB_ENV - echo "ARDUINO_BOARD_FQBN=$fbqn" >> $GITHUB_ENV + # export to env + echo "ARDUINO_PLATFORM=$arduino_platform" >> $GITHUB_ENV + echo "ARDUINO_PLATFORM_URL=$arduino_platform_url" >> $GITHUB_ENV + echo "ARDUINO_CLI_ARGS=$arduino_cli_args" >> $GITHUB_ENV + echo "ARDUINO_BOARD_FQBN=$arduino_board_fqbn" >> $GITHUB_ENV - name: Compile example @@ -146,7 +152,6 @@ jobs: platform-url: ${{env.ARDUINO_PLATFORM_URL}} required-libraries: ArduinoJson extra-arduino-cli-args: ${{env.ARDUINO_CLI_ARGS}} - #extra-arduino-cli-args: ${{ matrix.cli-args }} #build-properties: ${{ toJson(matrix.build-properties) }} sketch-names: ${{ env.SKETCH_NAME }} #sketches-exclude: ${{ matrix.sketches-exclude }} From 9f0988b3f148049f1d3a5aa05bdf94f3e544749c Mon Sep 17 00:00:00 2001 From: tobozo Date: Sun, 23 Oct 2022 19:37:43 +0200 Subject: [PATCH 48/54] Arduino CI Tests --- .github/workflows/ArduinoBuild.yml | 42 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ArduinoBuild.yml b/.github/workflows/ArduinoBuild.yml index bd424c4..f55bb34 100644 --- a/.github/workflows/ArduinoBuild.yml +++ b/.github/workflows/ArduinoBuild.yml @@ -33,13 +33,11 @@ jobs: # export at output variables, flatten as JSON - id: set-env run: | - content='${{ toJson(env) }}' - echo $content - content="${content//'%'/'%25'}" - content="${content//$'\n'/''}" - content="${content//$'\r'/''}" + content='${{ toJson(env) }}' # convert env vars to json + content="${content//'%'/'%25'}" # escape percent entities + content="${content//$'\n'/''}" # remove lf + content="${content//$'\r'/''}" # remove cr echo "env=${content}" >> $GITHUB_OUTPUT - # echo "::set-output name=env::${content}" build: name: ${{matrix.board}}@${{matrix.platform-version}} @@ -70,21 +68,24 @@ jobs: include: # multidimensional matrix doesn't apply to these profiles, so they are explicitely populated - - { board: d1_mini, platform: esp8266, archi: esp8266, platform-version: 3.0.1, ... } - - { board: d1_mini, platform: esp8266, archi: esp8266, platform-version: latest, ... } - - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: 1.8.2, ... } - - { board: seeed_wio_terminal, platform: Seeeduino, archi: samd, platform-version: latest, ... } - - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: 2.3.3, ... } - - { board: rpipico, platform: rp2040, archi: rp2040, platform-version: latest, ... } + + - { board: d1_mini, platform: esp8266, arch: esp8266, platform-version: 3.0.1, ... } + - { board: d1_mini, platform: esp8266, arch: esp8266, platform-version: latest, ... } + + - { board: seeed_wio_terminal, platform: Seeeduino, arch: samd, platform-version: 1.8.2, ... } + - { board: seeed_wio_terminal, platform: Seeeduino, arch: samd, platform-version: latest, ... } + + - { board: rpipico, platform: rp2040, arch: rp2040, platform-version: 2.3.3, ... } + - { board: rpipico, platform: rp2040, arch: rp2040, platform-version: latest, ... } # multidimensional matrix applies to these: - - { board: esp32, platform: esp32, archi: esp32, ... } - - { board: esp32s2, platform: esp32, archi: esp32, ... } - - { board: esp32s3, platform: esp32, archi: esp32, ... } - - { board: esp32c3, platform: esp32, archi: esp32, ... } + - { board: esp32, platform: esp32, arch: esp32, ... } + - { board: esp32s2, platform: esp32, arch: esp32, ... } + - { board: esp32s3, platform: esp32, arch: esp32, ... } + - { board: esp32c3, platform: esp32, arch: esp32, ... } exclude: - # multidimensional matrix excludes these (no support or unstable): + # multidimensional matrix excludes (no support or unstable): - { board: esp32s2, platform-version: 1.0.6 } - { board: esp32s2, platform-version: 2.0.0 } @@ -103,7 +104,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} @@ -133,8 +134,8 @@ jobs: # populate values for the next step arduino_platform_url=${board_urls[$platform_name]} arduino_cli_args=${cli_args[$platform_name]} - arduino_board_fqbn=${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}}${fbqn_extras[$board_name]} - arduino_platform=${{matrix.platform}}:${{matrix.archi}}@${{matrix.platform-version}} + arduino_board_fqbn=${{matrix.platform}}:${{matrix.arch}}:${{matrix.board}}${fbqn_extras[$board_name]} + arduino_platform=${{matrix.platform}}:${{matrix.arch}}@${{matrix.platform-version}} # export to env echo "ARDUINO_PLATFORM=$arduino_platform" >> $GITHUB_ENV @@ -146,7 +147,6 @@ jobs: - name: Compile example uses: ArminJo/arduino-test-compile@master with: - #arduino-board-fqbn: ${{matrix.platform}}:${{matrix.archi}}:${{matrix.board}} arduino-board-fqbn: ${{env.ARDUINO_BOARD_FQBN}} arduino-platform: ${{env.ARDUINO_PLATFORM}} platform-url: ${{env.ARDUINO_PLATFORM_URL}} From 53a62b089eb8ebf2fb6be1b1da58389bcdfee001 Mon Sep 17 00:00:00 2001 From: tobozo Date: Wed, 26 Oct 2022 11:24:43 +0200 Subject: [PATCH 49/54] bump version --- .github/workflows/lint.yml | 2 +- examples/test/platformio.ini | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4f06033..25c5471 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,7 +22,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: arduino/arduino-lint-action@v1 with: project-type: library diff --git a/examples/test/platformio.ini b/examples/test/platformio.ini index fbba8e6..c0327e7 100644 --- a/examples/test/platformio.ini +++ b/examples/test/platformio.ini @@ -8,7 +8,8 @@ src_dir = src framework = arduino lib_deps = bblanchon/ArduinoJson @ ^6 - tobozo/YAMLDuino @ ^1.2 +; tobozo/YAMLDuino @ ^1.2 + YAMLDuino lib_ldf_mode = deep @@ -18,3 +19,13 @@ platform = espressif32 ; or alternate platform/package: ;platform = https://github.com/tasmota/platform-espressif32 ;platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32/releases/download/2.0.5/esp32-2.0.5.zip + + +[env:rp2040_pico] +platform = https://github.com/maxgerhardt/platform-raspberrypi.git +platform_packages = framework-arduinopico @ https://github.com/earlephilhower/arduino-pico/releases/download/2.6.1/rp2040-2.6.1.zip +board = generic +framework = arduino +board_build.filesystem_size = 0.5m ; adjust if needed +board_upload.maximum_size = 16777216 +board_build.arduino.earlephilhower.boot2_source = boot2_w25q080_4_padded_checksum.S From 1cc259c6d2506d925a5dbf080e7263df6fe75355 Mon Sep 17 00:00:00 2001 From: tobozo Date: Wed, 26 Oct 2022 11:25:27 +0200 Subject: [PATCH 50/54] enabled experimental support for atmega --- src/ArduinoYaml.hpp | 4 ++-- src/logger.hpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ArduinoYaml.hpp b/src/ArduinoYaml.hpp index de5bb08..c64eeef 100644 --- a/src/ArduinoYaml.hpp +++ b/src/ArduinoYaml.hpp @@ -42,7 +42,7 @@ extern "C" { #if !defined YAML_DISABLE_ARDUINOJSON - #if defined ARDUINO_ARCH_SAMD || defined ARDUINO_ARCH_RP2040 || defined ESP8266 + #if defined ARDUINO_ARCH_SAMD || defined ARDUINO_ARCH_RP2040 || defined ESP8266 || defined ARDUINO_ARCH_AVR // those platforms don't have built-in cJSON and __has_include() macro is limited to // the sketch folder, so assume ArduinoJson is in use #include @@ -230,7 +230,7 @@ size_t serializeYml( Stream &json_src_stream, Stream &yml_dest_stream, OutputFor template DeserializationError deserializeYml( JsonObject &dest_obj, T &src) { - static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "src must be const char* or Stream*"); + //static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "src must be const char* or Stream*"); YAMLToArduinoJson *parser = new YAMLToArduinoJson(); JsonObject _dest_obj = parser->toJson( src ); // decode yaml stream/string dest_obj = _dest_obj[ROOT_NODE]; diff --git a/src/logger.hpp b/src/logger.hpp index 2600749..db6f931 100644 --- a/src/logger.hpp +++ b/src/logger.hpp @@ -95,7 +95,7 @@ #define YAML_PATHNAME _pathToFileName static const char * _pathToFileName(const char * path) { - size_t i = 0, pos = 0; + int i = 0, pos = 0; char * p = (char *)path; while(*p){ i++; @@ -106,6 +106,8 @@ } return path+pos; } + #include + #include #endif #if !defined LOG_PRINTF From 17731d8e8736ce0eeda3ec0d8b81467202b79fa0 Mon Sep 17 00:00:00 2001 From: tobozo Date: Wed, 26 Oct 2022 11:36:54 +0200 Subject: [PATCH 51/54] enabled experimental support for atmega --- examples/test/src/test.cpp | 12 ++++++++---- src/ArduinoYaml.hpp | 15 +++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/examples/test/src/test.cpp b/examples/test/src/test.cpp index 66cbbcf..6a7949c 100644 --- a/examples/test/src/test.cpp +++ b/examples/test/src/test.cpp @@ -456,12 +456,16 @@ void setup() #pragma message "Enabling ArduinoJson tests" Serial.println("\n"); YAML_LOG_n("### YAML=>JSON and JSON=>YAML using ArduinoJson\n"); - test_deserializeYml_JsonObject_YamlString(); + #if !defined ARDUINO_ARCH_AVR + test_deserializeYml_JsonDocument_YamlStream(); + test_deserializeYml_JsonDocument_YamlString(); + test_deserializeYml_JsonObject_YamlString(); + test_serializeYml_JsonObject_YamlString(); + #endif test_deserializeYml_JsonObject_YamlStream(); - test_deserializeYml_JsonDocument_YamlStream(); - test_deserializeYml_JsonDocument_YamlString(); test_serializeYml_JsonObject_YamlStream(); - test_serializeYml_JsonObject_YamlString(); + + YAML_LOG_n("### ArduinoJson tests complete\n"); #endif diff --git a/src/ArduinoYaml.hpp b/src/ArduinoYaml.hpp index c64eeef..0909e96 100644 --- a/src/ArduinoYaml.hpp +++ b/src/ArduinoYaml.hpp @@ -36,17 +36,23 @@ extern "C" { #include "libyaml/yaml.h" // https://github.com/yaml/libyaml } -#if !defined YAML_DISABLE_CJSON // define this from sketch if cJSON isn't needed - #define HAS_CJSON // built-in (esp32) or bundled +//#define YAML_DISABLE_ARDUINOJSON + +#if defined ARDUINO_ARCH_SAMD || defined ARDUINO_ARCH_RP2040 || defined ESP8266 || defined ARDUINO_ARCH_AVR + #include + #include +#endif + +#if !defined YAML_DISABLE_CJSON && !defined ARDUINO_ARCH_AVR // define this from sketch if cJSON isn't needed + #define HAS_CJSON // built-in (esp32) or bundled, except for AVR #endif + #if !defined YAML_DISABLE_ARDUINOJSON #if defined ARDUINO_ARCH_SAMD || defined ARDUINO_ARCH_RP2040 || defined ESP8266 || defined ARDUINO_ARCH_AVR // those platforms don't have built-in cJSON and __has_include() macro is limited to // the sketch folder, so assume ArduinoJson is in use - #include - #include #include #define HAS_ARDUINOJSON #endif @@ -58,6 +64,7 @@ extern "C" { #endif + #define YAML_SCALAR_SPACE " " // YAML is indented with spaces (2 or more), not tabs #define JSON_SCALAR_TAB "\t" // JSON is indented with one tab as a default, this can be changed later #define JSON_FOLDING_DEPTH 4 // lame fact: folds on objects, not on arrays From c3fac660ee253be036b0e6ef811173c492df225a Mon Sep 17 00:00:00 2001 From: tobozo Date: Wed, 26 Oct 2022 20:02:11 +0200 Subject: [PATCH 52/54] updated examples --- examples/deserializeYml/deserializeYml.ino | 130 ++++++++++++++++++++ examples/serializeYml/serializeYml.ino | 133 +++++++++++++++++++++ examples/test/src/test.cpp | 4 +- 3 files changed, 265 insertions(+), 2 deletions(-) create mode 100644 examples/deserializeYml/deserializeYml.ino create mode 100644 examples/serializeYml/serializeYml.ino diff --git a/examples/deserializeYml/deserializeYml.ino b/examples/deserializeYml/deserializeYml.ino new file mode 100644 index 0000000..606af68 --- /dev/null +++ b/examples/deserializeYml/deserializeYml.ino @@ -0,0 +1,130 @@ +#pragma GCC diagnostic ignored "-Wunused-variable" + +#include +#include + +const char* yaml_sample_str = R"_YAML_STRING_( +first: true +blah: + nope: ["n","o","p","e"] +integer: 12345 +float: 12.3323 +last: true + +)_YAML_STRING_"; + +// exact JSON representation of yaml_sample_str +const char* json_sample_str = R"_JSON_STRING_( +{ + "first": true, + "blah": { "nope": [ "n", "o", "p", "e" ] }, + "integer": 12345, + "float": 12.3323, + "last": true +} + +)_JSON_STRING_"; + + +const size_t yaml_str_size = strlen(yaml_sample_str); +const size_t json_str_size = strlen(json_sample_str); +int test_number = 1; + + +// uncomment/comment as needed + +#define TEST_YAML_Stream_To_ArduinoJsonObject +#define TEST_YAML_String_To_ArduinoJsonObject +#define TEST_YAML_Stream_To_ArduinoJsonDocument +#define TEST_YAML_String_To_ArduinoJsonDocument + + + +void test_deserializeYml_JsonObject_YamlStream() +{ + #if defined TEST_YAML_Stream_To_ArduinoJsonObject + String yaml_str = String( yaml_sample_str ); + StringStream yaml_stream( yaml_str ); + StaticJsonDocument<128> json_doc; + JsonObject json_obj = json_doc.to(); + auto err = deserializeYml( json_obj, yaml_stream ); // deserialize yaml stream to JsonObject + if( err ) { + Serial.printf("Unable to deserialize demo YAML to JsonObject: %s", err.c_str() ); + return; + } + const size_t bytes_out = serializeJsonPretty( json_obj, Serial ); // print deserialized JsonObject + #endif +} + + +void test_deserializeYml_JsonObject_YamlString() +{ + #if defined TEST_YAML_String_To_ArduinoJsonObject + StaticJsonDocument<128> json_doc; + JsonObject json_obj = json_doc.to(); + auto err = deserializeYml( json_obj, yaml_sample_str ); // deserialize yaml string to JsonObject + if( err ) { + Serial.printf("Unable to deserialize demo YAML to JsonObject: %s", err.c_str() ); + return; + } + const size_t bytes_out = serializeJsonPretty( json_obj, Serial ); // print deserialized JsonObject + #endif +} + + +void test_deserializeYml_JsonDocument_YamlStream() +{ + #if defined TEST_YAML_Stream_To_ArduinoJsonDocument + StaticJsonDocument<128> json_doc; + String yaml_str = String( yaml_sample_str ); + StringStream yaml_stream( yaml_str ); + auto err = deserializeYml( json_doc, yaml_stream ); // deserialize yaml stream to JsonDocument + if( err ) { + Serial.printf("Unable to deserialize demo YAML to JsonObject: %s", err.c_str() ); + return; + } + const size_t bytes_out = serializeJsonPretty( json_doc, Serial ); // print deserialized JsonObject + #endif +} + + +void test_deserializeYml_JsonDocument_YamlString() +{ + #if defined TEST_YAML_String_To_ArduinoJsonDocument + String yaml_str( yaml_sample_str ); + StaticJsonDocument<128> json_doc; + auto err = deserializeYml( json_doc, yaml_str.c_str() ); // deserialize yaml string to JsonDocument + if( err ) { + Serial.printf("Unable to deserialize demo YAML to JsonObject: %s", err.c_str() ); + return; + } + JsonObject json_obj = json_doc.as(); + const size_t bytes_out = serializeJsonPretty( json_obj, Serial ); // print deserialized JsonObject + #endif +} + + + +void setup() +{ + Serial.begin(115200); + delay(5000); + Serial.printf("Welcome to the YAML Test sketch\nRam free: %d bytes", HEAP_AVAILABLE() ); + + // YAML::setLogLevel( YAML::LogLevelDebug ); // override sketch debug level (otherwise inherited) + // YAML::setJSONIndent(" ", 8 ); // JSON -> two spaces per indent level, unfold objets up to 8 nesting levels + // YAML::setYAMLIndent( 3 ); // annoy your friends with 3 spaces indentation + + test_deserializeYml_JsonDocument_YamlStream(); + test_deserializeYml_JsonDocument_YamlString(); + test_deserializeYml_JsonObject_YamlString(); + test_deserializeYml_JsonObject_YamlStream(); + +} + + +void loop() +{ + +} + diff --git a/examples/serializeYml/serializeYml.ino b/examples/serializeYml/serializeYml.ino new file mode 100644 index 0000000..d4bf697 --- /dev/null +++ b/examples/serializeYml/serializeYml.ino @@ -0,0 +1,133 @@ +#include +//#define YAML_DISABLE_ARDUINOJSON +#include + +const char* yaml_sample_str = R"_YAML_STRING_( +first: true +blah: + nope: ["n","o","p","e"] +integer: 12345 +float: 12.3323 +last: true + +)_YAML_STRING_"; + +// exact JSON representation of yaml_sample_str +const char* json_sample_str = R"_JSON_STRING_( +{ + "first": true, + "blah": { "nope": [ "n", "o", "p", "e" ] }, + "integer": 12345, + "float": 12.3323, + "last": true +} + +)_JSON_STRING_"; + + +const size_t yaml_str_size = strlen(yaml_sample_str); +const size_t json_str_size = strlen(json_sample_str); + + +int test_number = 1; + + +// uncomment/comment as needed + +#define TEST_YAML_TO_JSON +#define TEST_YAML_TO_JSON_PRETTY +#define TEST_JSON_TO_YAML +#define TEST_ArduinoJsonObject_TO_YAML_Stream +#define TEST_ArduinoJsonObject_TO_YAML_String + + +void test_Yaml2JsonPretty() +{ + #if defined TEST_YAML_TO_JSON + String yaml_str = String( yaml_sample_str ); + StringStream yaml_stream( yaml_str ); + serializeYml( yaml_stream, Serial, YAMLParser::OUTPUT_JSON_PRETTY ); + #endif +} + +void test_Yaml2Json() +{ + #if defined TEST_YAML_TO_JSON_PRETTY + String yaml_str = String( yaml_sample_str ); + StringStream yaml_stream( yaml_str ); + serializeYml( yaml_stream, Serial, YAMLParser::OUTPUT_JSON ); + #endif +} + + +void test_Json2Yaml() +{ + #if defined TEST_JSON_TO_YAML + String yaml_str = String( yaml_sample_str ); + StringStream yaml_stream( yaml_str ); + serializeYml( yaml_stream, Serial, YAMLParser::OUTPUT_YAML ); + #endif +} + + +void test_serializeYml_JsonObject_YamlStream() +{ + #if defined TEST_ArduinoJsonObject_TO_YAML_Stream + // Convert JsonObject to yaml + String json_str = String( json_sample_str ); + DynamicJsonDocument doc(128); // create and populate a JsonObject + auto err = deserializeJson( doc, json_str.c_str() ); + if( err ) { + Serial.printf("Unable to deserialize demo JSON to JsonObject: %s", err.c_str() ); + return; + } + JsonObject json_obj = doc.as(); + const size_t bytes_out = serializeYml( json_obj, Serial ); + #endif +} + + +void test_serializeYml_JsonObject_YamlString() +{ + #if defined TEST_ArduinoJsonObject_TO_YAML_String + // Convert JsonObject to yaml + String str_yaml_out = ""; // YAML output string + String json_str = String( json_sample_str ); + DynamicJsonDocument doc(128); // create and populate a JsonObject + auto err = deserializeJson( doc, json_str.c_str() ); + if( err ) { + Serial.printf("Unable to deserialize demo JSON to JsonObject: %s", err.c_str() ); + return; + } + JsonObject json_obj = doc.as(); + const size_t bytes_out = serializeYml( json_obj, str_yaml_out ); + Serial.println( str_yaml_out ); + #endif +} + + + + +void setup() +{ + Serial.begin(115200); + delay(5000); + Serial.printf("Welcome to the YAML Test sketch\nRam free: %d bytes", HEAP_AVAILABLE() ); + + // YAML::setLogLevel( YAML::LogLevelDebug ); // override sketch debug level (otherwise inherited) + // YAML::setJSONIndent(" ", 8 ); // JSON -> two spaces per indent level, unfold objets up to 8 nesting levels + // YAML::setYAMLIndent( 3 ); // annoy your friends with 3 spaces indentation + + test_Yaml2JsonPretty(); + test_Yaml2Json(); + test_Json2Yaml(); + test_serializeYml_JsonObject_YamlString(); + test_serializeYml_JsonObject_YamlStream(); +} + + +void loop() +{ + +} + diff --git a/examples/test/src/test.cpp b/examples/test/src/test.cpp index 6a7949c..d19f41a 100644 --- a/examples/test/src/test.cpp +++ b/examples/test/src/test.cpp @@ -227,7 +227,7 @@ void test_Yaml_Stream_Loader() String yaml_str = String( yaml_sample_str ); StringStream yaml_stream( yaml_str ); DynamicJsonDocument json_doc(2048); - JsonObject json_obj = json_doc.as(); + JsonObject json_obj = json_doc.to(); auto err = deserializeYml( json_obj, yaml_stream ); // deserialize yaml stream to JsonObject if( err ) { YAML_LOG_n("Unable to deserialize demo YAML to JsonObject: %s", err.c_str() ); @@ -244,7 +244,7 @@ void test_Yaml_Stream_Loader() { YAML_LOG_n( "[TEST #%d] YAML string to JsonObject -> deserializeYml(json_obj, yaml_sample_str):", test_number++ ); DynamicJsonDocument json_doc(2048); - JsonObject json_obj = json_doc.as(); + JsonObject json_obj = json_doc.to(); auto err = deserializeYml( json_obj, yaml_sample_str ); // deserialize yaml string to JsonObject if( err ) { YAML_LOG_n("Unable to deserialize demo YAML to JsonObject: %s", err.c_str() ); From 256796ba7f653e04c17d0ec0405ea3d7a2742ec9 Mon Sep 17 00:00:00 2001 From: tobozo Date: Wed, 26 Oct 2022 20:03:23 +0200 Subject: [PATCH 53/54] some refactor --- library.properties | 2 +- src/ArduinoYaml.cpp | 124 ++++++++++++++++++++++++++------------------ src/ArduinoYaml.hpp | 87 ++++++++++++++++++------------- src/logger.hpp | 3 ++ 4 files changed, 129 insertions(+), 87 deletions(-) diff --git a/library.properties b/library.properties index 477d725..1c78eb0 100644 --- a/library.properties +++ b/library.properties @@ -6,7 +6,7 @@ sentence=A simple and efficient YAML library for embedded C++ paragraph=ArduinoYaml is syntax friendly with ArduinoJson and cJSON, supports ✔ serialization, ✔ deserialization, ✔ conversion category=Data Processing url=https://github.com/tobozo/YAMLDuino -architectures=esp32,esp8266,samd,rp2040,mbed_rp2040,mbed_nano +architectures=esp32,esp8266,samd,rp2040,mbed_rp2040,mbed_nano,avr includes=ArduinoYaml.h,YAMLDuino.h depends=ArduinoJson license=MIT diff --git a/src/ArduinoYaml.cpp b/src/ArduinoYaml.cpp index e4a63b7..859e620 100644 --- a/src/ArduinoYaml.cpp +++ b/src/ArduinoYaml.cpp @@ -348,20 +348,21 @@ size_t serialize_YamlDocument( yaml_traverser_t *it ) size_t bytes_out = 0; int node_count = 0; + int node_max = 0; + bool is_seq = false; + bool needs_folding = false; + bool needs_quotes = false; switch (node->type) { case YAML_SCALAR_NODE: - { - bool needs_quotes = scalar_needs_quote( node ); + needs_quotes = scalar_needs_quote( node ); if( needs_quotes ) bytes_out += stream->printf("\""); yaml_escape_quoted_string( stream, SCALAR_c(node), strlen(SCALAR_c(node)), &bytes_out ); if( needs_quotes ) bytes_out += stream->printf("\""); - } break; case YAML_SEQUENCE_NODE: - { bytes_out += stream->printf("["); - const int node_max = node->data.sequence.items.top - node->data.sequence.items.start; + node_max = node->data.sequence.items.top - node->data.sequence.items.start; for (auto item_i = node->data.sequence.items.start; item_i < node->data.sequence.items.top; ++item_i) { auto node_item = yaml_document_get_node(document, *item_i); int child_level = node_item->type == YAML_MAPPING_NODE ? depth+1 : depth-1; @@ -373,15 +374,13 @@ size_t serialize_YamlDocument( yaml_traverser_t *it ) } } bytes_out += stream->printf("]"); - } break; case YAML_MAPPING_NODE: - { - bool is_seq = ( depth>0 && nest_type == YAMLParser::SEQ_KEY ); - bool needs_folding = (depth>YAML::JSONFoldindDepth); + is_seq = ( depth>0 && nest_type == YAMLParser::SEQ_KEY ); + needs_folding = (depth>YAML::JSONFoldindDepth); bytes_out += stream->printf("{"); if( !needs_folding ) bytes_out += stream->printf("\n%s", indent(depth+1, YAML::JSON_INDENT) ); - const int node_max = node->data.mapping.pairs.top - node->data.mapping.pairs.start; + node_max = node->data.mapping.pairs.top - node->data.mapping.pairs.start; for (auto pair_i = node->data.mapping.pairs.start; pair_i < node->data.mapping.pairs.top; ++pair_i) { auto key = yaml_document_get_node(document, pair_i->key); auto value = yaml_document_get_node(document, pair_i->value); @@ -400,8 +399,6 @@ size_t serialize_YamlDocument( yaml_traverser_t *it ) } if( !needs_folding ) bytes_out += stream->printf("\n%s", indent( is_seq ? depth-1 : depth, YAML::JSON_INDENT) ); bytes_out += stream->printf("}"); - - } break; case YAML_NO_NODE: break; default: YAML_LOG_e("Unknown node type (line %lu).", node->start_mark.line); break; @@ -512,12 +509,12 @@ void YAMLParser::setLogLevel( YAML::LogLevel_t level ) } -void YAMLParser::parse( OutputFormat_t format ) +bool YAMLParser::parse( OutputFormat_t format ) { yaml_node_t* node; if (node = yaml_document_get_root_node(&document), !node) { YAML_LOG_e("No document defined."); - return; + return false; } yaml_traverser_t doc = { &document, node, _yaml_stream, YAMLParser::NONE, 0 }; @@ -525,14 +522,15 @@ void YAMLParser::parse( OutputFormat_t format ) size_t bytes_out = output_cb( &doc ); YAML_LOG_d("written %d bytes", bytes_out ); + return bytes_out>0; } -void YAMLParser::parse( Stream &yaml_or_json_stream, OutputFormat_t format ) +bool YAMLParser::parse( Stream &yaml_or_json_stream, OutputFormat_t format ) { if (!yaml_parser_initialize(&parser)) { YAML_LOG_e("Failed to initialize parser!\n", stderr); - return; + return false; } yaml_stream_handler_data_t shd = { &yaml_or_json_stream, &_bytes_read }; @@ -540,13 +538,13 @@ void YAMLParser::parse( Stream &yaml_or_json_stream, OutputFormat_t format ) if (!yaml_parser_load(&parser, &document)) { handle_parser_error(&parser); - return; + return false; } yaml_node_t* node; if (node = yaml_document_get_root_node(&document), !node) { YAML_LOG_e("No document defined."); - return; + return false; } yaml_traverser_t doc = { &document, node, _yaml_stream, YAMLParser::NONE, 0 }; @@ -554,30 +552,31 @@ void YAMLParser::parse( Stream &yaml_or_json_stream, OutputFormat_t format ) size_t bytes_out = output_cb( &doc ); YAML_LOG_d("written %d bytes", bytes_out ); + return bytes_out>0; } -void YAMLParser::parse( const char* yaml_or_json_str, OutputFormat_t format ) +bool YAMLParser::parse( const char* yaml_or_json_str, OutputFormat_t format ) { - assert( yaml_or_json_str ); + if( !yaml_or_json_str || strlen(yaml_or_json_str)<=0 ) return false; if (!yaml_parser_initialize(&parser)) { YAML_LOG_e("Failed to initialize parser!\n", stderr); - return; + return false; } yaml_parser_set_input_string(&parser, (const unsigned char*)yaml_or_json_str, strlen(yaml_or_json_str) ); if (!yaml_parser_load(&parser, &document)) { handle_parser_error(&parser); - return; + return false; } yaml_node_t* node; if (node = yaml_document_get_root_node(&document), !node) { YAML_LOG_e("No document defined."); - return; + return false; } yaml_traverser_t doc = { &document, node, _yaml_stream, YAMLParser::NONE, 0 }; @@ -585,10 +584,11 @@ void YAMLParser::parse( const char* yaml_or_json_str, OutputFormat_t format ) size_t bytes_out = output_cb( &doc ); YAML_LOG_d("written %d bytes", bytes_out ); + return bytes_out>0; } -void YAMLParser::load( Stream &yaml_or_json_stream ) +bool YAMLParser::load( Stream &yaml_or_json_stream ) { _yaml_string = ""; // reset internal output stream _bytes_read = 0; // length will be known when the stream is consumed @@ -597,19 +597,19 @@ void YAMLParser::load( Stream &yaml_or_json_stream ) if ( !yaml_parser_initialize(&parser) ) { handle_parser_error(&parser); YAML_LOG_e("[FATAL] could not initialize parser"); - return; + return false; } yaml_stream_handler_data_t shd = { &yaml_or_json_stream, &_bytes_read }; yaml_parser_set_input(&parser, &_yaml_stream_reader, &shd); - _loadDocument(); + return _loadDocument(); } -void YAMLParser::load( const char* yaml_or_json_str ) +bool YAMLParser::load( const char* yaml_or_json_str ) { - assert( yaml_or_json_str ); + if( !yaml_or_json_str || strlen(yaml_or_json_str)<=0 ) return false; _yaml_string = ""; // reset internal output stream _bytes_read = strlen(yaml_or_json_str); // length is already known @@ -618,21 +618,22 @@ void YAMLParser::load( const char* yaml_or_json_str ) if ( !yaml_parser_initialize(&parser) ) { handle_parser_error(&parser); YAML_LOG_e("[FATAL] could not initialize parser"); - return; + return false; } yaml_parser_set_input_string(&parser, (const unsigned char*)yaml_or_json_str, _bytes_read ); - _loadDocument(); + return _loadDocument(); } // private, called by load(const char*) and load(Stream&) -void YAMLParser::_loadDocument() +bool YAMLParser::_loadDocument() { + bool ret = false; yaml_document_t _tmpdoc; yaml_emitter_t emitter; - assert(yaml_emitter_initialize(&emitter)); + if(!yaml_emitter_initialize(&emitter)) return false; yaml_stream_handler_data_t shd = { nullptr, &_bytes_written }; yaml_emitter_set_canonical(&emitter, 1); yaml_emitter_set_unicode(&emitter, 1); @@ -643,13 +644,16 @@ void YAMLParser::_loadDocument() YAML_LOG_e("[FATAL] Failed to load YAML document at line %lu", parser.problem_mark.line); goto _emitter_delete; } - assert( yaml_copy_document(&_tmpdoc, &document) ); // copy into local document for later parsing - assert( yaml_emitter_dump(&emitter, &_tmpdoc) ); // dump to emitter for input length evaluation - yaml_document_delete(&_tmpdoc); + if(! yaml_copy_document(&_tmpdoc, &document) ) goto _emitter_delete; + if( yaml_emitter_dump(&emitter, &_tmpdoc) ) { // dump to emitter for input length evaluation + yaml_document_delete(&_tmpdoc); + ret = true; + } _emitter_delete: yaml_emitter_close(&emitter); yaml_emitter_delete(&emitter); + return ret; } @@ -696,8 +700,10 @@ void YAMLParser::handle_emitter_error(yaml_emitter_t *e) // yaml_node_t deconstructor => JsonObject - void deserializeYml_JsonObject( yaml_document_t* document, yaml_node_t* yamlNode, JsonObject &jsonNode, JNestingType_t nt, const char *nodename, int depth ) + DeserializationError deserializeYml_JsonObject( yaml_document_t* document, yaml_node_t* yamlNode, JsonObject &jsonNode, JNestingType_t nt, const char *nodename, int depth ) { + bool isRootNode = ( strlen(nodename)<=0 ); + switch (yamlNode->type) { case YAML_SCALAR_NODE: { @@ -754,7 +760,7 @@ void YAMLParser::handle_emitter_error(yaml_emitter_t *e) break; case YAML_MAPPING_NODE: { - JsonObject tmpNode = jsonNode.createNestedObject((char*)nodename); + JsonObject tmpNode = isRootNode ? jsonNode : jsonNode.createNestedObject((char*)nodename); yaml_node_pair_t* pair_i; yaml_node_t* key; yaml_node_t* value; @@ -770,9 +776,12 @@ void YAMLParser::handle_emitter_error(yaml_emitter_t *e) } } break; - case YAML_NO_NODE: YAML_LOG_e("YAML_NO_NODE"); break; + case YAML_NO_NODE: YAML_LOG_e("YAML_NO_NODE"); + + break; default: YAML_LOG_e("Unknown node type (line %lu).", yamlNode->start_mark.line); break; } + return DeserializationError::Ok; } @@ -821,29 +830,42 @@ void YAMLParser::handle_emitter_error(yaml_emitter_t *e) DeserializationError deserializeYml( JsonDocument &dest_doc, Stream &src ) { YAMLToArduinoJson *parser = new YAMLToArduinoJson(); - JsonObject tmpObj = parser->toJson( src ); // decode yaml stream/string - DeserializationError ret = DeserializationError::Ok; - if( !dest_doc.set( tmpObj[ROOT_NODE] ) ) { - ret = DeserializationError::NoMemory; - } + JsonObject dest_obj = dest_doc.to(); + DeserializationError ret = parser->toJsonObject( src, dest_obj ); delete parser; - return DeserializationError::Ok; + return ret; } - DeserializationError deserializeYml( JsonDocument &dest_doc, const char *src ) + DeserializationError deserializeYml( JsonDocument &dest_doc, const char* src ) { YAMLToArduinoJson *parser = new YAMLToArduinoJson(); - JsonObject tmpObj = parser->toJson( src ); // decode yaml stream/string - DeserializationError ret = DeserializationError::Ok; - if( !dest_doc.set( tmpObj[ROOT_NODE] ) ) { - ret = DeserializationError::NoMemory; - } + JsonObject dest_obj = dest_doc.to(); + DeserializationError ret = parser->toJsonObject( src, dest_obj ); delete parser; - return DeserializationError::Ok; + return ret; + } + + + DeserializationError deserializeYml( JsonObject &dest_obj, Stream &src) + { + YAMLToArduinoJson *parser = new YAMLToArduinoJson(); + DeserializationError ret = parser->toJsonObject( src, dest_obj ); + delete parser; + return ret; } + DeserializationError deserializeYml( JsonObject &dest_obj, const char* src) + { + YAMLToArduinoJson *parser = new YAMLToArduinoJson(); + DeserializationError ret = parser->toJsonObject( src, dest_obj ); + delete parser; + return ret; + } + + + #endif // HAS_ARDUINOJSON diff --git a/src/ArduinoYaml.hpp b/src/ArduinoYaml.hpp index 0909e96..6c1fa6b 100644 --- a/src/ArduinoYaml.hpp +++ b/src/ArduinoYaml.hpp @@ -123,19 +123,19 @@ class YAMLParser void setOutputStream( Stream* stream ) { _yaml_stream = stream; } // yaml/json loaders (populates this.document) - void load( const char* yaml_or_json_str ); - void load( Stream &yaml_or_json_stream ); + bool load( const char* yaml_or_json_str ); + bool load( Stream &yaml_or_json_stream ); // the swiss-army knife functions: // parse any of yaml/json input, and output as yaml, json ugly or json pretty - void parse( OutputFormat_t format=OUTPUT_YAML ); - void parse( const char* yaml_or_json_str, OutputFormat_t format=OUTPUT_YAML ); - void parse( Stream &yaml_or_json_stream, OutputFormat_t format=OUTPUT_YAML ); + bool parse( OutputFormat_t format=OUTPUT_YAML ); + bool parse( const char* yaml_or_json_str, OutputFormat_t format=OUTPUT_YAML ); + bool parse( Stream &yaml_or_json_stream, OutputFormat_t format=OUTPUT_YAML ); - // explicit JSON exporters - template - void toJson( T &yaml, bool pretty = true ) { load( yaml ); toJson( pretty ); } - void toJson( bool pretty = true ) { parse( pretty ? OUTPUT_JSON_PRETTY : OUTPUT_JSON ); } + // // explicit JSON exporters + // template + // void toJson( T &yaml, bool pretty = true ) { load( yaml ); toJson( pretty ); } + // void toJson( bool pretty = true ) { parse( pretty ? OUTPUT_JSON_PRETTY : OUTPUT_JSON ); } // various getters yaml_document_t* getDocument() { return &document; } @@ -154,7 +154,7 @@ class YAMLParser String _yaml_string; Stream *_yaml_stream = nullptr; StringStream *_yaml_string_stream_ptr = nullptr; - void _loadDocument(); + bool _loadDocument(); yaml_document_t document; yaml_parser_t parser; OutputFormat_t output_format; @@ -180,7 +180,7 @@ size_t serializeYml( Stream &json_src_stream, Stream &yml_dest_stream, OutputFor // default name for the topmost temporary JsonObject #define ROOT_NODE "_root_" // deconstructors - void deserializeYml_JsonObject( yaml_document_t* document, yaml_node_t* yamlNode, JsonObject &jsonNode, JNestingType_t nt=YAMLParser::NONE, const char *nodename=ROOT_NODE, int depth=0 ); + DeserializationError deserializeYml_JsonObject( yaml_document_t*, yaml_node_t* , JsonObject&, JNestingType_t nt=YAMLParser::NONE, const char *nodename="", int depth=0 ); size_t serializeYml_JsonVariant( JsonVariant root, Stream &out, int depth_level, JNestingType_t nt ); class YAMLToArduinoJson : public YAMLParser @@ -204,16 +204,19 @@ size_t serializeYml( Stream &json_src_stream, Stream &yml_dest_stream, OutputFor } deserializeYml_JsonObject(getDocument(), node, _root); } + template - JsonObject& toJson( T &yaml ) + DeserializationError toJsonObject( T &src, JsonObject& output ) { - load( yaml ); - if( bytesWritten() > 0 ) { - setJsonDocument( bytesWritten()*2 ); - toJson(); + if( !load( src ) ) return DeserializationError::NoMemory; + yaml_node_t * node; + if (node = yaml_document_get_root_node(getDocument()), !node) { + YAML_LOG_e("No document defined."); + return DeserializationError::NoMemory; } - return _root; + return deserializeYml_JsonObject(getDocument(), node, output); } + private: DynamicJsonDocument *_doc = nullptr; JsonObject _root; @@ -230,27 +233,41 @@ size_t serializeYml( Stream &json_src_stream, Stream &yml_dest_stream, OutputFor // Deserialize YAML stream to ArduinoJSON document DeserializationError deserializeYml( JsonDocument &dest_doc, const char *src); + + // [templated] Deserialize YAML string to ArduinoJSON Document + DeserializationError deserializeYml( JsonObject &dest_doc, const char* src_yaml_str ); + // [templated] Deserialize YAML stream to ArduinoJSON Document + DeserializationError deserializeYml( JsonObject &dest_doc, Stream &src_stream ); + + // [templated] Deserialize YAML string to ArduinoJSON object // DeserializationError deserializeYml( JsonObject &dest_obj, const char* src_yaml_str ); // [templated] Deserialize YAML stream to ArduinoJSON object // DeserializationError deserializeYml( JsonObject &dest_obj, Stream &src_stream ); - template - DeserializationError deserializeYml( JsonObject &dest_obj, T &src) - { - //static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "src must be const char* or Stream*"); - YAMLToArduinoJson *parser = new YAMLToArduinoJson(); - JsonObject _dest_obj = parser->toJson( src ); // decode yaml stream/string - dest_obj = _dest_obj[ROOT_NODE]; - size_t capacity = parser->bytesWritten()*2; - delete parser; - if( capacity == 0 ) { - return DeserializationError::InvalidInput; - } - if( dest_obj.isNull() ) { - return DeserializationError::NoMemory; - } - return DeserializationError::Ok; - } +// template +// DeserializationError deserializeYml( JsonObject &dest_obj, T &src) +// { +// YAMLToArduinoJson *parser = new YAMLToArduinoJson(); +// //JsonObject dest_obj = dest_doc.to(); +// DeserializationError ret = parser->toJsonObject( src, dest_obj ); +// delete parser; +// return ret; +// /* +// +// //static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "src must be const char* or Stream*"); +// YAMLToArduinoJson *parser = new YAMLToArduinoJson(); +// JsonObject _dest_obj = parser->toJson( src ); // decode yaml stream/string +// dest_obj = _dest_obj[ROOT_NODE]; +// size_t capacity = parser->bytesWritten()*2; +// delete parser; +// if( capacity == 0 ) { +// return DeserializationError::InvalidInput; +// } +// if( dest_obj.isNull() ) { +// return DeserializationError::NoMemory; +// } +// return DeserializationError::Ok;*/ +// } #endif // HAS_ARDUINOJSON @@ -283,7 +300,7 @@ size_t serializeYml( Stream &json_src_stream, Stream &yml_dest_stream, OutputFor if (node = yaml_document_get_root_node(document), !node) { YAML_LOG_w("No document defined."); return NULL; } return deserializeYml_cJSONObject(document, node); }; - cJSON *toJson( const char* yaml_str ) { load( yaml_str ); return toJson( getDocument() ); }; + cJSON *toJson( const char* yaml_str ) { load( yaml_str ); return toJson( getDocument() ); } cJSON* toJson( Stream &yaml_stream ) { load( yaml_stream ); return toJson( getDocument() ); } }; diff --git a/src/logger.hpp b/src/logger.hpp index db6f931..25c3a7e 100644 --- a/src/logger.hpp +++ b/src/logger.hpp @@ -82,6 +82,9 @@ } #define HEAP_AVAILABLE() getFreeRam() #else + #include + #include + #define LOG_PRINTF Serial.printf static int getFreeRam() { // implement your own From 4ba933f67cfeb7d1090b9d3872ea0cd599c6c2cc Mon Sep 17 00:00:00 2001 From: tobozo Date: Wed, 26 Oct 2022 20:19:47 +0200 Subject: [PATCH 54/54] bump version --- library.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index 1c78eb0..0e84c61 100644 --- a/library.properties +++ b/library.properties @@ -1,12 +1,12 @@ name=YAMLDuino -version=1.2.8 +version=1.2.9 author=tobozo maintainer=tobozo sentence=A simple and efficient YAML library for embedded C++ paragraph=ArduinoYaml is syntax friendly with ArduinoJson and cJSON, supports ✔ serialization, ✔ deserialization, ✔ conversion category=Data Processing url=https://github.com/tobozo/YAMLDuino -architectures=esp32,esp8266,samd,rp2040,mbed_rp2040,mbed_nano,avr +architectures=esp32,esp8266,samd,rp2040,mbed_rp2040,mbed_nano includes=ArduinoYaml.h,YAMLDuino.h depends=ArduinoJson license=MIT