Skip to content

Commit 4ca635a

Browse files
authored
ci(json): Add requires_any field and use QIO by default to match IDE (#10472)
* ci(FQBN): Use QIO as default as DIO can be used on demand now * fix(indentation): Fix default indentation for bash files * fix(compilation): Make errors appear on CI fail * ci(json): Add requires_any field to JSON and fix comparison
1 parent 064d1c4 commit 4ca635a

File tree

5 files changed

+130
-32
lines changed

5 files changed

+130
-32
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ indent_size = 2
1818
indent_style = space
1919

2020
[*.{bash,sh}]
21-
indent_size = 2
21+
indent_size = 4
2222
indent_style = space
2323

2424
[*.{c,cc,cp,cpp,cxx,h,hh,hpp,hxx,ii,inl,ino,ixx,pde,tpl,tpp,txx}]

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

+38-4
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ function count_sketches(){ # count_sketches <examples-path>
9696
continue
9797
fi
9898

99-
# Check if the sketch requires any configuration options
99+
# Check if the sketch requires any configuration options (AND)
100100
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
101-
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
101+
if [[ "$requirements" != "null" && "$requirements" != "" ]]; then
102102
for requirement in $requirements; do
103103
requirement=$(echo $requirement | xargs)
104104
found_line=$(grep -E "^$requirement" "$SDKCONFIG_DIR/esp32/sdkconfig")
@@ -107,6 +107,23 @@ function count_sketches(){ # count_sketches <examples-path>
107107
fi
108108
done
109109
fi
110+
111+
# Check if the sketch requires any configuration options (OR)
112+
requirements_or=$(jq -r '.requires_any[]? // empty' $sketchdir/ci.json)
113+
if [[ "$requirements_or" != "null" && "$requirements_or" != "" ]]; then
114+
found=false
115+
for requirement in $requirements_or; do
116+
requirement=$(echo $requirement | xargs)
117+
found_line=$(grep -E "^$requirement" "$SDKCONFIG_DIR/esp32/sdkconfig")
118+
if [[ "$found_line" != "" ]]; then
119+
found=true
120+
break
121+
fi
122+
done
123+
if [[ "$found" == "false" ]]; then
124+
continue
125+
fi
126+
fi
110127
fi
111128

112129
echo $sketch >> sketches.txt
@@ -187,9 +204,9 @@ function build_pio_sketches(){ # build_pio_sketches <board> <options> <examples-
187204
continue
188205
fi
189206

190-
# Check if the sketch requires any configuration options
207+
# Check if the sketch requires any configuration options (AND)
191208
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
192-
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
209+
if [[ "$requirements" != "null" && "$requirements" != "" ]]; then
193210
for requirement in $requirements; do
194211
requirement=$(echo $requirement | xargs)
195212
found_line=$(grep -E "^$requirement" "$SDKCONFIG_DIR/esp32/sdkconfig")
@@ -198,6 +215,23 @@ function build_pio_sketches(){ # build_pio_sketches <board> <options> <examples-
198215
fi
199216
done
200217
fi
218+
219+
# Check if the sketch requires any configuration options (OR)
220+
requirements_or=$(jq -r '.requires_any[]? // empty' $sketchdir/ci.json)
221+
if [[ "$requirements_or" != "null" && "$requirements_or" != "" ]]; then
222+
found=false
223+
for requirement in $requirements_or; do
224+
requirement=$(echo $requirement | xargs)
225+
found_line=$(grep -E "^$requirement" "$SDKCONFIG_DIR/esp32/sdkconfig")
226+
if [[ "$found_line" != "" ]]; then
227+
found=true
228+
break
229+
fi
230+
done
231+
if [[ "$found" == "false" ]]; then
232+
continue
233+
fi
234+
fi
201235
fi
202236

203237
sketchnum=$(($sketchnum + 1))

.github/scripts/sketch_utils.sh

+61-18
Original file line numberDiff line numberDiff line change
@@ -98,34 +98,42 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
9898

9999
# Default FQBN options if none were passed in the command line.
100100

101-
esp32_opts="PSRAM=enabled,FlashMode=dio${fqbn_append:+,$fqbn_append}"
102-
esp32s2_opts="PSRAM=enabled,FlashMode=dio${fqbn_append:+,$fqbn_append}"
103-
esp32s3_opts="PSRAM=opi,USBMode=default,FlashMode=dio${fqbn_append:+,$fqbn_append}"
104-
esp32c3_opts="FlashMode=dio${fqbn_append:+,$fqbn_append}"
105-
esp32c6_opts="FlashMode=dio${fqbn_append:+,$fqbn_append}"
106-
esp32h2_opts="FlashMode=dio${fqbn_append:+,$fqbn_append}"
101+
esp32_opts="PSRAM=enabled${fqbn_append:+,$fqbn_append}"
102+
esp32s2_opts="PSRAM=enabled${fqbn_append:+,$fqbn_append}"
103+
esp32s3_opts="PSRAM=opi,USBMode=default${fqbn_append:+,$fqbn_append}"
104+
esp32c3_opts="$fqbn_append"
105+
esp32c6_opts="$fqbn_append"
106+
esp32h2_opts="$fqbn_append"
107107

108108
# Select the common part of the FQBN based on the target. The rest will be
109109
# appended depending on the passed options.
110110

111+
opt=""
112+
111113
case "$target" in
112114
"esp32")
113-
fqbn="espressif:esp32:esp32:${options:-$esp32_opts}"
115+
[ -n "${options:-$esp32_opts}" ] && opt=":${options:-$esp32_opts}"
116+
fqbn="espressif:esp32:esp32$opt"
114117
;;
115118
"esp32s2")
116-
fqbn="espressif:esp32:esp32s2:${options:-$esp32s2_opts}"
119+
[ -n "${options:-$esp32s2_opts}" ] && opt=":${options:-$esp32s2_opts}"
120+
fqbn="espressif:esp32:esp32s2$opt"
117121
;;
118122
"esp32c3")
119-
fqbn="espressif:esp32:esp32c3:${options:-$esp32c3_opts}"
123+
[ -n "${options:-$esp32c3_opts}" ] && opt=":${options:-$esp32c3_opts}"
124+
fqbn="espressif:esp32:esp32c3$opt"
120125
;;
121126
"esp32s3")
122-
fqbn="espressif:esp32:esp32s3:${options:-$esp32s3_opts}"
127+
[ -n "${options:-$esp32s3_opts}" ] && opt=":${options:-$esp32s3_opts}"
128+
fqbn="espressif:esp32:esp32s3$opt"
123129
;;
124130
"esp32c6")
125-
fqbn="espressif:esp32:esp32c6:${options:-$esp32c6_opts}"
131+
[ -n "${options:-$esp32c6_opts}" ] && opt=":${options:-$esp32c6_opts}"
132+
fqbn="espressif:esp32:esp32c6$opt"
126133
;;
127134
"esp32h2")
128-
fqbn="espressif:esp32:esp32h2:${options:-$esp32h2_opts}"
135+
[ -n "${options:-$esp32h2_opts}" ] && opt=":${options:-$esp32h2_opts}"
136+
fqbn="espressif:esp32:esp32h2$opt"
129137
;;
130138
esac
131139

