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 1e66cec

Browse files
committedApr 28, 2024
ci(performance): Add performance tests to CI
1 parent cf44890 commit 1e66cec

Some content is hidden

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

49 files changed

+8246
-52
lines changed
 

‎.github/scripts/sketch_utils.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
7070

7171
len=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn | length' $sketchdir/cfg.json`
7272
fqbn=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn' $sketchdir/cfg.json`
73+
74+
# Skip if the target is not in the config file.
75+
if [ -z $fqbn ]; then
76+
echo "No FQBN found for chip: $target. Skipping."
77+
exit 0
78+
fi
7379
else
7480
# Since we are passing options, we will end up with only one FQBN to
7581
# build.
@@ -121,7 +127,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
121127
fi
122128

123129
if [ -z "$fqbn" ]; then
124-
echo "No FQBN passed or unvalid chip: $target"
130+
echo "No FQBN passed or invalid chip: $target"
125131
exit 1
126132
fi
127133

@@ -139,7 +145,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
139145
echo "Skipping $sketchname for target $target"
140146
exit 0
141147
fi
142-
148+
143149
ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp"
144150
if [ -n "$ARDUINO_BUILD_DIR" ]; then
145151
build_dir="$ARDUINO_BUILD_DIR"
@@ -177,7 +183,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
177183
--build-path "$build_dir" \
178184
$xtra_opts "${sketchdir}" \
179185
> $output_file
180-
186+
181187
exit_status=$?
182188
if [ $exit_status -ne 0 ]; then
183189
echo ""ERROR: Compilation failed with error code $exit_status""
@@ -198,11 +204,11 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
198204
# Extract the desired substring using sed
199205
lib_sketch_name=$(echo "$directory_path" | sed "s|$constant_part||")
200206
#append json file where key is fqbn, sketch name, sizes -> extracted values
201-
echo "{\"name\": \"$lib_sketch_name\",
207+
echo "{\"name\": \"$lib_sketch_name\",
202208
\"sizes\": [{
203-
\"flash_bytes\": $flash_bytes,
204-
\"flash_percentage\": $flash_percentage,
205-
\"ram_bytes\": $ram_bytes,
209+
\"flash_bytes\": $flash_bytes,
210+
\"flash_percentage\": $flash_percentage,
211+
\"ram_bytes\": $ram_bytes,
206212
\"ram_percentage\": $ram_percentage
207213
}]
208214
}," >> "$sizes_file"
@@ -386,7 +392,7 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
386392
if [ $log_compilation ]; then
387393
#echo board,target and start of sketches to sizes_file json
388394
echo "{ \"board\": \"$fqbn\",
389-
\"target\": \"$target\",
395+
\"target\": \"$target\",
390396
\"sketches\": [" >> "$sizes_file"
391397
fi
392398

‎.github/scripts/tests_build.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
USAGE="
44
USAGE:
5-
${0} -c <chunk_build_opts>
6-
Example: ${0} -c -t esp32 -i 0 -m 15
5+
${0} -c -type <test_type> <chunk_build_opts>
6+
Example: ${0} -c -type validation -t esp32 -i 0 -m 15
77
${0} -s sketch_name <build_opts>
88
Example: ${0} -s hello_world -t esp32
99
${0} -clean
1010
Remove build and test generated files
1111
"
1212

1313
function clean(){
14-
rm -rf tests/*/build*/
1514
rm -rf tests/.pytest_cache
16-
rm -rf tests/*/__pycache__/
17-
rm -rf tests/*/*.xml
15+
find tests/ -type d -name 'build*' -exec rm -rf "{}" \+
16+
find tests/ -type d -name '__pycache__' -exec rm -rf "{}" \+
17+
find tests/ -name '*.xml' -exec rm -rf "{}" \+
18+
find tests/ -name 'result_*.json' -exec rm -rf "{}" \+
1819
}
1920

2021
SCRIPTS_DIR="./.github/scripts"
@@ -35,6 +36,10 @@ while [ ! -z "$1" ]; do
3536
echo "$USAGE"
3637
exit 0
3738
;;
39+
-type )
40+
shift
41+
test_type=$1
42+
;;
3843
-clean )
3944
clean
4045
exit 0
@@ -52,12 +57,25 @@ source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
5257

5358
args="-ai $ARDUINO_IDE_PATH -au $ARDUINO_USR_PATH"
5459

60+
if [[ $test_type == "all" ]] || [[ -z $test_type ]]; then
61+
if [ -n "$sketch" ]; then
62+
tmp_sketch_path=$(find tests -name $sketch.ino)
63+
test_type=$(basename $(dirname $(dirname "$tmp_sketch_path")))
64+
echo "Sketch $sketch test type: $test_type"
65+
test_folder="$PWD/tests/$test_type"
66+
else
67+
test_folder="$PWD/tests"
68+
fi
69+
else
70+
test_folder="$PWD/tests/$test_type"
71+
fi
72+
5573
if [ $chunk_build -eq 1 ]; then
5674
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh chunk_build"
57-
args+=" -p $PWD/tests"
75+
args+=" -p $test_folder"
5876
else
5977
BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh build"
60-
args+=" -s $PWD/tests/$sketch"
78+
args+=" -s $test_folder/$sketch"
6179
fi
6280

6381
${BUILD_CMD} ${args} $*

0 commit comments

Comments
 (0)
Please sign in to comment.