Skip to content

Commit 352337b

Browse files
committed
fix(push): Fix push chunks script indentation and lib detection
1 parent 325c822 commit 352337b

File tree

1 file changed

+58
-58
lines changed

1 file changed

+58
-58
lines changed

.github/scripts/set_push_chunks.sh

+58-58
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,73 @@ build_all=false
44
chunks_count=0
55

66
if [[ $CORE_CHANGED == 'true' ]] || [[ $IS_PR != 'true' ]]; then
7-
echo "Core files changed or not a PR. Building all."
8-
build_all=true
9-
chunks_count=$MAX_CHUNKS
7+
echo "Core files changed or not a PR. Building all."
8+
build_all=true
9+
chunks_count=$MAX_CHUNKS
1010
elif [[ $LIB_CHANGED == 'true' ]]; then
11-
echo "Libraries changed. Building only affected sketches."
12-
if [[ $NETWORKING_CHANGED == 'true' ]]; then
13-
echo "Networking libraries changed. Building networking related sketches."
14-
networking_sketches="$(find libraries/WiFi -name *.ino) "
15-
networking_sketches+="$(find libraries/Ethernet -name *.ino) "
16-
networking_sketches+="$(find libraries/PPP -name *.ino) "
17-
networking_sketches+="$(find libraries/NetworkClientSecure -name *.ino) "
18-
networking_sketches+="$(find libraries/WebServer -name *.ino) "
19-
fi
20-
if [[ $FS_CHANGED == 'true' ]]; then
21-
echo "FS libraries changed. Building FS related sketches."
22-
fs_sketches="$(find libraries/SD -name *.ino) "
23-
fs_sketches+="$(find libraries/SD_MMC -name *.ino) "
24-
fs_sketches+="$(find libraries/SPIFFS -name *.ino) "
25-
fs_sketches+="$(find libraries/LittleFS -name *.ino) "
26-
fs_sketches+="$(find libraries/FFat -name *.ino) "
27-
fi
28-
sketches="$networking_sketches $fs_sketches"
29-
for file in $LIB_FILES; do
30-
if [[ $file == *.ino ]]; then
31-
# If file ends with .ino, add it to the list of sketches
32-
echo "Sketch found: $file"
33-
sketches+="$file "
34-
elif [[ $(basename $(dirname $file)) == "src" ]]; then
35-
# If file is in a src directory, find all sketches in the parent/examples directory
36-
echo "Library src file found: $file"
37-
lib=$(dirname $(dirname $file))
38-
if [[ -d $lib/examples ]]; then
39-
lib_sketches=$(find $lib/examples -name *.ino)
40-
sketches+="$lib_sketches "
41-
echo "Library sketches: $lib_sketches"
42-
fi
43-
else
44-
# If file is in a example folder but it is not a sketch, find all sketches in the current directory
45-
echo "File in example folder found: $file"
46-
sketch=$(find $(dirname $file) -name *.ino)
47-
sketches+="$sketch "
48-
echo "Sketch in example folder: $sketch"
49-
fi
50-
echo ""
51-
done
11+
echo "Libraries changed. Building only affected sketches."
12+
if [[ $NETWORKING_CHANGED == 'true' ]]; then
13+
echo "Networking libraries changed. Building networking related sketches."
14+
networking_sketches="$(find libraries/WiFi -name *.ino) "
15+
networking_sketches+="$(find libraries/Ethernet -name *.ino) "
16+
networking_sketches+="$(find libraries/PPP -name *.ino) "
17+
networking_sketches+="$(find libraries/NetworkClientSecure -name *.ino) "
18+
networking_sketches+="$(find libraries/WebServer -name *.ino) "
19+
fi
20+
if [[ $FS_CHANGED == 'true' ]]; then
21+
echo "FS libraries changed. Building FS related sketches."
22+
fs_sketches="$(find libraries/SD -name *.ino) "
23+
fs_sketches+="$(find libraries/SD_MMC -name *.ino) "
24+
fs_sketches+="$(find libraries/SPIFFS -name *.ino) "
25+
fs_sketches+="$(find libraries/LittleFS -name *.ino) "
26+
fs_sketches+="$(find libraries/FFat -name *.ino) "
27+
fi
28+
sketches="$networking_sketches $fs_sketches"
29+
for file in $LIB_FILES; do
30+
lib=$(echo $file | awk -F "/" '{print $1"/"$2}')
31+
if [[ "$file" == *.ino ]]; then
32+
# If file ends with .ino, add it to the list of sketches
33+
echo "Sketch found: $file"
34+
sketches+="$file "
35+
elif [[ "$file" == "$lib/src/"* ]]; then
36+
# If file is inside the src directory, find all sketches in the lib/examples directory
37+
echo "Library src file found: $file"
38+
if [[ -d $lib/examples ]]; then
39+
lib_sketches=$(find $lib/examples -name *.ino)
40+
sketches+="$lib_sketches "
41+
echo "Library sketches: $lib_sketches"
42+
fi
43+
else
44+
# If file is in a example folder but it is not a sketch, find all sketches in the current directory
45+
echo "File in example folder found: $file"
46+
sketch=$(find $(dirname $file) -name *.ino)
47+
sketches+="$sketch "
48+
echo "Sketch in example folder: $sketch"
49+
fi
50+
echo ""
51+
done
5252
fi
5353

5454
if [[ -n $sketches ]]; then
55-
# Remove duplicates
56-
sketches=$(echo $sketches | tr ' ' '\n' | sort | uniq)
57-
for sketch in $sketches; do
58-
echo $sketch >> sketches_found.txt
59-
chunks_count=$((chunks_count+1))
60-
done
61-
echo "Number of sketches found: $chunks_count"
62-
echo "Sketches:"
63-
echo "$sketches"
55+
# Remove duplicates
56+
sketches=$(echo $sketches | tr ' ' '\n' | sort | uniq)
57+
for sketch in $sketches; do
58+
echo $sketch >> sketches_found.txt
59+
chunks_count=$((chunks_count+1))
60+
done
61+
echo "Number of sketches found: $chunks_count"
62+
echo "Sketches:"
63+
echo "$sketches"
6464

65-
if [[ $chunks_count -gt $MAX_CHUNKS ]]; then
66-
echo "More sketches than the allowed number of chunks found. Limiting to $MAX_CHUNKS chunks."
67-
chunks_count=$MAX_CHUNKS
68-
fi
65+
if [[ $chunks_count -gt $MAX_CHUNKS ]]; then
66+
echo "More sketches than the allowed number of chunks found. Limiting to $MAX_CHUNKS chunks."
67+
chunks_count=$MAX_CHUNKS
68+
fi
6969
fi
7070

7171
chunks='["0"'
7272
for i in $(seq 1 $(( $chunks_count - 1 )) ); do
73-
chunks+=",\"$i\""
73+
chunks+=",\"$i\""
7474
done
7575
chunks+="]"
7676

0 commit comments

Comments
 (0)