@@ -163,9 +171,9 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
163171
exit 0
164172
fi
165173

166-
# Check if the sketch requires any configuration options
174+
# Check if the sketch requires any configuration options (AND)
167175
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
168-
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
176+
if [[ "$requirements" != "null" && "$requirements" != "" ]]; then
169177
for requirement in $requirements; do
170178
requirement=$(echo $requirement | xargs)
171179
found_line=$(grep -E "^$requirement" "$SDKCONFIG_DIR/$target/sdkconfig")
@@ -175,6 +183,24 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
175183
fi
176184
done
177185
fi
186+
187+
# Check if the sketch excludes any configuration options (OR)
188+
requirements_or=$(jq -r '.requires_any[]? // empty' $sketchdir/ci.json)
189+
if [[ "$requirements_or" != "null" && "$requirements_or" != "" ]]; then
190+
found=false
191+
for requirement in $requirements_or; do
192+
requirement=$(echo $requirement | xargs)
193+
found_line=$(grep -E "^$requirement" "$SDKCONFIG_DIR/$target/sdkconfig")
194+
if [[ "$found_line" != "" ]]; then
195+
found=true
196+
break
197+
fi
198+
done
199+
if [[ "$found" == "false" ]]; then
200+
echo "Target $target meets none of the requirements in requires_any for $sketchname. Skipping."
201+
exit 0
202+
fi
203+
fi
178204
fi
179205

180206
ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp"
@@ -213,9 +239,9 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
213239
--build-cache-path "$ARDUINO_CACHE_DIR" \
214240
--build-path "$build_dir" \
215241
$xtra_opts "${sketchdir}" \
216-
> $output_file
242+
2>&1 | tee $output_file
217243

