Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e403f0b

Browse files
authoredSep 30, 2024
ci(json): Add configuration requirements to ci.json files (espressif#10385)
* ci(json): Add support for checking sdkconfig before running tests * docs(ci): Add explanation about requires field in JSON * fix(json): Ignore comments when searching requirements * feat(json): Add extended regex support to requires field * change(json): Move to using requirements in JSON * fix(json): Fix requirements for touch tests * refactor(json): Fix formatting of JSON files * fix(spi): Fix SPI example and JSON
1 parent 1f1de27 commit e403f0b

File tree

169 files changed

+654
-688
lines changed

Some content is hidden

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

169 files changed

+654
-688
lines changed
 

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

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ PLATFORMIO_ESP32_URL="https://github.com/platformio/platform-espressif32.git"
66
TOOLCHAIN_VERSION="12.2.0+20230208"
77
ESPTOOLPY_VERSION="~1.40501.0"
88
ESPRESSIF_ORGANIZATION_NAME="espressif"
9+
LIBS_DIR="tools/esp32-arduino-libs"
910

1011
echo "Installing Python Wheel ..."
1112
pip install wheel > /dev/null 2>&1
@@ -88,12 +89,25 @@ function count_sketches(){ # count_sketches <examples-path>
8889
local sketchname=$(basename $sketch)
8990
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
9091
continue
92+
elif [ -f $sketchdir/ci.json ]; then
93+
# If the target is listed as false, skip the sketch. Otherwise, include it.
94+
is_target=$(jq -r '.targets[esp32]' $sketchdir/ci.json)
95+
if [[ "$is_target" == "false" ]]; then
96+
continue
97+
fi
98+
99+
# Check if the sketch requires any configuration options
100+
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
101+
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
102+
for requirement in $requirements; do
103+
found_line=$(grep -E "^$requirement" $LIBS_DIR/esp32/sdkconfig)
104+
if [[ "$found_line" == "" ]]; then
105+
continue 2
106+
fi
107+
done
108+
fi
91109
fi
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
95-
continue
96-
fi
110+
97111
echo $sketch >> sketches.txt
98112
sketchnum=$(($sketchnum + 1))
99113
done
@@ -163,12 +177,27 @@ function build_pio_sketches(){ # build_pio_sketches <board> <options> <examples-
163177
local sketchdir=$(dirname $sketch)
164178
local sketchdirname=$(basename $sketchdir)
165179
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.
168-
if [ "${sketchdirname}.ino" != "$sketchname" ] \
169-
|| [[ "$is_target" == "false" ]]; then
180+
if [[ "$sketchdirname.ino" != "$sketchname" ]]; then
170181
continue
182+
elif [ -f $sketchdir/ci.json ]; then
183+
# If the target is listed as false, skip the sketch. Otherwise, include it.
184+
is_target=$(jq -r '.targets[esp32]' $sketchdir/ci.json)
185+
if [[ "$is_target" == "false" ]]; then
186+
continue
187+
fi
188+
189+
# Check if the sketch requires any configuration options
190+
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
191+
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
192+
for requirement in $requirements; do
193+
found_line=$(grep -E "^$requirement" $LIBS_DIR/esp32/sdkconfig)
194+
if [[ "$found_line" == "" ]]; then
195+
continue 2
196+
fi
197+
done
198+
fi
171199
fi
200+
172201
sketchnum=$(($sketchnum + 1))
173202
if [ "$sketchnum" -le "$start_index" ] \
174203
|| [ "$sketchnum" -gt "$end_index" ]; then

‎.github/scripts/sketch_utils.sh

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
LIBS_DIR="tools/esp32-arduino-libs"
4+
35
function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [extra-options]
46
while [ ! -z "$1" ]; do
57
case "$1" in
@@ -140,16 +142,25 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
140142

141143
sketchname=$(basename $sketchdir)
142144

143-
# If the target is listed as false, skip the sketch. Otherwise, include it.
144145
if [ -f $sketchdir/ci.json ]; then
146+
# If the target is listed as false, skip the sketch. Otherwise, include it.
145147
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
146-
else
147-
is_target="true"
148-
fi
148+
if [[ "$is_target" == "false" ]]; then
149+
echo "Skipping $sketchname for target $target"
150+
exit 0
151+
fi
149152

150-
if [[ "$is_target" == "false" ]]; then
151-
echo "Skipping $sketchname for target $target"
152-
exit 0
153+
# Check if the sketch requires any configuration options
154+
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
155+
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
156+
for requirement in $requirements; do
157+
found_line=$(grep -E "^$requirement" $LIBS_DIR/$target/sdkconfig)
158+
if [[ "$found_line" == "" ]]; then
159+
echo "Target $target does not meet the requirement $requirement for $sketchname. Skipping."
160+
exit 0
161+
fi
162+
done
163+
fi
153164
fi
154165

155166
ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp"
@@ -288,16 +299,23 @@ function count_sketches(){ # count_sketches <path> [target] [file]
288299
local sketchname=$(basename $sketch)
289300
if [[ "$sketchdirname.ino" != "$sketchname" ]]; then
290301
continue
291-
elif [[ -n $target ]]; then
302+
elif [[ -n $target ]] && [[ -f $sketchdir/ci.json ]]; then
292303
# 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
304+
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
298305
if [[ "$is_target" == "false" ]]; then
299306
continue
300307
fi
308+
309+
# Check if the sketch requires any configuration options
310+
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
311+
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
312+
for requirement in $requirements; do
313+
found_line=$(grep -E "^$requirement" $LIBS_DIR/$target/sdkconfig)
314+
if [[ "$found_line" == "" ]]; then
315+
continue 2
316+
fi
317+
done
318+
fi
301319
fi
302320
echo $sketch >> sketches.txt
303321
sketchnum=$(($sketchnum + 1))

0 commit comments

Comments
 (0)
Please sign in to comment.