Skip to content

Commit c74f66f

Browse files
committed
ci(refactor): Refactor workflows and skip files
1 parent d45f35a commit c74f66f

File tree

534 files changed

+1859
-677
lines changed

Some content is hidden

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

534 files changed

+1859
-677
lines changed

Diff for: .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))

Diff for: .github/scripts/on-push.sh

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ fi
6969

7070
SCRIPTS_DIR="./.github/scripts"
7171
if [ "$BUILD_PIO" -eq 0 ]; then
72-
#source ${SCRIPTS_DIR}/install-arduino-ide.sh
7372
source ${SCRIPTS_DIR}/install-arduino-cli.sh
7473
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
7574

Diff for: .github/scripts/sketch_utils.sh

+36-19
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
@@ -270,12 +282,19 @@ function count_sketches(){ # count_sketches <path> [target]
270282
local sketchname=$(basename $sketch)
271283
if [[ "$sketchdirname.ino" != "$sketchname" ]]; then
272284
continue
273-
elif [[ -n $target ]] && [[ -f "$sketchdir/.skip.$target" ]]; then
274-
continue
275-
else
276-
echo $sketch >> sketches.txt
277-
sketchnum=$(($sketchnum + 1))
285+
elif [[ -n $target ]]; then
286+
# If the target is listed as false, skip the sketch. Otherwise, include it.
287+
if [ -f $sketchdir/ci.json ]; then
288+
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
289+
else
290+
is_target="true"
291+
fi
292+
if [[ "$is_target" == "false" ]]; then
293+
continue
294+
fi
278295
fi
296+
echo $sketch >> sketches.txt
297+
sketchnum=$(($sketchnum + 1))
279298
done
280299
return $sketchnum
281300
}
@@ -339,7 +358,7 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
339358
return 1
340359
fi
341360

342-
if [ "$chunk_index" -gt "$chunk_max" ] && [ "$chunk_max" -ge 2 ]; then
361+
if [ "$chunk_index" -gt "$chunk_max" ] && [ "$chunk_max" -ge 2 ]; then
343362
chunk_index=$chunk_max
344363
fi
345364

@@ -364,8 +383,6 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
364383
else
365384
start_index=$(( $chunk_index * $chunk_size ))
366385
if [ "$sketchcount" -le "$start_index" ]; then
367-
echo "Skipping job"
368-
touch ~/.build_skipped
369386
return 0
370387
fi
371388

Diff for: .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"

Diff for: .github/scripts/tests_run.sh

