diff --git a/.travis.yml b/.travis.yml index 22c62479..0edf733d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,7 @@ cache: - "~/.npm" - "~/.platformio" install: -- pip install -U platformio -- pio platform update -p -- npm install -g npm@latest -- cd code && npm ci && cd .. +- ./travis_install.sh env: global: - BUILDER_TOTAL_THREADS=4 @@ -23,10 +20,11 @@ stages: if: tag IS present AND tag =~ ^\d+\.\d+\.\d+$ jobs: include: - - stage: Test - env: BUILDER_ENV=travis-2_3_0 - - env: BUILDER_ENV=travis-latest - - env: BUILDER_ENV=travis-git BUILDER_EXTRA="-a test/build/extra/secure_client.h" + - stage: Test WebUI + - stage: Test PlatformIO Build + env: TEST_ENV=travis-2_3_0 + - env: TEST_ENV=travis-latest + - env: TEST_ENV=travis-git TEST_EXTRA_ARGS="-a test/build/extra/secure_client.h" - stage: Release env: BUILDER_THREAD=0 - env: BUILDER_THREAD=1 diff --git a/code/build.sh b/code/build.sh index ec1505cb..93bbd38f 100755 --- a/code/build.sh +++ b/code/build.sh @@ -21,6 +21,8 @@ stat_bytes() { destination=../firmware version_file=espurna/config/version.h version=$(grep -E '^#define APP_VERSION' $version_file | awk '{print $3}' | sed 's/"//g') +script_build_environments=true +script_build_webui=true if ${TRAVIS:-false}; then git_revision=${TRAVIS_COMMIT::7} @@ -133,8 +135,36 @@ build_environments() { } # Parameters -while getopts "lpd:" opt; do +print_getopts_help() { + cat <... + + Where ENVIRONMENT is environment name(s) from platformio.ini + +Options: + + -f VALUE Filter build stage by name to skip it + Supported VALUEs are "environments" and "webui" + Can be specified multiple times + -l Print available environments + -d VALUE Destination to move .bin files after building environments + -p Enable parallel build + Depends on following exported variables: + BUILDER_THREAD= (default 0...4) + BUILDER_TOTAL_THREADS= (default 4) + When building platformio environments, will only pick every th + -h Display this message +EOF +} + +while getopts "f:lpd:h" opt; do case $opt in + f) + case "$OPTARG" in + webui) script_build_webui=false ;; + environments) script_build_environments=false ;; + esac + ;; l) print_available exit @@ -145,6 +175,9 @@ while getopts "lpd:" opt; do d) destination=$OPTARG ;; + h) + print_getopts_help + exit esac done @@ -158,13 +191,18 @@ echo "Building for version ${version}" ${git_revision:+($git_revision)} # Environments to build environments=$@ -if [ $# -eq 0 ]; then - set_default_environments +if $script_build_webui ; then + build_webui fi -if ${CI:-false}; then - print_environments -fi +if $script_build_environments ; then + if [ $# -eq 0 ]; then + set_default_environments + fi + + if ${CI:-false}; then + print_environments + fi -build_webui -build_environments + build_environments +fi diff --git a/travis_install.sh b/travis_install.sh new file mode 100755 index 00000000..251bdd14 --- /dev/null +++ b/travis_install.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -x -e -v + +npm_install() { + npm install -g npm@latest + npm ci +} + +pio_install() { + pip install -U platformio + pio platform update -p +} + +cd code + +if [ "${TRAVIS_BUILD_STAGE_NAME}" = "Test webui" ]; then + npm_install +elif [ "${TRAVIS_BUILD_STAGE_NAME}" = "Test platformio build" ]; then + pio_install +elif [ "${TRAVIS_BUILD_STAGE_NAME}" = "Release" ]; then + npm_install + pio_install +else + echo -e "\e[1;33mUnknown stage name, exiting!\e[0m" + exit 1 +fi diff --git a/travis_script.sh b/travis_script.sh index 21eaf7e3..3881873e 100755 --- a/travis_script.sh +++ b/travis_script.sh @@ -1,11 +1,17 @@ #!/bin/bash -set -e -v +set -x -e -v cd code -if [ ${TRAVIS_BUILD_STAGE_NAME} = "Test" ]; then - scripts/test_build.py -e $BUILDER_ENV $BUILDER_EXTRA -else +if [ "${TRAVIS_BUILD_STAGE_NAME}" = "Test webui" ]; then + ./build.sh -f environments +elif [ "${TRAVIS_BUILD_STAGE_NAME}" = "Test platformio build" ]; then + # shellcheck disable=SC2086 + scripts/test_build.py -e "$TEST_ENV" $TEST_EXTRA_ARGS +elif [ "${TRAVIS_BUILD_STAGE_NAME}" = "Release" ]; then ./build.sh -p +else + echo -e "\e[1;33mUnknown stage name, exiting!\e[0m" + exit 1 fi