diff --git a/.travis.yml b/.travis.yml index 9852d881a..a1343eb6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,49 +20,50 @@ stages: jobs: include: # Build stage. To save time, run all kinds of builds and tests in parallel. - # TODO: since we can now call different script for each job, - # split the do-it-all common.sh into separate scripts responsible - # for different types of jobs below: + - name: "Platformio (1)" stage: build - script: $TRAVIS_BUILD_DIR/tests/common.sh + script: $TRAVIS_BUILD_DIR/tests/platformio.sh env: - - BUILD_TYPE=platformio_even + - BUILD_PARITY=even - name: "Platformio (2)" stage: build - script: $TRAVIS_BUILD_DIR/tests/common.sh + script: $TRAVIS_BUILD_DIR/tests/platformio.sh env: - - BUILD_TYPE=platformio_odd + - BUILD_PARITY=odd + - name: "Build (1)" stage: build - script: $TRAVIS_BUILD_DIR/tests/common.sh + script: $TRAVIS_BUILD_DIR/tests/build.sh env: - - BUILD_TYPE=build_even + - BUILD_PARITY=even - name: "Build (2)" stage: build - script: $TRAVIS_BUILD_DIR/tests/common.sh + script: $TRAVIS_BUILD_DIR/tests/build.sh env: - - BUILD_TYPE=build_odd + - BUILD_PARITY=odd + - name: "Debug (1)" stage: build - script: $TRAVIS_BUILD_DIR/tests/common.sh + script: $TRAVIS_BUILD_DIR/tests/debug.sh env: - - BUILD_TYPE=debug_even + - BUILD_PARITY=even - name: "Debug (2)" stage: build - script: $TRAVIS_BUILD_DIR/tests/common.sh + script: $TRAVIS_BUILD_DIR/tests/debug.sh env: - - BUILD_TYPE=debug_odd + - BUILD_PARITY=odd + - name: "Build IPv6 (1)" stage: build - script: $TRAVIS_BUILD_DIR/tests/common.sh + script: $TRAVIS_BUILD_DIR/tests/build6.sh env: - - BUILD_TYPE=build6_even + - BUILD_PARITY=even - name: "Build IPv6 (2)" stage: build - script: $TRAVIS_BUILD_DIR/tests/common.sh + script: $TRAVIS_BUILD_DIR/tests/build6.sh env: - - BUILD_TYPE=build6_odd + - BUILD_PARITY=odd - name: "Host tests" stage: build diff --git a/tests/build.sh b/tests/build.sh new file mode 100755 index 000000000..45f88e7ef --- /dev/null +++ b/tests/build.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +cache_dir=$(mktemp -d) + +source "$TRAVIS_BUILD_DIR"/tests/common.sh + +if [ -z "$BUILD_PARITY" ]; then + mod=1 + rem=0 +elif [ "$BUILD_PARITY" = "even" ]; then + mod=2 + rem=0 +elif [ "$BUILD_PARITY" = "odd" ]; then + mod=2 + rem=1 +fi + +install_arduino nodebug +build_sketches_with_arduino "$mod" "$rem" lm2f + +rm -rf "$cache_dir" + diff --git a/tests/build6.sh b/tests/build6.sh new file mode 100755 index 000000000..4fc199699 --- /dev/null +++ b/tests/build6.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +cache_dir=$(mktemp -d) + +source "$TRAVIS_BUILD_DIR"/tests/common.sh + +if [ -z "$BUILD_PARITY" ]; then + mod=1 + rem=0 +elif [ "$BUILD_PARITY" = "even" ]; then + mod=2 + rem=0 +elif [ "$BUILD_PARITY" = "odd" ]; then + mod=2 + rem=1 +fi + +install_arduino nodebug +build_sketches_with_arduino "$mod" "$rem" lm6f + +rm -rf "$cache_dir" + diff --git a/tests/common.sh b/tests/common.sh index 78aae1e8d..f03a4f6c5 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -141,59 +141,6 @@ function install_ide() export PATH="$ide_path:$core_path/tools/xtensa-lx106-elf/bin:$PATH" } -function install_platformio() -{ - pip install --user -U https://github.com/platformio/platformio/archive/develop.zip - platformio platform install "https://github.com/platformio/platform-espressif8266.git#feature/stage" - sed -i 's/https:\/\/github\.com\/esp8266\/Arduino\.git/*/' ~/.platformio/platforms/espressif8266/platform.json - ln -s $TRAVIS_BUILD_DIR ~/.platformio/packages/framework-arduinoespressif8266 - # Install dependencies: - # - esp8266/examples/ConfigFile - pio lib install ArduinoJson -} - -function build_sketches_with_platformio() -{ - set +e - local srcpath=$1 - local build_arg=$2 - local build_mod=$3 - local build_rem=$4 - local sketches=$(find $srcpath -name *.ino | sort) - local testcnt=0 - for sketch in $sketches; do - testcnt=$(( ($testcnt + 1) % $build_mod )) - if [ $testcnt -ne $build_rem ]; then - continue # Not ours to do - fi - local sketchdir=$(dirname $sketch) - local sketchdirname=$(basename $sketchdir) - local sketchname=$(basename $sketch) - if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then - echo "Skipping $sketch, beacause it is not the main sketch file"; - continue - fi; - if [[ -f "$sketchdir/.test.skip" ]]; then - echo -e "\n ------------ Skipping $sketch ------------ \n"; - continue - fi - local build_cmd="pio ci $sketchdir $build_arg" - echo -e "\n ------------ Building $sketch ------------ \n"; - echo "$build_cmd" - time ($build_cmd >build.log) - local result=$? - if [ $result -ne 0 ]; then - echo "Build failed ($1)" - echo "Build log:" - cat build.log - set -e - return $result - fi - rm build.log - done - set -e -} - function install_arduino() { local debug=$1 @@ -235,48 +182,3 @@ if [ -z "$TRAVIS_BUILD_DIR" ]; then echo "TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR" fi -cache_dir=$(mktemp -d) - -if [ "$BUILD_TYPE" = "build" ]; then - install_arduino nodebug - build_sketches_with_arduino 1 0 lm2f -elif [ "$BUILD_TYPE" = "build6" ]; then - install_arduino nodebug - build_sketches_with_arduino 1 0 lm6f -elif [ "$BUILD_TYPE" = "build_even" ]; then - install_arduino nodebug - build_sketches_with_arduino 2 0 lm2f -elif [ "$BUILD_TYPE" = "build_odd" ]; then - install_arduino nodebug - build_sketches_with_arduino 2 1 lm2f -elif [ "$BUILD_TYPE" = "debug_even" ]; then - install_arduino debug - build_sketches_with_arduino 2 0 lm2f -elif [ "$BUILD_TYPE" = "debug_odd" ]; then - install_arduino debug - build_sketches_with_arduino 2 1 lm2f -elif [ "$BUILD_TYPE" = "build6_even" ]; then - install_arduino nodebug - build_sketches_with_arduino 2 0 lm6f -elif [ "$BUILD_TYPE" = "build6_odd" ]; then - install_arduino nodebug - build_sketches_with_arduino 2 1 lm6f -elif [ "$BUILD_TYPE" = "platformio" ]; then - # PlatformIO - install_platformio - build_sketches_with_platformio $TRAVIS_BUILD_DIR/libraries "--board nodemcuv2 --verbose" 1 0 -elif [ "$BUILD_TYPE" = "platformio_even" ]; then - # PlatformIO - install_platformio - build_sketches_with_platformio $TRAVIS_BUILD_DIR/libraries "--board nodemcuv2 --verbose" 2 0 -elif [ "$BUILD_TYPE" = "platformio_odd" ]; then - # PlatformIO - install_platformio - build_sketches_with_platformio $TRAVIS_BUILD_DIR/libraries "--board nodemcuv2 --verbose" 2 1 -else - echo "BUILD_TYPE not set or invalid" - rm -rf $cache_dir - exit 1 -fi - -rm -rf $cache_dir diff --git a/tests/debug.sh b/tests/debug.sh new file mode 100755 index 000000000..9f4aea603 --- /dev/null +++ b/tests/debug.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +cache_dir=$(mktemp -d) + +source "$TRAVIS_BUILD_DIR"/tests/common.sh + +if [ "$BUILD_PARITY" = "even" ]; then + mod=2 + rem=0 +elif [ "$BUILD_PARITY" = "odd" ]; then + mod=2 + rem=1 +fi + +install_arduino debug +build_sketches_with_arduino "$mod" "$rem" lm2f + +rm -rf "$cache_dir" + diff --git a/tests/platformio.sh b/tests/platformio.sh new file mode 100755 index 000000000..a62fdd798 --- /dev/null +++ b/tests/platformio.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +cache_dir=$(mktemp -d) + +source "$TRAVIS_BUILD_DIR"/tests/common.sh + +function install_platformio() +{ + pip install --user -U https://github.com/platformio/platformio/archive/develop.zip + platformio platform install "https://github.com/platformio/platform-espressif8266.git#feature/stage" + sed -i 's/https:\/\/github\.com\/esp8266\/Arduino\.git/*/' ~/.platformio/platforms/espressif8266/platform.json + ln -s $TRAVIS_BUILD_DIR ~/.platformio/packages/framework-arduinoespressif8266 + # Install dependencies: + # - esp8266/examples/ConfigFile + pio lib install ArduinoJson +} + +function build_sketches_with_platformio() +{ + set +e + local srcpath=$1 + local build_arg=$2 + local build_mod=$3 + local build_rem=$4 + local sketches=$(find $srcpath -name *.ino | sort) + local testcnt=0 + for sketch in $sketches; do + testcnt=$(( ($testcnt + 1) % $build_mod )) + if [ $testcnt -ne $build_rem ]; then + continue # Not ours to do + fi + local sketchdir=$(dirname $sketch) + local sketchdirname=$(basename $sketchdir) + local sketchname=$(basename $sketch) + if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then + echo "Skipping $sketch, beacause it is not the main sketch file"; + continue + fi; + if [[ -f "$sketchdir/.test.skip" ]]; then + echo -e "\n ------------ Skipping $sketch ------------ \n"; + continue + fi + local build_cmd="pio ci $sketchdir $build_arg" + echo -e "\n ------------ Building $sketch ------------ \n"; + echo "$build_cmd" + time ($build_cmd >build.log) + local result=$? + if [ $result -ne 0 ]; then + echo "Build failed ($1)" + echo "Build log:" + cat build.log + set -e + return $result + fi + rm build.log + done + set -e +} + +if [ -z "$BUILD_PARITY" ]; then + mod=1 + rem=0 +elif [ "$BUILD_PARITY" = "even" ]; then + mod=2 + rem=0 +elif [ "$BUILD_PARITY" = "odd" ]; then + mod=2 + rem=1 +fi + +install_platformio +build_sketches_with_platformio "$TRAVIS_BUILD_DIR"/libraries "--board nodemcuv2 --verbose" "$mod" "$rem" + +rm -rf "$cache_dir" + diff --git a/tests/run_CI_locally.sh b/tests/run_CI_locally.sh index 2518069bf..90b2d77c3 100755 --- a/tests/run_CI_locally.sh +++ b/tests/run_CI_locally.sh @@ -79,7 +79,41 @@ EOF done # use pip2 for python2 with python3 is around, platformio doesn't like it -cp tests/common.sh tests/common-custom.sh -sed -i 's,pip ,pip2 ,g' tests/common-custom.sh +cp tests/platformio.sh tests/platformio-custom.sh +sed -i 's,pip ,pip2 ,g' tests/platformio-custom.sh + +export HOME="${TMPCI}" +export TRAVIS_BUILD_DIR="${TMPCI}" +export BUILD_TYPE="$BUILD_TYPE" + +if [ "$BUILD_TYPE" = "build" ]; then + tests/build.sh +elif [ "$BUILD_TYPE" = "build_even" ]; then + BUILD_PARITY=even tests/build.sh +elif [ "$BUILD_TYPE" = "build_odd" ]; then + BUILD_PARITY=odd tests/build.sh + +elif [ "$BUILD_TYPE" = "debug_even" ]; then + BUILD_PARITY=even tests/debug.sh +elif [ "$BUILD_TYPE" = "debug_odd" ]; then + BUILD_PARITY=odd tests/debug.sh + +elif [ "$BUILD_TYPE" = "build6" ]; then + tests/build6.sh +elif [ "$BUILD_TYPE" = "build6_even" ]; then + BUILD_PARITY=even tests/build6.sh +elif [ "$BUILD_TYPE" = "build6_odd" ]; then + BUILD_PARITY=odd tests/build6.sh + +elif [ "$BUILD_TYPE" = "platformio" ]; then + tests/platformio-custom.sh +elif [ "$BUILD_TYPE" = "platformio_even" ]; then + BUILD_PARITY=even tests/platformio-custom.sh +elif [ "$BUILD_TYPE" = "platformio_odd" ]; then + BUILD_PARITY=odd tests/platformio-custom.sh + +else + echo "BUILD_TYPE not set or invalid" + exit 1 +fi -HOME=${TMPCI} TRAVIS_BUILD_DIR=${TMPCI} BUILD_TYPE=$BUILD_TYPE tests/common-custom.sh