+54-22
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,60 @@ function run_test() {
88
local sketchdir=$(dirname $sketch)
99
local sketchname=$(basename $sketchdir)
1010
local result=0
11+
local error=0
1112

12-
if [[ -f "$sketchdir/.skip.$platform" ]] || [[ -f "$sketchdir/.skip.$target" ]] || [[ -f "$sketchdir/.skip.$platform.$target" ]]; then
13-
echo "Skipping $sketchname test for $target, platform: $platform"
14-
skipfile="$sketchdir/.test_skipped"
15-
touch $skipfile
16-
exit 0
13+
# If the target or platform is listed as false, skip the sketch. Otherwise, include it.
14+
if [ -f $sketchdir/ci.json ]; then
15+
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
16+
selected_platform=$(jq -r --arg platform $platform '.platforms[$platform]' $sketchdir/ci.json)
17+
else
18+
is_target="true"
19+
selected_platform="true"
20+
fi
21+
22+
if [[ $is_target == "false" ]] || [[ $selected_platform == "false" ]]; then
23+
printf "\033[93mSkipping $sketchname test for $target, platform: $platform\033[0m\n"
24+
printf "\n\n\n"
25+
return 0
1726
fi
1827

19-
if [ $options -eq 0 ] && [ -f $sketchdir/cfg.json ]; then
20-
len=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn | length' $sketchdir/cfg.json`
28+
if [ $options -eq 0 ] && [ -f $sketchdir/ci.json ]; then
29+
len=`jq -r --arg target $target '.fqbn[$target] | length' $sketchdir/ci.json`
30+
if [ $len -eq 0 ]; then
31+
len=1
32+
fi
2133
else
2234
len=1
2335
fi
2436

2537
if [ $len -eq 1 ]; then
2638
# build_dir="$sketchdir/build"
2739
build_dir="$HOME/.arduino/tests/$sketchname/build.tmp"
28-
report_file="$sketchdir/$sketchname.xml"
40+
report_file="$sketchdir/$target/$sketchname.xml"
2941
fi
3042

3143
for i in `seq 0 $(($len - 1))`
3244
do
33-
echo "Running test: $sketchname -- Config: $i"
45+
fqbn="Default"
46+
47+
if [ $len -ne 1 ]; then
48+
fqbn=`jq -r --arg target $target --argjson i $i '.fqbn[$target] | sort | .[$i]' $sketchdir/ci.json`
49+
elif [ -f $sketchdir/ci.json ]; then
50+
has_fqbn=`jq -r --arg target $target '.fqbn[$target]' $sketchdir/ci.json`
51+
if [ "$has_fqbn" != "null" ]; then
52+
fqbn=`jq -r --arg target $target '.fqbn[$target] | .[0]' $sketchdir/ci.json`
53+
fi
54+
fi
55+
56+
printf "\033[95mRunning test: $sketchname -- Config: $fqbn\033[0m\n"
3457
if [ $erase_flash -eq 1 ]; then
3558
esptool.py -c $target erase_flash
3659
fi
3760

3861
if [ $len -ne 1 ]; then
3962
# build_dir="$sketchdir/build$i"
4063
build_dir="$HOME/.arduino/tests/$sketchname/build$i.tmp"
41-
report_file="$sketchdir/$sketchname$i.xml"
64+
report_file="$sketchdir/$target/$sketchname$i.xml"
4265
fi
4366

4467
if [ $platform == "wokwi" ]; then
@@ -55,27 +78,31 @@ function run_test() {
5578
elif [ $target == "esp32c3" ]; then
5679
extra_args+=" --qemu-prog-path qemu-system-riscv32 --qemu-cli-args=\"-machine $target -icount 3 -nographic\""
5780
else
58-
echo "Unsupported QEMU target: $target"
81+
printf "\033[91mUnsupported QEMU target: $target\033[0m\n"
5982
exit 1
6083
fi
6184
else
6285
extra_args="--embedded-services esp,arduino"
6386
fi
6487

6588
result=0
66-
echo "pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args"
89+
printf "\033[95mpytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args\033[0m\n"
6790
bash -c "set +e; pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args; exit \$?" || result=$?
68-
result=$?
91+
printf "\n"
6992
if [ $result -ne 0 ]; then
7093
result=0
71-
echo "Retrying test: $sketchname -- Config: $i"
94+
printf "\033[95mRetrying test: $sketchname -- Config: $i\033[0m\n"
95+
printf "\033[95mpytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args\033[0m\n"
7296
bash -c "set +e; pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args; exit \$?" || result=$?
97+
printf "\n"
7398
result=$?
7499
if [ $result -ne 0 ]; then
75-
exit $result
100+
error=$result
76101
fi
77102
fi
78103
done
104+
printf "\n"
105+
return $error
79106
}
80107

81108
SCRIPTS_DIR="./.github/scripts"
@@ -92,14 +119,14 @@ while [ ! -z "$1" ]; do
92119
-c )
93120
chunk_run=1
94121
;;
95-
-q )
122+
-Q )
96123
if [ ! -d $QEMU_PATH ]; then
97124
echo "QEMU path $QEMU_PATH does not exist"
98125
exit 1
99126
fi
100127
platform="qemu"
101128
;;
102-
-w )
129+
-W )
103130
shift
104131
wokwi_timeout=$1
105132
platform="wokwi"
@@ -165,6 +192,7 @@ if [ $chunk_run -eq 0 ]; then
165192
exit 1
166193
fi
167194
run_test $target $test_folder/$sketch/$sketch.ino $options $erase
195+
exit $?
168196
else
169197
if [ "$chunk_max" -le 0 ]; then
170198
echo "ERROR: Chunks count must be positive number"
@@ -197,8 +225,6 @@ else
197225
else
198226
start_index=$(( $chunk_index * $chunk_size ))
199227
if [ "$sketchcount" -le "$start_index" ]; then
200-
echo "Skipping job"
201-
touch $PWD/tests/.test_skipped
202228
exit 0
203229
fi
204230

