Skip to content

Commit 113f24e

Browse files
committed
feat(json): Add extended regex support to requires field
1 parent 66e74ed commit 113f24e

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function count_sketches(){ # count_sketches <examples-path>
100100
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
101101
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
102102
for requirement in $requirements; do
103-
found_line=$(grep "^$requirement" $LIBS_DIR/esp32/sdkconfig)
103+
found_line=$(grep -E "^$requirement" $LIBS_DIR/esp32/sdkconfig)
104104
if [[ "$found_line" == "" ]]; then
105105
continue 2
106106
fi
@@ -190,7 +190,7 @@ function build_pio_sketches(){ # build_pio_sketches <board> <options> <examples-
190190
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
191191
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
192192
for requirement in $requirements; do
193-
found_line=$(grep "^$requirement" $LIBS_DIR/esp32/sdkconfig)
193+
found_line=$(grep -E "^$requirement" $LIBS_DIR/esp32/sdkconfig)
194194
if [[ "$found_line" == "" ]]; then
195195
continue 2
196196
fi

.github/scripts/sketch_utils.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
154154
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
155155
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
156156
for requirement in $requirements; do
157-
found_line=$(grep "^$requirement" $LIBS_DIR/$target/sdkconfig)
157+
found_line=$(grep -E "^$requirement" $LIBS_DIR/$target/sdkconfig)
158158
if [[ "$found_line" == "" ]]; then
159159
echo "Target $target does not meet the requirement $requirement for $sketchname. Skipping."
160160
exit 0
@@ -310,7 +310,7 @@ function count_sketches(){ # count_sketches <path> [target] [file]
310310
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
311311
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
312312
for requirement in $requirements; do
313-
found_line=$(grep "^$requirement" $LIBS_DIR/$target/sdkconfig)
313+
found_line=$(grep -E "^$requirement" $LIBS_DIR/$target/sdkconfig)
314314
if [[ "$found_line" == "" ]]; then
315315
continue 2
316316
fi

.github/scripts/tests_run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function run_test() {
2525
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
2626
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
2727
for requirement in $requirements; do
28-
found_line=$(grep "^$requirement" $LIBS_DIR/$target/sdkconfig)
28+
found_line=$(grep -E "^$requirement" $LIBS_DIR/$target/sdkconfig)
2929
if [[ "$found_line" == "" ]]; then
3030
printf "\033[93mTarget $target does not meet the requirement $requirement for $sketchname. Skipping.\033[0m\n"
3131
printf "\n\n\n"

docs/en/contributing.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ Testing
110110
*******
111111

112112
Be sure you have tested the example in all the supported targets. If the example some specific hardware requirements,
113-
edit/add the ``ci.json`` in the same folder as the sketch to specify the required configurations from ``sdkconfig``.
113+
edit/add the ``ci.json`` in the same folder as the sketch to specify the regular expression for the
114+
required configurations from ``sdkconfig``.
114115
This will ensure that the CI system will run the test only on the targets that have the required configurations.
116+
115117
You can check the available configurations in the ``sdkconfig`` file in the ``tools/esp32-arduino-libs/<target>`` folder.
116118

117119
Here is an example of the ``ci.json`` file where the example requires Wi-Fi to work properly:
@@ -129,6 +131,9 @@ Here is an example of the ``ci.json`` file where the example requires Wi-Fi to w
129131
The list of configurations will be checked against the ``sdkconfig`` file in the target folder. If the configuration is not present in the ``sdkconfig``,
130132
the test will be skipped for that target. That means that the test will only run on the targets that have **ALL** the required configurations.
131133

134+
Also, by default, the "match start of line" character (``^``) will be added to the beginning of each configuration.
135+
That means that the configuration must be at the beginning of the line in the ``sdkconfig`` file.
136+
132137
Sometimes, the example might not be supported by some target, even if the target has the required configurations
133138
(like resources limitations or requiring a specific SoC). To avoid compilation errors, you can add the target to the ``ci.json``
134139
file so the CI system will force to skip the test on that target.

0 commit comments

Comments
 (0)