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 696fda8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
35 changes: 22 additions & 13 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 All @@ -294,7 +301,7 @@ function count_sketches(){ # count_sketches <path> [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)
Expand All @@ -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
12 changes: 4 additions & 8 deletions .github/scripts/tests_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/tests_hw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ jobs:
sparse-checkout: |
*
- name: List files
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
run: ls -la

# setup-python currently only works on ubuntu images
# - uses: actions/setup-python@v5
# if: ${{ steps.check-tests.outputs.enabled == 'true' }}
Expand Down

0 comments on commit 696fda8

Please sign in to comment.