Skip to content

Commit 3ad6ea7

Browse files
committed
changed json format and removed moving the file
1 parent 8c32460 commit 3ad6ea7

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

.github/scripts/on-push.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,22 @@ if [ "$BUILD_PIO" -eq 0 ]; then
7777
$ARDUINO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino\
7878
$ARDUINO_ESP32_PATH/libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics.ino\
7979
"
80+
#create sizes_file and echo start of JSON array with "boards" key
81+
sizes_file="$GITHUB_WORKSPACE/cli_compile_$CHUNK_INDEX.json"
82+
echo "{\"boards\": [" > $sizes_file
8083

84+
#build sketches for different targets
8185
build "esp32s3" $FQBN_ESP32S3 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
8286
build "esp32s2" $FQBN_ESP32S2 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
8387
build "esp32c3" $FQBN_ESP32C3 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
8488
build "esp32c6" $FQBN_ESP32C6 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
8589
build "esp32h2" $FQBN_ESP32H2 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
8690
build "esp32" $FQBN_ESP32 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
8791

88-
sizes_file="$HOME/.arduino/cli_compile_output.json"
89-
#rename sizes_file="$HOME/.arduino/cli_compile_output.json" to sizes_file="GITHUB_WORKSPACE/cli_compile_output_${chunk_index}.json"
90-
echo "Listings of $HOME/.arduino"
91-
ls $HOME/.arduino
92-
mv $sizes_file "$GITHUB_WORKSPACE/cli_compile_$CHUNK_INDEX.json"
93-
echo "Listings of $GITHUB_WORKSPACE"
94-
ls $GITHUB_WORKSPACE
92+
#remove last comma from the last JSON object
93+
sed -i '' -e '$ s/,$//' $sizes_file
94+
#echo end of JSON array
95+
echo "]}" >> $sizes_file
9596

9697
else
9798
source ${SCRIPTS_DIR}/install-platformio-esp32.sh

.github/scripts/sketch_utils.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
141141
fi
142142

143143
log_file="$HOME/.arduino/cli_compile_output.txt"
144-
sizes_file="$HOME/.arduino/cli_compile_output.json"
144+
sizes_file="$GITHUB_WORKSPACE/cli_compile_$CHUNK_INDEX.json"
145+
146+
#echo board,target and start of sketches to sizes_file json
147+
echo "{ \"board\": \"$fqbn\",
148+
\"target\": \"$target\",
149+
\"sketches\": [" >> "$sizes_file"
145150

146151
mkdir -p "$ARDUINO_CACHE_DIR"
147152
for i in `seq 0 $(($len - 1))`
@@ -182,16 +187,28 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
182187
ram_bytes=$(grep -oE 'Global variables use ([0-9]+) bytes' $log_file | awk '{print $4}')
183188
ram_percentage=$(grep -oE 'Global variables use ([0-9]+) bytes \(([0-9]+)%\)' $log_file | awk '{print $6}' | tr -d '(%)')
184189

190+
# Define the constant part
191+
constant_path="$HOME/Arduino/hardware/espressif/esp32/libraries/"
192+
193+
# Extract the desired substring using awk
194+
lib_sketch_name=$(echo "$sketch" | sed "s|$constant_part\([^/]*\)/.*|\1|")
195+
196+
# Print the extracted substring
197+
echo "Extracted Path: $lib_sketch_name"
198+
185199
#append json file where key is fqbn, sketch name, sizes -> extracted values
186-
echo "{\"fqbn\": \"$fqbn\",
187-
\"sketch\": \"$sketch\",
200+
echo "{\"name\": \"$lib_sketch_name\",
188201
\"sizes\": {
189202
\"flash_bytes\": $flash_bytes,
190203
\"flash_percentage\": $flash_percentage,
191204
\"ram_bytes\": $ram_bytes,
192205
\"ram_percentage\": $ram_percentage
193206
}
194-
}" >> "$sizes_file"
207+
}," >> "$sizes_file"
208+
#if i is the last index of the loop, remove the last comma
209+
if [ $i -eq $(($len - 1)) ]; then
210+
sed -i '$ s/.$//' "$sizes_file"
211+
fi
195212

196213
elif [ -f "$ide_path/arduino-builder" ]; then
197214
echo "Building $sketchname with arduino-builder and FQBN=$currfqbn"
@@ -226,6 +243,12 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
226243
# $xtra_opts "${sketchdir}/${sketchname}.ino"
227244
fi
228245
done
246+
247+
#echo end of sketches sizes_file json
248+
echo "]}" >> "$sizes_file"
249+
#echo end of board sizes_file json
250+
echo "}," >> "$sizes_file"
251+
229252
unset fqbn
230253
unset xtra_opts
231254
unset options

.github/workflows/push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050

5151
#Upload cli compile json as artifact
5252
- name: Upload cli compile json
53-
uses: actions/upload-artifact@v2
53+
uses: actions/upload-artifact@v4
5454
with:
5555
name: cli_compile_${{ matrix.chunk }}
5656
path: cli_compile_${{ matrix.chunk }}.json

0 commit comments

Comments
 (0)