Browse Source

Merge pull request #1007 from mcspr/parallel-travis-jobs

Separate test and release stages in travis
rfm69
Xose Pérez 6 years ago
committed by GitHub
parent
commit
95ac8c6cd6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 28 deletions
  1. +21
    -8
      .travis.yml
  2. +15
    -20
      code/build.sh

+ 21
- 8
.travis.yml View File

@ -4,6 +4,7 @@ python:
sudo: false sudo: false
cache: cache:
directories: directories:
- "~/.npm"
- "~/.platformio" - "~/.platformio"
- "$TRAVIS_BUILD_DIR/code/.piolibdeps" - "$TRAVIS_BUILD_DIR/code/.piolibdeps"
- "$TRAVIS_BUILD_DIR/code/espurna/node_modules" - "$TRAVIS_BUILD_DIR/code/espurna/node_modules"
@ -11,15 +12,25 @@ install:
- pip install -U platformio - pip install -U platformio
- cd code ; npm install --only=dev ; cd .. - cd code ; npm install --only=dev ; cd ..
env: 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: script:
- cd code && ./build.sh -p && cd .. - 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: before_deploy:
- mv firmware/*/espurna-*.bin firmware/ - mv firmware/*/espurna-*.bin firmware/
deploy: deploy:
@ -30,8 +41,10 @@ deploy:
file: firmware/espurna-*.bin file: firmware/espurna-*.bin
skip_cleanup: true skip_cleanup: true
on: on:
all_branches: true
tags: true tags: true
branch: master
repo: xoseperez/espurna
condition: $TRAVIS_BUILD_STAGE_NAME = Release
notifications: notifications:
pushover: pushover:
api_key: api_key:


+ 15
- 20
code/build.sh View File

@ -27,12 +27,12 @@ while getopts "lp" opt; do
${par_total_threads} -ne ${par_total_threads} ]; then ${par_total_threads} -ne ${par_total_threads} ]; then
echo "Parallel threads should be a number." echo "Parallel threads should be a number."
exit 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 esac
done done
@ -43,14 +43,14 @@ environments=$@
# Environments to build # Environments to build
if [ $# -eq 0 ]; then 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
fi fi
@ -84,13 +84,8 @@ node node_modules/gulp/bin/gulp.js || exit
echo "--------------------------------------------------------------" echo "--------------------------------------------------------------"
echo "Building firmware images..." echo "Building firmware images..."
mkdir -p ../firmware/espurna-$version 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 --- " echo -n "* espurna-$version-$environment.bin --- "
platformio run --silent --environment $environment || exit 1 platformio run --silent --environment $environment || exit 1
stat -c %s .pioenvs/$environment/firmware.bin stat -c %s .pioenvs/$environment/firmware.bin


Loading…
Cancel
Save