Browse Source

Travis parallel builds

rfm69
Lazar Obradovic 6 years ago
parent
commit
87b456cb6a
2 changed files with 47 additions and 11 deletions
  1. +11
    -1
      .travis.yml
  2. +36
    -10
      code/build.sh

+ 11
- 1
.travis.yml View File

@ -5,11 +5,21 @@ sudo: false
cache: cache:
directories: directories:
- "~/.platformio" - "~/.platformio"
- "$TRAVIS_BUILD_DIR/code/.piolibdeps"
- "$TRAVIS_BUILD_DIR/code/espurna/node_modules"
install: install:
- pip install -U platformio - pip install -U platformio
- cd code ; npm install --only=dev ; cd .. - 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
script: script:
- cd code && ./build.sh && cd ..
- cd code && ./build.sh -p && cd ..
before_deploy: before_deploy:
- mv firmware/*/espurna-*.bin firmware/ - mv firmware/*/espurna-*.bin firmware/
deploy: deploy:


+ 36
- 10
code/build.sh View File

@ -9,15 +9,36 @@ travis=$(grep env: platformio.ini | grep travis | sed 's/\[env://' | sed 's/\]/
available=$(grep env: platformio.ini | grep -v ota | grep -v ssl | grep -v travis | sed 's/\[env://' | sed 's/\]/ /' | sort) available=$(grep env: platformio.ini | grep -v ota | grep -v ssl | grep -v travis | sed 's/\[env://' | sed 's/\]/ /' | sort)
# Parameters # Parameters
while getopts "lp" opt; do
case $opt in
l)
echo "--------------------------------------------------------------"
echo "Available environments:"
for environment in $available; do
echo "* $environment"
done
exit
;;
p)
par_build=1
par_thread=${BUILDER_THREAD:-0}
par_total_threads=${BUILDER_TOTAL_THREADS:-4}
if [ ${par_thread} -ne ${par_thread} -o \
${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
;;
esac
done
shift $((OPTIND-1))
environments=$@ environments=$@
if [ "$environments" == "list" ]; then
echo "--------------------------------------------------------------"
echo "Available environments:"
for environment in $available; do
echo "* $environment"
done
exit
fi
# Environments to build # Environments to build
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@ -63,8 +84,13 @@ 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
for environment in $environments; do
echo "* espurna-$version-$environment.bin"
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 echo "* espurna-$version-$environment.bin"
platformio run --silent --environment $environment || exit 1 platformio run --silent --environment $environment || exit 1
mv .pioenvs/$environment/firmware.bin ../firmware/espurna-$version/espurna-$version-$environment.bin mv .pioenvs/$environment/firmware.bin ../firmware/espurna-$version/espurna-$version-$environment.bin
done done


Loading…
Cancel
Save