Skip to content

Commit

Permalink
fix(push): Fix push chunks script indentation and lib detection
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz committed Nov 4, 2024
1 parent 325c822 commit 1de6372
Showing 1 changed file with 58 additions and 58 deletions.
116 changes: 58 additions & 58 deletions .github/scripts/set_push_chunks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,73 @@ build_all=false
chunks_count=0

if [[ $CORE_CHANGED == 'true' ]] || [[ $IS_PR != 'true' ]]; then
echo "Core files changed or not a PR. Building all."
build_all=true
chunks_count=$MAX_CHUNKS
echo "Core files changed or not a PR. Building all."
build_all=true
chunks_count=$MAX_CHUNKS
elif [[ $LIB_CHANGED == 'true' ]]; then
echo "Libraries changed. Building only affected sketches."
if [[ $NETWORKING_CHANGED == 'true' ]]; then
echo "Networking libraries changed. Building networking related sketches."
networking_sketches="$(find libraries/WiFi -name *.ino) "
networking_sketches+="$(find libraries/Ethernet -name *.ino) "
networking_sketches+="$(find libraries/PPP -name *.ino) "
networking_sketches+="$(find libraries/NetworkClientSecure -name *.ino) "
networking_sketches+="$(find libraries/WebServer -name *.ino) "
fi
if [[ $FS_CHANGED == 'true' ]]; then
echo "FS libraries changed. Building FS related sketches."
fs_sketches="$(find libraries/SD -name *.ino) "
fs_sketches+="$(find libraries/SD_MMC -name *.ino) "
fs_sketches+="$(find libraries/SPIFFS -name *.ino) "
fs_sketches+="$(find libraries/LittleFS -name *.ino) "
fs_sketches+="$(find libraries/FFat -name *.ino) "
fi
sketches="$networking_sketches $fs_sketches"
for file in $LIB_FILES; do
if [[ $file == *.ino ]]; then
# If file ends with .ino, add it to the list of sketches
echo "Sketch found: $file"
sketches+="$file "
elif [[ $(basename $(dirname $file)) == "src" ]]; then
# If file is in a src directory, find all sketches in the parent/examples directory
echo "Library src file found: $file"
lib=$(dirname $(dirname $file))
if [[ -d $lib/examples ]]; then
lib_sketches=$(find $lib/examples -name *.ino)
sketches+="$lib_sketches "
echo "Library sketches: $lib_sketches"
fi
else
# If file is in a example folder but it is not a sketch, find all sketches in the current directory
echo "File in example folder found: $file"
sketch=$(find $(dirname $file) -name *.ino)
sketches+="$sketch "
echo "Sketch in example folder: $sketch"
fi
echo ""
done
echo "Libraries changed. Building only affected sketches."
if [[ $NETWORKING_CHANGED == 'true' ]]; then
echo "Networking libraries changed. Building networking related sketches."
networking_sketches="$(find libraries/WiFi -name *.ino) "
networking_sketches+="$(find libraries/Ethernet -name *.ino) "
networking_sketches+="$(find libraries/PPP -name *.ino) "
networking_sketches+="$(find libraries/NetworkClientSecure -name *.ino) "
networking_sketches+="$(find libraries/WebServer -name *.ino) "
fi
if [[ $FS_CHANGED == 'true' ]]; then
echo "FS libraries changed. Building FS related sketches."
fs_sketches="$(find libraries/SD -name *.ino) "
fs_sketches+="$(find libraries/SD_MMC -name *.ino) "
fs_sketches+="$(find libraries/SPIFFS -name *.ino) "
fs_sketches+="$(find libraries/LittleFS -name *.ino) "
fs_sketches+="$(find libraries/FFat -name *.ino) "
fi
sketches="$networking_sketches $fs_sketches"
for file in $LIB_FILES; do
lib=$(echo $file | awk -F "/" '{print $1"/"$2}')
if [[ $file == *.ino ]]; then
# If file ends with .ino, add it to the list of sketches
echo "Sketch found: $file"
sketches+="$file "
elif [[ $file == $lib/src/* ]]; then
# If file is inside the src directory, find all sketches in the lib/examples directory
echo "Library src file found: $file"
if [[ -d $lib/examples ]]; then
lib_sketches=$(find $lib/examples -name *.ino)
sketches+="$lib_sketches "
echo "Library sketches: $lib_sketches"
fi
else
# If file is in a example folder but it is not a sketch, find all sketches in the current directory
echo "File in example folder found: $file"
sketch=$(find $(dirname $file) -name *.ino)
sketches+="$sketch "
echo "Sketch in example folder: $sketch"
fi
echo ""
done
fi

if [[ -n $sketches ]]; then
# Remove duplicates
sketches=$(echo $sketches | tr ' ' '\n' | sort | uniq)
for sketch in $sketches; do
echo $sketch >> sketches_found.txt
chunks_count=$((chunks_count+1))
done
echo "Number of sketches found: $chunks_count"
echo "Sketches:"
echo "$sketches"
# Remove duplicates
sketches=$(echo $sketches | tr ' ' '\n' | sort | uniq)
for sketch in $sketches; do
echo $sketch >> sketches_found.txt
chunks_count=$((chunks_count+1))
done
echo "Number of sketches found: $chunks_count"
echo "Sketches:"
echo "$sketches"

if [[ $chunks_count -gt $MAX_CHUNKS ]]; then
echo "More sketches than the allowed number of chunks found. Limiting to $MAX_CHUNKS chunks."
chunks_count=$MAX_CHUNKS
fi
if [[ $chunks_count -gt $MAX_CHUNKS ]]; then
echo "More sketches than the allowed number of chunks found. Limiting to $MAX_CHUNKS chunks."
chunks_count=$MAX_CHUNKS
fi
fi

chunks='["0"'
for i in $(seq 1 $(( $chunks_count - 1 )) ); do
chunks+=",\"$i\""
chunks+=",\"$i\""
done
chunks+="]"

Expand Down

0 comments on commit 1de6372

Please sign in to comment.