Skip to content

Commit 187f6a5

Browse files
Androbinearlephilhower
authored andcommitted
Split common.sh into separate scripts for each job (#5569)
1 parent dc03293 commit 187f6a5

File tree

7 files changed

+195
-120
lines changed

7 files changed

+195
-120
lines changed

.travis.yml

+20-19
Original file line numberDiff line numberDiff line change
@@ -20,49 +20,50 @@ stages:
2020
jobs:
2121
include:
2222
# Build stage. To save time, run all kinds of builds and tests in parallel.
23-
# TODO: since we can now call different script for each job,
24-
# split the do-it-all common.sh into separate scripts responsible
25-
# for different types of jobs below:
23+
2624
- name: "Platformio (1)"
2725
stage: build
28-
script: $TRAVIS_BUILD_DIR/tests/common.sh
26+
script: $TRAVIS_BUILD_DIR/tests/platformio.sh
2927
env:
30-
- BUILD_TYPE=platformio_even
28+
- BUILD_PARITY=even
3129
- name: "Platformio (2)"
3230
stage: build
33-
script: $TRAVIS_BUILD_DIR/tests/common.sh
31+
script: $TRAVIS_BUILD_DIR/tests/platformio.sh
3432
env:
35-
- BUILD_TYPE=platformio_odd
33+
- BUILD_PARITY=odd
34+
3635
- name: "Build (1)"
3736
stage: build
38-
script: $TRAVIS_BUILD_DIR/tests/common.sh
37+
script: $TRAVIS_BUILD_DIR/tests/build.sh
3938
env:
40-
- BUILD_TYPE=build_even
39+
- BUILD_PARITY=even
4140
- name: "Build (2)"
4241
stage: build
43-
script: $TRAVIS_BUILD_DIR/tests/common.sh
42+
script: $TRAVIS_BUILD_DIR/tests/build.sh
4443
env:
45-
- BUILD_TYPE=build_odd
44+
- BUILD_PARITY=odd
45+
4646
- name: "Debug (1)"
4747
stage: build
48-
script: $TRAVIS_BUILD_DIR/tests/common.sh
48+
script: $TRAVIS_BUILD_DIR/tests/debug.sh
4949
env:
50-
- BUILD_TYPE=debug_even
50+
- BUILD_PARITY=even
5151
- name: "Debug (2)"
5252
stage: build
53-
script: $TRAVIS_BUILD_DIR/tests/common.sh
53+
script: $TRAVIS_BUILD_DIR/tests/debug.sh
5454
env:
55-
- BUILD_TYPE=debug_odd
55+
- BUILD_PARITY=odd
56+
5657
- name: "Build IPv6 (1)"
5758
stage: build
58-
script: $TRAVIS_BUILD_DIR/tests/common.sh
59+
script: $TRAVIS_BUILD_DIR/tests/build6.sh
5960
env:
60-
- BUILD_TYPE=build6_even
61+
- BUILD_PARITY=even
6162
- name: "Build IPv6 (2)"
6263
stage: build
63-
script: $TRAVIS_BUILD_DIR/tests/common.sh
64+
script: $TRAVIS_BUILD_DIR/tests/build6.sh
6465
env:
65-
- BUILD_TYPE=build6_odd
66+
- BUILD_PARITY=odd
6667

6768
- name: "Host tests"
6869
stage: build

tests/build.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
cache_dir=$(mktemp -d)
4+
5+
source "$TRAVIS_BUILD_DIR"/tests/common.sh
6+
7+
if [ -z "$BUILD_PARITY" ]; then
8+
mod=1
9+
rem=0
10+
elif [ "$BUILD_PARITY" = "even" ]; then
11+
mod=2
12+
rem=0
13+
elif [ "$BUILD_PARITY" = "odd" ]; then
14+
mod=2
15+
rem=1
16+
fi
17+
18+
install_arduino nodebug
19+
build_sketches_with_arduino "$mod" "$rem" lm2f
20+
21+
rm -rf "$cache_dir"
22+

tests/build6.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
cache_dir=$(mktemp -d)
4+
5+
source "$TRAVIS_BUILD_DIR"/tests/common.sh
6+
7+
if [ -z "$BUILD_PARITY" ]; then
8+
mod=1
9+
rem=0
10+
elif [ "$BUILD_PARITY" = "even" ]; then
11+
mod=2
12+
rem=0
13+
elif [ "$BUILD_PARITY" = "odd" ]; then
14+
mod=2
15+
rem=1
16+
fi
17+
18+
install_arduino nodebug
19+
build_sketches_with_arduino "$mod" "$rem" lm6f
20+
21+
rm -rf "$cache_dir"
22+

tests/common.sh

-98
Original file line numberDiff line numberDiff line change
@@ -141,59 +141,6 @@ function install_ide()
141141
export PATH="$ide_path:$core_path/tools/xtensa-lx106-elf/bin:$PATH"
142142
}
143143