218-
exit_status=$?
244+
exit_status=${PIPESTATUS[0]}
219245
if [ $exit_status -ne 0 ]; then
220246
echo "ERROR: Compilation failed with error code $exit_status"
221247
exit $exit_status
@@ -322,9 +348,9 @@ function count_sketches(){ # count_sketches <path> [target] [file] [ignore-requi
322348
fi
323349

324350
if [ "$ignore_requirements" != "1" ]; then
325-
# Check if the sketch requires any configuration options
351+
# Check if the sketch requires any configuration options (AND)
326352
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
327-
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
353+
if [[ "$requirements" != "null" && "$requirements" != "" ]]; then
328354
for requirement in $requirements; do
329355
requirement=$(echo $requirement | xargs)
330356
found_line=$(grep -E "^$requirement" $SDKCONFIG_DIR/$target/sdkconfig)
@@ -333,6 +359,23 @@ function count_sketches(){ # count_sketches <path> [target] [file] [ignore-requi
333359
fi
334360
done
335361
fi
362+
363+
# Check if the sketch excludes any configuration options (OR)
364+
requirements_or=$(jq -r '.requires_any[]? // empty' $sketchdir/ci.json)
365+
if [[ "$requirements_or" != "null" && "$requirements_or" != "" ]]; then
366+
found=false
367+
for requirement in $requirements_or; do
368+
requirement=$(echo $requirement | xargs)
369+
found_line=$(grep -E "^$requirement" $SDKCONFIG_DIR/$target/sdkconfig)
370+
if [[ "$found_line" != "" ]]; then
371+
found=true
372+
break
373+
fi
374+
done
375+
if [[ "$found" == "false" ]]; then
376+
continue 2
377+
fi
378+
fi
336379
fi
337380
fi
338381
echo $sketch >> sketches.txt

.github/scripts/tests_run.sh

+21-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ function run_test() {
3636
return 0
3737
fi
3838

39-
# Check if the sketch requires any configuration options
39+
# Check if the sketch requires any configuration options (AND)
4040
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
41-
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
41+
if [[ "$requirements" != "null" && "$requirements" != "" ]]; then
4242
for requirement in $requirements; do
4343
requirement=$(echo $requirement | xargs)
4444
found_line=$(grep -E "^$requirement" "$SDKCONFIG_PATH")
@@ -49,6 +49,25 @@ function run_test() {
4949
fi
5050
done
5151
fi
52+
53+
# Check if the sketch requires any configuration options (OR)
54+
requirements_or=$(jq -r '.requires_any[]? // empty' $sketchdir/ci.json)
55+
if [[ "$requirements_or" != "null" && "$requirements_or" != "" ]]; then
56+
found=false
57+
for requirement in $requirements_or; do
58+
requirement=$(echo $requirement | xargs)
59+
found_line=$(grep -E "^$requirement" "$SDKCONFIG_PATH")
60+
if [[ "$found_line" != "" ]]; then
61+
found=true
62+
break
63+
fi
64+
done
65+
if [[ "$found" == "false" ]]; then
66+
printf "\033[93mTarget $target meets none of the requirements in requires_any for $sketchname. Skipping.\033[0m\n"
67+
printf "\n\n\n"
68+
return 0
69+
fi
70+
fi
5271
fi
5372

5473
if [ $len -eq 1 ]; then

docs/en/contributing.rst

+9-7
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ And in the ``README.md`` file:
172172
By default, the CI system will use the FQBNs specified in the ``.github/scripts/sketch_utils.sh`` file to compile the sketches.
173173
Currently, the default FQBNs are:
174174

175-
* ``espressif:esp32:esp32:PSRAM=enabled,FlashMode=dio``
176-
* ``espressif:esp32:esp32s2:PSRAM=enabled,FlashMode=dio``
177-
* ``espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,FlashMode=dio``
178-
* ``espressif:esp32:esp32c3:FlashMode=dio``
179-
* ``espressif:esp32:esp32c6:FlashMode=dio``
180-
* ``espressif:esp32:esp32h2:FlashMode=dio``
175+
* ``espressif:esp32:esp32:PSRAM=enabled``
176+
* ``espressif:esp32:esp32s2:PSRAM=enabled``
177+
* ``espressif:esp32:esp32s3:PSRAM=opi,USBMode=default``
178+
* ``espressif:esp32:esp32c3``
179+
* ``espressif:esp32:esp32c6``
180+
* ``espressif:esp32:esp32h2``
181181

182182
There are two ways to alter the FQBNs used to compile the sketches: by using the ``fqbn`` or ``fqbn_append`` fields in the ``ci.json`` file.
183183

@@ -408,7 +408,9 @@ CI JSON File
408408
The ``ci.json`` file is used to specify how the test suite and sketches will handled by the CI system. It can contain the following fields:
409409

410410
* ``requires``: A list of configurations in ``sdkconfig`` that are required to run the test suite. The test suite will only run on the targets
411-
that have the required configurations. By default, no configurations are required.
411+
that have **ALL** the required configurations. By default, no configurations are required.
412+
* ``requires_any``: A list of configurations in ``sdkconfig`` that are required to run the test suite. The test suite will only run on the targets
413+
that have **ANY** of the required configurations. By default, no configurations are required.
412414
* ``targets``: A dictionary that specifies the targets for which the tests will be run. The key is the target name and the value is a boolean
413415
that specifies if the test should be run for that target. By default, all targets are enabled as long as they have the required configurations
414416
specified in the ``requires`` field. This field is also valid for examples.

0 commit comments

Comments
 (0)