Skip to content

Commit bde5e31

Browse files
committed
Merge branch 'ci/tests_refactor'
2 parents 6adeca4 + a000fb6 commit bde5e31

File tree

509 files changed

+1406
-474
lines changed

Some content is hidden

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

509 files changed

+1406
-474
lines changed

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

Lines changed: 6 additions & 2 deletions
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/sketch_utils.sh

Lines changed: 32 additions & 15 deletions
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,24 +65,28 @@ 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"
86+
esp32_opts="PSRAM=enabled,PartitionScheme=huge_app"
8287
esp32s2_opts="PSRAM=enabled,PartitionScheme=huge_app"
8388
esp32s3_opts="PSRAM=opi,USBMode=default,PartitionScheme=huge_app"
84-
esp32c3_opts="FlashMode=dio,PartitionScheme=huge_app"
89+
esp32c3_opts="PartitionScheme=huge_app"
8590
esp32c6_opts="PartitionScheme=huge_app"
8691
esp32h2_opts="PartitionScheme=huge_app"
8792

@@ -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

.github/scripts/tests_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fi
7272

7373
if [ $chunk_build -eq 1 ]; then
7474
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh chunk_build"
75-
args+=" -p $test_folder"
75+
args+=" -p $test_folder -i 0 -m 1"
7676
else
7777
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh build"
7878
args+=" -s $test_folder/$sketch"

.github/scripts/tests_run.sh

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,25 @@ function run_test() {
88
local sketchdir=$(dirname $sketch)
99
local sketchname=$(basename $sketchdir)
1010

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

18-
if [ $options -eq 0 ] && [ -f $sketchdir/cfg.json ]; then
19-
len=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn | length' $sketchdir/cfg.json`
25+
if [ $options -eq 0 ] && [ -f $sketchdir/ci.json ]; then
26+
len=`jq -r --arg target $target '.fqbn[$target] | length' $sketchdir/ci.json`
27+
if [ $len -eq 0 ]; then
28+
len=1
29+
fi
2030
else
2131
len=1
2232
fi
@@ -29,7 +39,18 @@ function run_test() {
2939

3040
for i in `seq 0 $(($len - 1))`
3141
do
32-
echo "Running test: $sketchname -- Config: $i"
42+
fqbn="Default"
43+
44+
if [ $len -ne 1 ]; then
45+
fqbn=`jq -r --arg target $target --argjson i $i '.fqbn[$target] | sort | .[$i]' $sketchdir/ci.json`
46+
elif [ -f $sketchdir/ci.json ]; then
47+
has_fqbn=`jq -r --arg target $target '.fqbn[$target]' $sketchdir/ci.json`
48+
if [ "$has_fqbn" != "null" ]; then
49+
fqbn=`jq -r --arg target $target '.fqbn[$target] | .[0]' $sketchdir/ci.json`
50+
fi
51+
fi
52+
53+
echo "Running test: $sketchname -- Config: $fqbn"
3354
if [ $erase_flash -eq 1 ]; then
3455
esptool.py -c $target erase_flash
3556
fi
@@ -84,14 +105,14 @@ while [ ! -z "$1" ]; do
84105
-c )
85106
chunk_run=1
86107
;;
87-
-q )
108+
-Q )
88109
if [ ! -d $QEMU_PATH ]; then
89110
echo "QEMU path $QEMU_PATH does not exist"
90111
exit 1
91112
fi
92113
platform="qemu"
93114
;;
94-
-w )
115+
-W )
95116
shift
96117
wokwi_timeout=$1
97118
platform="wokwi"
@@ -189,8 +210,6 @@ else
189210
else
190211
start_index=$(( $chunk_index * $chunk_size ))
191212
if [ "$sketchcount" -le "$start_index" ]; then
192-
echo "Skipping job"
193-
touch $PWD/tests/.test_skipped
194213
exit 0
195214
fi
196215

.github/workflows/build_tests.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
chip:
5+
required: true
6+
type: string
7+
type:
8+
required: true
9+
type: string
10+
ref:
11+
required: true
12+
type: string
13+
14+
concurrency:
15+
group: tests-build-${{ inputs.ref }}-${{ inputs.chip }}-${{ inputs.type }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build-tests:
20+
name: Build ${{ inputs.type }} tests for ${{ inputs.chip }}
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout Repository
24+
uses: actions/checkout@v4
25+
26+
- name: Build sketches
27+
run: |
28+
bash .github/scripts/tests_build.sh -c -type ${{ inputs.type }} -t ${{ inputs.chip }}
29+
30+
- name: Upload ${{ inputs.chip }}-${{ inputs.type }} artifacts
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: ${{ inputs.chip }}-${{ inputs.type }}.artifacts
34+
if-no-files-found: error
35+
path: |
36+
~/.build_skipped
37+
~/.arduino/tests/**/build*.tmp/*.bin
38+
~/.arduino/tests/**/build*.tmp/*.elf
39+
~/.arduino/tests/**/build*.tmp/*.json

0 commit comments

Comments
 (0)