Skip to content

Commit f5b8e27

Browse files
authored
ci(refactor): Refactor workflows and skip files (#9696)
* ci(refactor): Refactor workflows and skip files * ci(refactor): Refactor workflows and skip files * ci(refactor): Improvements and compilation of only related files * ci(refactor): Delete duplicated steps * ci(refactor): General improvements * ci(refactor): Delete duplicated lines * ci(refactor): Rename jobs
1 parent ebb77c4 commit f5b8e27

File tree

535 files changed

+2068
-699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

535 files changed

+2068
-699
lines changed

.github/scripts/install-platformio-esp32.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ function count_sketches(){ # count_sketches <examples-path>
8989
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
9090
continue
9191
fi
92-
if [[ -f "$sketchdir/.test.skip" ]]; then
92+
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
93+
# If the target is listed as false, skip the sketch. Otherwise, include it.
94+
if [[ "$is_target" == "false" ]]; then
9395
continue
9496
fi
9597
echo $sketch >> sketches.txt
@@ -161,8 +163,10 @@ function build_pio_sketches(){ # build_pio_sketches <board> <options> <examples-
161163
local sketchdir=$(dirname $sketch)
162164
local sketchdirname=$(basename $sketchdir)
163165
local sketchname=$(basename $sketch)
166+
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
167+
# If the target is listed as false, skip the sketch. Otherwise, include it.
164168
if [ "${sketchdirname}.ino" != "$sketchname" ] \
165-
|| [ -f "$sketchdir/.test.skip" ]; then
169+
|| [[ "$is_target" == "false" ]]; then
166170
continue
167171
fi
168172
sketchnum=$(($sketchnum + 1))

.github/scripts/on-push.sh

+12-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ function build(){
1010
local chunk_index=$3
1111
local chunks_cnt=$4
1212
local build_log=$5
13-
shift; shift; shift; shift; shift;
13+
local sketches_file=$6
14+
shift; shift; shift; shift; shift; shift;
1415
local sketches=$*
1516

1617
local BUILD_SKETCH="${SCRIPTS_DIR}/sketch_utils.sh build"
@@ -23,6 +24,9 @@ function build(){
2324
if [ "$OS_IS_LINUX" == "1" ]; then
2425
args+=" -p $ARDUINO_ESP32_PATH/libraries"
2526
args+=" -i $chunk_index -m $chunks_cnt"
27+
if [ -n "$sketches_file" ]; then
28+
args+=" -f $sketches_file"
29+
fi
2630
if [ $build_log -eq 1 ]; then
2731
args+=" -l $build_log"
2832
fi
@@ -50,6 +54,7 @@ fi
5054
CHUNK_INDEX=$1
5155
CHUNKS_CNT=$2
5256
BUILD_LOG=$3
57+
SKETCHES_FILE=$4
5358
BUILD_PIO=0
5459
if [ "$#" -lt 2 ] || [ "$CHUNKS_CNT" -le 0 ]; then
5560
CHUNK_INDEX=0
@@ -69,7 +74,6 @@ fi
6974

7075
SCRIPTS_DIR="./.github/scripts"
7176
if [ "$BUILD_PIO" -eq 0 ]; then
72-
#source ${SCRIPTS_DIR}/install-arduino-ide.sh
7377
source ${SCRIPTS_DIR}/install-arduino-cli.sh
7478
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
7579

@@ -95,12 +99,12 @@ if [ "$BUILD_PIO" -eq 0 ]; then
9599
fi
96100

97101
#build sketches for different targets
98-
build "esp32s3" $FQBN_ESP32S3 $CHUNK_INDEX $CHUNKS_CNT $BUILD_LOG $SKETCHES_ESP32
99-
build "esp32s2" $FQBN_ESP32S2 $CHUNK_INDEX $CHUNKS_CNT $BUILD_LOG $SKETCHES_ESP32
100-
build "esp32c3" $FQBN_ESP32C3 $CHUNK_INDEX $CHUNKS_CNT $BUILD_LOG $SKETCHES_ESP32
101-
build "esp32c6" $FQBN_ESP32C6 $CHUNK_INDEX $CHUNKS_CNT $BUILD_LOG $SKETCHES_ESP32
102-
build "esp32h2" $FQBN_ESP32H2 $CHUNK_INDEX $CHUNKS_CNT $BUILD_LOG $SKETCHES_ESP32
103-
build "esp32" $FQBN_ESP32 $CHUNK_INDEX $CHUNKS_CNT $BUILD_LOG $SKETCHES_ESP32
102+
build "esp32s3" $FQBN_ESP32S3 "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
103+
build "esp32s2" $FQBN_ESP32S2 "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
104+
build "esp32c3" $FQBN_ESP32C3 "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
105+
build "esp32c6" $FQBN_ESP32C6 "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
106+
build "esp32h2" $FQBN_ESP32H2 "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
107+
build "esp32" $FQBN_ESP32 "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
104108

105109
if [ "$BUILD_LOG" -eq 1 ]; then
106110
#remove last comma from the last JSON object

.github/scripts/sketch_utils.sh

+57-25
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
4343
done
4444

4545
xtra_opts=$*
46+
len=0
4647

4748
if [ -z $sketchdir ]; then
4849
echo "ERROR: Sketch directory not provided"
@@ -64,26 +65,30 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
6465
# precedence. Note that the following logic also falls to the default
6566
# parameters if no arguments were passed and no file was found.
6667

67-
if [ -z $options ] && [ -f $sketchdir/cfg.json ]; then
68+
if [ -z $options ] && [ -f $sketchdir/ci.json ]; then
6869
# The config file could contain multiple FQBNs for one chip. If
6970
# that's the case we build one time for every FQBN.
7071

71-
len=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn | length' $sketchdir/cfg.json`
72-
fqbn=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn' $sketchdir/cfg.json`
73-
else
72+
len=`jq -r --arg target $target '.fqbn[$target] | length' $sketchdir/ci.json`
73+
if [ $len -gt 0 ]; then
74+
fqbn=`jq -r --arg target $target '.fqbn[$target] | sort' $sketchdir/ci.json`
75+
fi
76+
fi
77+
78+
if [ ! -z $options ] || [ $len -eq 0 ]; then
7479
# Since we are passing options, we will end up with only one FQBN to
7580
# build.
7681

7782
len=1
7883

7984
# Default FQBN options if none were passed in the command line.
8085

81-
esp32_opts="FlashMode=dio,PSRAM=enabled,PartitionScheme=huge_app"
82-
esp32s2_opts="PSRAM=enabled,PartitionScheme=huge_app"
83-
esp32s3_opts="PSRAM=opi,USBMode=default,PartitionScheme=huge_app"
84-
esp32c3_opts="FlashMode=dio,PartitionScheme=huge_app"
85-
esp32c6_opts="PartitionScheme=huge_app"
86-
esp32h2_opts="PartitionScheme=huge_app"
86+
esp32_opts="PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio"
87+
esp32s2_opts="PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio"
88+
esp32s3_opts="PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=dio"
89+
esp32c3_opts="PartitionScheme=huge_app,FlashMode=dio"
90+
esp32c6_opts="PartitionScheme=huge_app,FlashMode=dio"
91+
esp32h2_opts="PartitionScheme=huge_app,FlashMode=dio"
8792

8893
# Select the common part of the FQBN based on the target. The rest will be
8994
# appended depending on the passed options.
@@ -135,7 +140,14 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
135140

136141
sketchname=$(basename $sketchdir)
137142

138-
if [[ -n $target ]] && [[ -f "$sketchdir/.skip.$target" ]]; then
143+
# If the target is listed as false, skip the sketch. Otherwise, include it.
144+
if [ -f $sketchdir/ci.json ]; then
145+
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
146+
else
147+
is_target="true"
148+
fi
149+
150+
if [[ "$is_target" == "false" ]]; then
139151
echo "Skipping $sketchname for target $target"
140152
exit 0
141153
fi
@@ -247,35 +259,48 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
247259
unset options
248260
}
249261

250-
function count_sketches(){ # count_sketches <path> [target]
262+
function count_sketches(){ # count_sketches <path> [target] [file]
251263
local path=$1
252264
local target=$2
265+
local file=$3
253266

254267
if [ $# -lt 1 ]; then
255268
echo "ERROR: Illegal number of parameters"
256269
echo "USAGE: ${0} count <path> [target]"
257270
fi
258271

259272
rm -rf sketches.txt
273+
touch sketches.txt
260274
if [ ! -d "$path" ]; then
261-
touch sketches.txt
262275
return 0
263276
fi
264277

265-
local sketches=$(find $path -name *.ino | sort)
278+
if [ -n "$file" ]; then
279+
local sketches=$(cat $file)
280+
else
281+
local sketches=$(find $path -name *.ino | sort)
282+
fi
283+
266284
local sketchnum=0
267285
for sketch in $sketches; do
268286
local sketchdir=$(dirname $sketch)
269287
local sketchdirname=$(basename $sketchdir)
270288
local sketchname=$(basename $sketch)
271289
if [[ "$sketchdirname.ino" != "$sketchname" ]]; then
272290
continue
273-
elif [[ -n $target ]] && [[ -f "$sketchdir/.skip.$target" ]]; then
274-
continue
275-
else
276-
echo $sketch >> sketches.txt
277-
sketchnum=$(($sketchnum + 1))
291+
elif [[ -n $target ]]; then
292+
# If the target is listed as false, skip the sketch. Otherwise, include it.
293+
if [ -f $sketchdir/ci.json ]; then
294+
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
295+
else
296+
is_target="true"
297+
fi
298+
if [[ "$is_target" == "false" ]]; then
299+
continue
300+
fi
278301
fi
302+
echo $sketch >> sketches.txt
303+
sketchnum=$(($sketchnum + 1))
279304
done
280305
return $sketchnum
281306
}
@@ -319,6 +344,10 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
319344
shift
320345
log_compilation=$1
321346
;;
347+
-f )
348+
shift
349+
sketches_file=$1
350+
;;
322351
* )
323352
break
324353
;;
@@ -328,7 +357,7 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
328357

329358
local xtra_opts=$*
330359

331-
if [ -z $chunk_index ] || [ -z $chunk_max ]; then
360+
if [ -z "$chunk_index" ] || [ -z "$chunk_max" ]; then
332361
echo "ERROR: Invalid chunk paramters"
333362
echo "$USAGE"
334363
exit 1
@@ -339,13 +368,18 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
339368
return 1
340369
fi
341370

342-
if [ "$chunk_index" -gt "$chunk_max" ] && [ "$chunk_max" -ge 2 ]; then
371+
if [ "$chunk_index" -gt "$chunk_max" ] && [ "$chunk_max" -ge 2 ]; then
343372
chunk_index=$chunk_max
344373
fi
345374

346375
set +e
347-
count_sketches "$path" "$target"
348-
local sketchcount=$?
376+
if [ -n "$sketches_file" ]; then
377+
count_sketches "$path" "$target" "$sketches_file"
378+
local sketchcount=$?
379+
else
380+
count_sketches "$path" "$target"
381+
local sketchcount=$?
382+
fi
349383
set -e
350384
local sketches=$(cat sketches.txt)
351385
rm -rf sketches.txt
@@ -364,8 +398,6 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
364398
else
365399
start_index=$(( $chunk_index * $chunk_size ))
366400
if [ "$sketchcount" -le "$start_index" ]; then
367-
echo "Skipping job"
368-
touch ~/.build_skipped
369401
return 0
370402
fi
371403

.github/scripts/tests_build.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ while [ ! -z "$1" ]; do
5151
shift
5252
done
5353

54-
#source ${SCRIPTS_DIR}/install-arduino-ide.sh
5554
source ${SCRIPTS_DIR}/install-arduino-cli.sh
5655
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
5756

@@ -72,7 +71,7 @@ fi
7271

7372
if [ $chunk_build -eq 1 ]; then
7473
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh chunk_build"
75-
args+=" -p $test_folder"
74+
args+=" -p $test_folder -i 0 -m 1"
7675
else
7776
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh build"
7877
args+=" -s $test_folder/$sketch"

0 commit comments

Comments
 (0)