From 5fdf4aa53dbd6305e663a44b642ce7426dc5e776 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Thu, 28 Jun 2018 03:43:14 +0300 Subject: [PATCH] Separate test and release stages in travis - Revert test to being serial. Releases are using parallel jobs. - Some cosmetic changes in build.sh --- .travis.yml | 29 +++++++++++++++++++++-------- code/build.sh | 35 +++++++++++++++-------------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec31cea6..8a38f507 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ python: sudo: false cache: directories: + - "~/.npm" - "~/.platformio" - "$TRAVIS_BUILD_DIR/code/.piolibdeps" - "$TRAVIS_BUILD_DIR/code/espurna/node_modules" @@ -11,15 +12,25 @@ install: - pip install -U platformio - cd code ; npm install --only=dev ; cd .. env: - global: - - BUILDER_TOTAL_THREADS=4 - matrix: - - BUILDER_THREAD=0 - - BUILDER_THREAD=1 - - BUILDER_THREAD=2 - - BUILDER_THREAD=3 + global: + - BUILDER_TOTAL_THREADS=4 script: - cd code && ./build.sh -p && cd .. +stages: +- name: Test +- name: Release + if: tag IS present AND branch = master +jobs: + include: + - stage: Test + script: cd code && ./build.sh travis01 + - script: cd code && ./build.sh travis02 + - script: cd code && ./build.sh travis03 + - stage: Release + env: BUILDER_THREAD=0 + - env: BUILDER_THREAD=1 + - env: BUILDER_THREAD=2 + - env: BUILDER_THREAD=3 before_deploy: - mv firmware/*/espurna-*.bin firmware/ deploy: @@ -30,8 +41,10 @@ deploy: file: firmware/espurna-*.bin skip_cleanup: true on: - all_branches: true tags: true + branch: master + repo: xoseperez/espurna + condition: $TRAVIS_BUILD_STAGE_NAME = Release notifications: pushover: api_key: diff --git a/code/build.sh b/code/build.sh index beda36b3..af1ada71 100755 --- a/code/build.sh +++ b/code/build.sh @@ -27,12 +27,12 @@ while getopts "lp" opt; do ${par_total_threads} -ne ${par_total_threads} ]; then echo "Parallel threads should be a number." exit - fi - if [ ${par_thread} -ge ${par_total_threads} ]; then - echo "Current thread is greater than total threads. Doesn't make sense" - exit - fi - ;; + fi + if [ ${par_thread} -ge ${par_total_threads} ]; then + echo "Current thread is greater than total threads. Doesn't make sense" + exit + fi + ;; esac done @@ -43,14 +43,14 @@ environments=$@ # Environments to build if [ $# -eq 0 ]; then - environments=$available - - # Hook to build travis test envs - if [[ "${TRAVIS_BRANCH}" != "" ]]; then - re='^[0-9]+\.[0-9]+\.[0-9]+$' - if ! [[ ${TRAVIS_BRANCH} =~ $re ]]; then - environments=$travis - fi + if [[ "${TRAVIS_BUILD_STAGE_NAME}" = "Release" ]] && [ ${par_build} ]; then + environments=$(echo ${available} | \ + awk -v par_thread=${par_thread} -v par_total_threads=${par_total_threads} \ + '{ for (i = 1; i <= NF; i++) if (++j % par_total_threads == par_thread ) print $i; }') + elif [[ "${TRAVIS_BUILD_STAGE_NAME}" = "Test" ]]; then + environments=$travis + else + environments=$available fi fi @@ -84,13 +84,8 @@ node node_modules/gulp/bin/gulp.js || exit echo "--------------------------------------------------------------" echo "Building firmware images..." mkdir -p ../firmware/espurna-$version -if [ ${par_build} ]; then - to_build=$(echo ${environments} | awk -v par_thread=${par_thread} -v par_total_threads=${par_total_threads} '{ for (i = 1; i <= NF; i++) if (++j % par_total_threads == par_thread ) print $i; }') -else - to_build=${environments} -fi -for environment in $to_build; do +for environment in $environments; do echo -n "* espurna-$version-$environment.bin --- " platformio run --silent --environment $environment || exit 1 stat -c %s .pioenvs/$environment/firmware.bin