From 6ba86819991be83360777847f6131b1012c6e7a9 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Thu, 3 Oct 2024 01:11:46 -0300 Subject: [PATCH] fix(json): Skip requirements if libs are not installed --- .github/scripts/sketch_utils.sh | 35 +++++++++++++++++++------------ .github/scripts/tests_run.sh | 12 ++++------- .github/workflows/tests_build.yml | 1 + 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.github/scripts/sketch_utils.sh b/.github/scripts/sketch_utils.sh index 8316c328e9c..746f467cfae 100755 --- a/.github/scripts/sketch_utils.sh +++ b/.github/scripts/sketch_utils.sh @@ -1,6 +1,12 @@ #!/bin/bash -SDKCONFIG_DIR="$ARDUINO_ESP32_PATH/tools/esp32-arduino-libs" +if [ -d "$ARDUINO_ESP32_PATH/tools/esp32-arduino-libs" ]; then + SDKCONFIG_DIR="$ARDUINO_ESP32_PATH/tools/esp32-arduino-libs" +elif [ -d "$GITHUB_WORKSPACE/tools/esp32-arduino-libs" ]; then + SDKCONFIG_DIR="$GITHUB_WORKSPACE/tools/esp32-arduino-libs" +else + SDKCONFIG_DIR="tools/esp32-arduino-libs" +fi function build_sketch(){ # build_sketch [extra-options] while [ ! -z "$1" ]; do @@ -278,10 +284,11 @@ function build_sketch(){ # build_sketch [ex unset options } -function count_sketches(){ # count_sketches [target] [file] +function count_sketches(){ # count_sketches [target] [file] [ignore-requirements] local path=$1 local target=$2 local file=$3 + local ignore_requirements=$4 if [ $# -lt 1 ]; then echo "ERROR: Illegal number of parameters" @@ -294,7 +301,7 @@ function count_sketches(){ # count_sketches [target] [file] return 0 fi - if [ -n "$file" ]; then + if [ -f "$file" ]; then local sketches=$(cat $file) else local sketches=$(find $path -name *.ino | sort) @@ -314,16 +321,18 @@ function count_sketches(){ # count_sketches [target] [file] continue fi - # Check if the sketch requires any configuration options - requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json) - if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then - for requirement in $requirements; do - requirement=$(echo $requirement | xargs) - found_line=$(grep -E "^$requirement" $SDKCONFIG_DIR/$target/sdkconfig) - if [[ "$found_line" == "" ]]; then - continue 2 - fi - done + if [[ "$ignore_requirements" != "1" ]]; then + # Check if the sketch requires any configuration options + requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json) + if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then + for requirement in $requirements; do + requirement=$(echo $requirement | xargs) + found_line=$(grep -E "^$requirement" $SDKCONFIG_DIR/$target/sdkconfig) + if [[ "$found_line" == "" ]]; then + continue 2 + fi + done + fi fi fi echo $sketch >> sketches.txt diff --git a/.github/scripts/tests_run.sh b/.github/scripts/tests_run.sh index be084e90ce2..ecdd8ed758a 100755 --- a/.github/scripts/tests_run.sh +++ b/.github/scripts/tests_run.sh @@ -30,14 +30,10 @@ function run_test() { return 0 fi - if [ -d $ARDUINO_ESP32_PATH/tools/esp32-arduino-libs ]; then - SDKCONFIG_PATH="$ARDUINO_ESP32_PATH/tools/esp32-arduino-libs/$target/sdkconfig" + if [ $len -eq 1 ]; then + SDKCONFIG_PATH="$HOME/.arduino/tests/$sketchname/build.tmp/sdkconfig" else - if [ $len -eq 1 ]; then - SDKCONFIG_PATH="$HOME/.arduino/tests/$sketchname/build.tmp/sdkconfig" - else - SDKCONFIG_PATH="$HOME/.arduino/tests/$sketchname/build0.tmp/sdkconfig" - fi + SDKCONFIG_PATH="$HOME/.arduino/tests/$sketchname/build0.tmp/sdkconfig" fi # Check if the sketch requires any configuration options @@ -233,7 +229,7 @@ else fi set +e - ${COUNT_SKETCHES} $test_folder $target + ${COUNT_SKETCHES} $test_folder $target "" "1" # Ignore requirements as we don't have the libs. The requirements will be checked in the run_test function sketchcount=$? set -e sketches=$(cat sketches.txt) diff --git a/.github/workflows/tests_build.yml b/.github/workflows/tests_build.yml index b02e23ebd70..090dfa8136b 100644 --- a/.github/workflows/tests_build.yml +++ b/.github/workflows/tests_build.yml @@ -29,6 +29,7 @@ jobs: ~/.arduino/tests/**/build*.tmp/*.bin ~/.arduino/tests/**/build*.tmp/*.elf ~/.arduino/tests/**/build*.tmp/*.json + ~/.arduino/tests/**/build*.tmp/sdkconfig - name: Evaluate if tests should be built id: check-build