@@ -210,6 +236,7 @@ else
210236

211237
start_num=$(( $start_index + 1 ))
212238
sketchnum=0
239+
error=0
213240

214241
for sketch in $sketches; do
215242

@@ -218,9 +245,14 @@ else
218245
|| [ "$sketchnum" -gt "$end_index" ]; then
219246
continue
220247
fi
221-
echo ""
222-
echo "Sketch Index $(($sketchnum - 1))"
223248

224-
run_test $target $sketch $options $erase
249+
printf "\033[95mSketch Index $(($sketchnum - 1))\033[0m\n"
250+
251+
exit_code=0
252+
run_test $target $sketch $options $erase || exit_code=$?
253+
if [ $exit_code -ne 0 ]; then
254+
error=$exit_code
255+
fi
225256
done
257+
exit $error
226258
fi

Diff for: .github/scripts/upload_py_tools.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/bash
22
CHANGED_FILES=$1
3-
echo "Pushing '$CHANGED_FILES' as $GITHUB_ACTOR"
4-
git config --global github.user "$GITHUB_ACTOR"
5-
git config --global user.name "$GITHUB_ACTOR"
6-
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
3+
echo "Pushing '$CHANGED_FILES' as github-actions[bot]"
4+
git config --global github.user "github-actions[bot]"
5+
git config --global user.name "github-actions[bot]"
6+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
77
for tool in $CHANGED_FILES; do
88
git add tools/$tool.exe
99
done
10-
git commit -m "Push binary to tools"
10+
git commit -m "change(tools): Push generated binaries to PR"
1111
git push

Diff for: .github/workflows/boards.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: Boards Test
33
# The workflow will run on schedule and labeled pull requests
44
on:
55
pull_request:
6+
paths:
7+
- 'boards.txt'
8+
- 'libraries/ESP32/examples/CI/CIBoardsTest/CIBoardsTest.ino'
9+
- '.github/workflows/boards.yml'
610

711
env:
812
# It's convenient to set variables for values used multiple times in the workflow
@@ -24,7 +28,7 @@ jobs:
2428
uses: dcarbone/[email protected]
2529

2630
- name: Get board name
27-
run:
31+
run:
2832
bash .github/scripts/find_new_boards.sh ${{ github.repository }} ${{github.event.number}}
2933

3034
test-boards:

Diff for: .github/workflows/build_py_tools.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ jobs:
8989
- name: Checkout repository
9090
uses: actions/checkout@v4
9191
with:
92+
token: ${{ secrets.TOOLS_UPLOAD_PAT }}
9293
ref: ${{ github.event.pull_request.head.ref }}
9394
- name: Set up Python 3.8
9495
# Skip setting python on ARM because of missing compatibility: https://github.com/actions/setup-python/issues/108
@@ -107,7 +108,7 @@ jobs:
107108
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=.github/pytools/espressif.ico tools/$tool.py
108109
done
109110
- name: Sign binaries
110-
if: matrix.os == 'windows-latest'
111+
if: matrix.os == 'windows-latest' && env.CERTIFICATE != '' && env.CERTIFICATE_PASSWORD != ''
111112
env:
112113
CERTIFICATE: ${{ secrets.CERTIFICATE }}
113114
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}

0 commit comments

Comments
 (0)