144-
function install_platformio()
145-
{
146-
pip install --user -U https://github.com./platformio/platformio/archive/develop.zip
147-
platformio platform install "https://github.com./platformio/platform-espressif8266.git#feature/stage"
148-
sed -i 's/https:\/\/github\.com\/esp8266\/Arduino\.git/*/' ~/.platformio/platforms/espressif8266/platform.json
149-
ln -s $TRAVIS_BUILD_DIR ~/.platformio/packages/framework-arduinoespressif8266
150-
# Install dependencies:
151-
# - esp8266/examples/ConfigFile
152-
pio lib install ArduinoJson
153-
}
154-
155-
function build_sketches_with_platformio()
156-
{
157-
set +e
158-
local srcpath=$1
159-
local build_arg=$2
160-
local build_mod=$3
161-
local build_rem=$4
162-
local sketches=$(find $srcpath -name *.ino | sort)
163-
local testcnt=0
164-
for sketch in $sketches; do
165-
testcnt=$(( ($testcnt + 1) % $build_mod ))
166-
if [ $testcnt -ne $build_rem ]; then
167-
continue # Not ours to do
168-
fi
169-
local sketchdir=$(dirname $sketch)
170-
local sketchdirname=$(basename $sketchdir)
171-
local sketchname=$(basename $sketch)
172-
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
173-
echo "Skipping $sketch, beacause it is not the main sketch file";
174-
continue
175-
fi;
176-
if [[ -f "$sketchdir/.test.skip" ]]; then
177-
echo -e "\n ------------ Skipping $sketch ------------ \n";
178-
continue
179-
fi
180-
local build_cmd="pio ci $sketchdir $build_arg"
181-
echo -e "\n ------------ Building $sketch ------------ \n";
182-
echo "$build_cmd"
183-
time ($build_cmd >build.log)
184-
local result=$?
185-
if [ $result -ne 0 ]; then
186-
echo "Build failed ($1)"
187-
echo "Build log:"
188-
cat build.log
189-
set -e
190-
return $result
191-
fi
192-
rm build.log
193-
done
194-
set -e
195-
}
196-
197144
function install_arduino()
198145
{
199146
local debug=$1
@@ -235,48 +182,3 @@ if [ -z "$TRAVIS_BUILD_DIR" ]; then
235182
echo "TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR"
236183
fi
237184

238-
cache_dir=$(mktemp -d)
239-
240-
if [ "$BUILD_TYPE" = "build" ]; then
241-
install_arduino nodebug
242-
build_sketches_with_arduino 1 0 lm2f
243-
elif [ "$BUILD_TYPE" = "build6" ]; then
244-
install_arduino nodebug
245-
build_sketches_with_arduino 1 0 lm6f
246-
elif [ "$BUILD_TYPE" = "build_even" ]; then
247-
install_arduino nodebug
248-
build_sketches_with_arduino 2 0 lm2f
249-
elif [ "$BUILD_TYPE" = "build_odd" ]; then
250-
install_arduino nodebug
251-
build_sketches_with_arduino 2 1 lm2f
252-
elif [ "$BUILD_TYPE" = "debug_even" ]; then
253-
install_arduino debug
254-
build_sketches_with_arduino 2 0 lm2f
255-
elif [ "$BUILD_TYPE" = "debug_odd" ]; then
256-
install_arduino debug
257-
build_sketches_with_arduino 2 1 lm2f
258-
elif [ "$BUILD_TYPE" = "build6_even" ]; then
259-
install_arduino nodebug
260-
build_sketches_with_arduino 2 0 lm6f
261-
elif [ "$BUILD_TYPE" = "build6_odd" ]; then
262-
install_arduino nodebug
263-
build_sketches_with_arduino 2 1 lm6f
264-
elif [ "$BUILD_TYPE" = "platformio" ]; then
265-
# PlatformIO
266-
install_platformio
267-
build_sketches_with_platformio $TRAVIS_BUILD_DIR/libraries "--board nodemcuv2 --verbose" 1 0
268-
elif [ "$BUILD_TYPE" = "platformio_even" ]; then
269-
# PlatformIO
270-
install_platformio
271-
build_sketches_with_platformio $TRAVIS_BUILD_DIR/libraries "--board nodemcuv2 --verbose" 2 0
272-
elif [ "$BUILD_TYPE" = "platformio_odd" ]; then
273-
# PlatformIO
274-
install_platformio
275-
build_sketches_with_platformio $TRAVIS_BUILD_DIR/libraries "--board nodemcuv2 --verbose" 2 1
276-
else
277-
echo "BUILD_TYPE not set or invalid"
278-
rm -rf $cache_dir
279-
exit 1
280-
fi
281-
282-
rm -rf $cache_dir

tests/debug.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
cache_dir=$(mktemp -d)
4+
5+
source "$TRAVIS_BUILD_DIR"/tests/common.sh
6+
7+
if [ "$BUILD_PARITY" = "even" ]; then
8+
mod=2
9+
rem=0
10+
elif [ "$BUILD_PARITY" = "odd" ]; then
11+
mod=2
12+
rem=1
13+
fi
14+
15+
install_arduino debug
16+
build_sketches_with_arduino "$mod" "$rem" lm2f
17+
18+
rm -rf "$cache_dir"
19+

tests/platformio.sh

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env bash
2+
3+
cache_dir=$(mktemp -d)
4+
5+
source "$TRAVIS_BUILD_DIR"/tests/common.sh
6+
7+
function install_platformio()
8+
{
9+
pip install --user -U https://github.com./platformio/platformio/archive/develop.zip
10+
platformio platform install "https://github.com./platformio/platform-espressif8266.git#feature/stage"
11+
sed -i 's/https:\/\/github\.com\/esp8266\/Arduino\.git/*/' ~/.platformio/platforms/espressif8266/platform.json
12+
ln -s $TRAVIS_BUILD_DIR ~/.platformio/packages/framework-arduinoespressif8266
13+
# Install dependencies:
14+
# - esp8266/examples/ConfigFile
15+
pio lib install ArduinoJson
16+
}
17+
18+
function build_sketches_with_platformio()
19+
{
20+
set +e
21+
local srcpath=$1
22+
local build_arg=$2
23+
local build_mod=$3
24+
local build_rem=$4
25+
local sketches=$(find $srcpath -name *.ino | sort)
26+
local testcnt=0
27+
for sketch in $sketches; do
28+
testcnt=$(( ($testcnt + 1) % $build_mod ))
29+
if [ $testcnt -ne $build_rem ]; then
30+
continue # Not ours to do
31+
fi
32+
local sketchdir=$(dirname $sketch)
33+
local sketchdirname=$(basename $sketchdir)
34+
local sketchname=$(basename $sketch)
35+
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
36+
echo "Skipping $sketch, beacause it is not the main sketch file";
37+
continue
38+
fi;
39+
if [[ -f "$sketchdir/.test.skip" ]]; then
40+
echo -e "\n ------------ Skipping $sketch ------------ \n";
41+
continue
42+
fi
43+
local build_cmd="pio ci $sketchdir $build_arg"
44+
echo -e "\n ------------ Building $sketch ------------ \n";
45+
echo "$build_cmd"
46+
time ($build_cmd >build.log)
47+
local result=$?
48+
if [ $result -ne 0 ]; then
49+
echo "Build failed ($1)"
50+
echo "Build log:"
51+
cat build.log
52+
set -e
53+
return $result
54+
fi
55+
rm build.log
56+
done
57+
set -e
58+
}
59+
60+
if [ -z "$BUILD_PARITY" ]; then
61+
mod=1
62+
rem=0
63+
elif [ "$BUILD_PARITY" = "even" ]; then
64+
mod=2
65+
rem=0
66+
elif [ "$BUILD_PARITY" = "odd" ]; then
67+
mod=2
68+
rem=1
69+
fi
70+
71+
install_platformio
72+
build_sketches_with_platformio "$TRAVIS_BUILD_DIR"/libraries "--board nodemcuv2 --verbose" "$mod" "$rem"
73+
74+
rm -rf "$cache_dir"
75+

tests/run_CI_locally.sh

+37-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,41 @@ EOF
7979
done
8080

8181
# use pip2 for python2 with python3 is around, platformio doesn't like it
82-
cp tests/common.sh tests/common-custom.sh
83-
sed -i 's,pip ,pip2 ,g' tests/common-custom.sh
82+
cp tests/platformio.sh tests/platformio-custom.sh
83+
sed -i 's,pip ,pip2 ,g' tests/platformio-custom.sh
84+
85+
export HOME="${TMPCI}"
86+
export TRAVIS_BUILD_DIR="${TMPCI}"
87+
export BUILD_TYPE="$BUILD_TYPE"
88+
89+
if [ "$BUILD_TYPE" = "build" ]; then
90+
tests/build.sh
91+
elif [ "$BUILD_TYPE" = "build_even" ]; then
92+
BUILD_PARITY=even tests/build.sh
93+
elif [ "$BUILD_TYPE" = "build_odd" ]; then
94+
BUILD_PARITY=odd tests/build.sh
95+
96+
elif [ "$BUILD_TYPE" = "debug_even" ]; then
97+
BUILD_PARITY=even tests/debug.sh
98+
elif [ "$BUILD_TYPE" = "debug_odd" ]; then
99+
BUILD_PARITY=odd tests/debug.sh
100+
101+
elif [ "$BUILD_TYPE" = "build6" ]; then
102+
tests/build6.sh
103+
elif [ "$BUILD_TYPE" = "build6_even" ]; then
104+
BUILD_PARITY=even tests/build6.sh
105+
elif [ "$BUILD_TYPE" = "build6_odd" ]; then
106+
BUILD_PARITY=odd tests/build6.sh
107+
108+
elif [ "$BUILD_TYPE" = "platformio" ]; then
109+
tests/platformio-custom.sh
110+
elif [ "$BUILD_TYPE" = "platformio_even" ]; then
111+
BUILD_PARITY=even tests/platformio-custom.sh
112+
elif [ "$BUILD_TYPE" = "platformio_odd" ]; then
113+
BUILD_PARITY=odd tests/platformio-custom.sh
114+
115+
else
116+
echo "BUILD_TYPE not set or invalid"
117+
exit 1
118+
fi
84119

85-
HOME=${TMPCI} TRAVIS_BUILD_DIR=${TMPCI} BUILD_TYPE=$BUILD_TYPE tests/common-custom.sh

0 commit comments

Comments
 (0)