Skip to content

Commit

Permalink
fix(json): Skip requirements if libs are not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz committed Oct 3, 2024
1 parent 613536a commit 0d46a3d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
33 changes: 21 additions & 12 deletions .github/scripts/sketch_utils.sh
Original file line number Diff line number Diff line change
@@ -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 <ide_path> <user_path> <path-to-ino> [extra-options]
while [ ! -z "$1" ]; do
Expand Down Expand Up @@ -278,10 +284,11 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
unset options
}

function count_sketches(){ # count_sketches <path> [target] [file]
function count_sketches(){ # count_sketches <path> [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"
Expand Down Expand Up @@ -314,16 +321,18 @@ function count_sketches(){ # count_sketches <path> [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
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/tests_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,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)
Expand Down

0 comments on commit 0d46a3d

Please sign in to comment.