Skip to content

Commit a1a9b99

Browse files
earlephilhowerdevyte
authored andcommitted
Add build_even/odd types to split Arduino tests (#4737)
Arduino builds are now taking 49 minutes or more, and failing due to Travis timeouts. Split the Arduino build task into even and odd half, where each job will build every other test. This will reduce any test's runtime by 50% and speed up checks to avoid the timeout.
1 parent 83ab034 commit a1a9b99

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ cache:
1010
matrix:
1111
include:
1212
- env:
13-
- BUILD_TYPE=build
13+
- BUILD_TYPE=build_even
14+
- env:
15+
- BUILD_TYPE=build_odd
1416
- env:
1517
- BUILD_TYPE=platformio
1618
- env:

tests/common.sh

+19-3
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,19 @@ function build_sketches()
3939
local srcpath=$2
4040
local build_arg=$3
4141
local build_dir=build.tmp
42+
local build_mod=$4
43+
local build_rem=$5
4244
mkdir -p $build_dir
4345
local build_cmd="python tools/build.py -b generic -v -w all -s 4M1M -v -k -p $PWD/$build_dir $build_arg "
44-
local sketches=$(find $srcpath -name *.ino)
46+
local sketches=$(find $srcpath -name *.ino | sort)
4547
print_size_info >size.log
4648
export ARDUINO_IDE_PATH=$arduino
49+
local testcnt=0
4750
for sketch in $sketches; do
51+
testcnt=$(( ($testcnt + 1) % $build_mod ))
52+
if [ $testcnt -ne $build_rem ]; then
53+
continue # Not ours to do
54+
fi
4855
rm -rf $build_dir/*
4956
local sketchdir=$(dirname $sketch)
5057
local sketchdirname=$(basename $sketchdir)
@@ -202,9 +209,12 @@ function install_arduino()
202209

203210
function build_sketches_with_arduino()
204211
{
212+
local build_mod=$1
213+
local build_rem=$2
214+
205215
# Compile sketches
206216
echo -e "travis_fold:start:sketch_test"
207-
build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR/libraries "-l $HOME/Arduino/libraries"
217+
build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR/libraries "-l $HOME/Arduino/libraries" $1 $2
208218
echo -e "travis_fold:end:sketch_test"
209219

210220
# Generate size report
@@ -239,7 +249,13 @@ fi
239249

240250
if [ "$BUILD_TYPE" = "build" ]; then
241251
install_arduino
242-
build_sketches_with_arduino
252+
build_sketches_with_arduino 1 0
253+
elif [ "$BUILD_TYPE" = "build_even" ]; then
254+
install_arduino
255+
build_sketches_with_arduino 2 0
256+
elif [ "$BUILD_TYPE" = "build_odd" ]; then
257+
install_arduino
258+
build_sketches_with_arduino 2 1
243259
elif [ "$BUILD_TYPE" = "platformio" ]; then
244260
# PlatformIO
245261
install_platformio

0 commit comments

Comments
 (0)