diff options
author | 1138-4EB <1138-4EB@users.noreply.github.com> | 2017-02-26 22:59:38 +0100 |
---|---|---|
committer | 1138-4EB <1138-4EB@users.noreply.github.com> | 2017-03-01 06:57:27 +0100 |
commit | 08264571869e92cb7e6dcee5facfedbf0bedce68 (patch) | |
tree | b9e8a587027b2359bbd8c3e59b7d12d4b1098a0d /dist/linux | |
parent | 439664c7e1cc7c9d3587cb72d8f395538aed36bc (diff) | |
download | ghdl-08264571869e92cb7e6dcee5facfedbf0bedce68.tar.gz ghdl-08264571869e92cb7e6dcee5facfedbf0bedce68.tar.bz2 ghdl-08264571869e92cb7e6dcee5facfedbf0bedce68.zip |
Use single VM in .travis.yml to speed-up launching builds. Container are launched in parallel threads.
The output of each thread is saved to a log. All of them are printed in order, after all the threads have finished.
Shared ANSI color codes between libraries/vendors and dist/linux. The common file to be sourced is dist/ansi_color.sh
Diffstat (limited to 'dist/linux')
-rwxr-xr-x[-rw-r--r--] | dist/linux/buildtest.sh | 106 | ||||
-rwxr-xr-x[-rw-r--r--] | dist/linux/docker-buildtest.sh | 64 | ||||
-rw-r--r-- | dist/linux/envs/fedora_llvm.sh | 2 | ||||
-rw-r--r-- | dist/linux/envs/fedora_mcode.sh | 2 | ||||
-rw-r--r-- | dist/linux/envs/ubuntu1204_llvm38.sh | 2 | ||||
-rw-r--r-- | dist/linux/envs/ubuntu1404_llvm35.sh | 2 | ||||
-rw-r--r-- | dist/linux/envs/ubuntu_mcode.sh | 2 | ||||
-rwxr-xr-x | dist/linux/travis-ci.sh | 71 |
8 files changed, 184 insertions, 67 deletions
diff --git a/dist/linux/buildtest.sh b/dist/linux/buildtest.sh index 884a30cb8..f8347070d 100644..100755 --- a/dist/linux/buildtest.sh +++ b/dist/linux/buildtest.sh @@ -1,71 +1,99 @@ #! /bin/sh -# This script is executed in the travis-ci environment. + +. dist/ansi_color.sh +disable_color # Stop in case of error set -e -while getopts ":b:f:" opt; do +# Transform long options to short ones +for arg in "$@"; do + shift + case "$arg" in + "--color"|"-color") set -- "$@" "-c";; + "--build"|"-build") set -- "$@" "-b";; + "--file"|"-file") set -- "$@" "-f";; + "--taskid"|"-taskid") set -- "$@" "-t";; + *) set -- "$@" "$arg" + esac +done +# Parse args +while getopts ":b:f:t:c" opt; do case $opt in + c) enable_color;; b) BLD=$OPTARG ;; f) PKG_FILE=$OPTARG;; - \?) echo "Invalid option: -$OPTARG" >&2; exit 1 ;; - :) echo "Option -$OPTARG requires an argument." >&2; exit 1 ;; + t) TASK=$OPTARG;; + \?) printf "$ANSI_RED[GHDL] Invalid option: -$OPTARG $ANSI_NOCOLOR\n" >&2; exit 1 ;; + :) printf "$ANSI_RED[GHDL] Option -$OPTARG requires an argument. $ANSI_NOCOLOR\n" >&2; exit 1 ;; esac done -CDIR=$(pwd) - -# Display environment -echo "Environment:" -env +#--- -# Prepare +printf "$ANSI_BLUE[$TASK| GHDL] Prepare $(pwd) $ANSI_NOCOLOR\n" +CDIR=$(pwd) +mkdir logs prefix="$CDIR/install-$BLD" mkdir "$prefix" mkdir "build-$BLD" cd "build-$BLD" -# Configure +#--- + +printf "$ANSI_BLUE[$TASK| GHDL] Environment $ANSI_NOCOLOR\n" +env 1>> ../log.log 2>&1 + +#--- + +printf "$ANSI_BLUE[$TASK| GHDL - build] Configure $ANSI_NOCOLOR\n" case "$BLD" in mcode) - ../configure --prefix="$prefix" - MAKEOPTS="" - ;; + ../configure "--prefix=$prefix" 1>> ../log.log 2>&1 + ;; llvm) - ../configure --prefix="$prefix$" --with-llvm-config - ;; + ../configure "--prefix=$prefix" "--with-llvm-config" 1>> ../log.log 2>&1 + ;; llvm-3.5) - ../configure --prefix="$prefix" --with-llvm-config=llvm-config-3.5 - MAKEOPTS="CXX=clang++" - ;; + ../configure "--prefix=$prefix" "--with-llvm-config=llvm-config-3.5" 1>> ../log.log 2>&1 + MAKEOPTS="CXX=clang++" + ;; llvm-3.8) - ../configure --prefix="$prefix" --with-llvm-config=llvm-config-3.8 - MAKEOPTS="CXX=clang++-3.8" - ;; - - docker) echo "Check docker container!"; exit 0;; + ../configure "--prefix=$prefix" "--with-llvm-config=llvm-config-3.8" 1>> ../log.log 2>&1 + MAKEOPTS="CXX=clang++-3.8" + ;; + + docker) printf "$ANSI_MAGENTA[$TASK| GHDL - build] Check docker container! $ANSI_NOCOLOR\n"; exit 0;; - *) - echo "unknown build $BLD" - exit 1 - ;; + *) printf "$ANSI_RED[$TASK| GHDL - build] Unknown build $BLD $ANSI_NOCOLOR\n" + exit 1;; esac -# Build -make $MAKEOPTS -make install +#--- + +printf "$ANSI_BLUE[$TASK| GHDL - build] Make $ANSI_NOCOLOR\n" +make $MAKEOPTS 1>> ../log.log 2>&1 +printf "$ANSI_BLUE[$TASK| GHDL - build] Install $ANSI_NOCOLOR\n" +make install 1>> ../log.log 2>&1 cd .. -# Package -echo "creating $PKG_FILE" -tar -zcvf "$PKG_FILE" -C "$prefix" . +#--- + +printf "$ANSI_BLUE[$TASK| GHDL] Create package $ANSI_DARKCYAN$PKG_FILE $ANSI_NOCOLOR\n" +tar -zcvf "$PKG_FILE" -C "$prefix" . 1>> log.log 2>&1 -# Test +#--- + +export ENABLECOLOR="$ENABLECOLOR" +export TASK="$TASK" export GHDL="$CDIR/install-$BLD/bin/ghdl" -cd testsuite -gnatmake get_entities -./testsuite.sh -cd ..
\ No newline at end of file +cd testsuite && ./testsuite.sh +cd .. + +#--- + +# Do not remove this line, and don't write anything below, since it is used to identify successful builds +echo "[$TASK|SUCCESSFUL]" 1>> log.log 2>&1
\ No newline at end of file diff --git a/dist/linux/docker-buildtest.sh b/dist/linux/docker-buildtest.sh index 5c921b18e..919a314d6 100644..100755 --- a/dist/linux/docker-buildtest.sh +++ b/dist/linux/docker-buildtest.sh @@ -1,22 +1,64 @@ -set -ev +#! /bin/sh -docker pull "$DOCKER_IMG" +. dist/ansi_color.sh +disable_color -if [ -z "$DONTGRAB_SRCS" ]; then +# Stop in case of error +set -e +# Transform long options to short ones +for arg in "$@"; do + shift + case "$arg" in + "--color"|"-color") set -- "$@" "-c";; + "--grab"|"-grab") set -- "$@" "-g";; + "--image"|"-image") set -- "$@" "-i";; + "--build"|"-build") set -- "$@" "-b";; + "--file"|"-file") set -- "$@" "-f";; + "--taskid"|"-taskid") set -- "$@" "-t";; + *) set -- "$@" "$arg" + esac +done +# Parse args +while getopts ":i:b:f:t:cg" opt; do + case $opt in + c) enable_color;; + g) GRAB_SRCS=1;; + i) DOCKER_IMG=$OPTARG;; + b) BLD=$OPTARG ;; + f) PKG_FILE=$OPTARG;; + t) TASK=$OPTARG;; + \?) printf "$ANSI_RED[BUILD] Invalid option: -$OPTARG $ANSI_NOCOLOR\n" >&2; exit 1 ;; + :) printf "$ANSI_RED[BUILD] Option -$OPTARG requires an argument $ANSI_NOCOLOR\n" >&2; exit 1 ;; + esac +done + +#--- + +printf "$ANSI_YELLOW[$TASK| BUILD] Docker pull $DOCKER_IMG $ANSI_NOCOLOR\n" +docker pull "$DOCKER_IMG" > /dev/null 2>&1 + +#--- + +printf "$ANSI_YELLOW[$TASK| BUILD] Docker run $DOCKER_IMG $BLD $PKG_FILE $ANSI_NOCOLOR\n" + +if [ -n "$GRAB_SRCS" ]; then + + printf "$ANSI_YELLOW[$TASK| BUILD] Grab sources$ANSI_NOCOLOR\n" + p="mkdir /work && cd /work" p="$p && curl -L https://github.com/tgingold/ghdl/archive/master.tar.gz | tar xz" p="$p && mv ghdl-master/* ./ && rm -rf ghdl-master" - - docker run --name ghdl_cmp -it "$DOCKER_IMG" sh -c "$p && sh ./dist/linux/buildtest.sh -b $DBLD -f $PKG_FILE" + + set +e + docker run --name ghdl_cmp -t "$DOCKER_IMG" sh -c "$p &&./dist/linux/buildtest.sh $ENABLECOLOR-t $TASK -b $BLD -f $PKG_FILE" + docker cp "ghdl_cmp:/work/log.log" "./log.log" + set -e docker cp "ghdl_cmp:/work/$PKG_FILE" ./ + docker rm ghdl_cmp else - docker run --name ghdl_cmp -itv $(pwd):/work:Z "$DOCKER_IMG" sh -c "cd /work && sh ./dist/linux/buildtest.sh -b $DBLD -f $PKG_FILE" - -fi - -docker rm ghdl_cmp - + docker run --rm -tv $(pwd):/work:Z -w="/work" "$DOCKER_IMG" sh -c "./dist/linux/buildtest.sh $ENABLECOLOR-t $TASK -b $BLD -f $PKG_FILE" +fi
\ No newline at end of file diff --git a/dist/linux/envs/fedora_llvm.sh b/dist/linux/envs/fedora_llvm.sh deleted file mode 100644 index c44857c51..000000000 --- a/dist/linux/envs/fedora_llvm.sh +++ /dev/null @@ -1,2 +0,0 @@ -BLD=fed+llvm -DOCKER_IMG="ghdl/ghdl-tools:fedora-llvm-mcode"
\ No newline at end of file diff --git a/dist/linux/envs/fedora_mcode.sh b/dist/linux/envs/fedora_mcode.sh deleted file mode 100644 index 3ddb515bf..000000000 --- a/dist/linux/envs/fedora_mcode.sh +++ /dev/null @@ -1,2 +0,0 @@ -BLD=fed+mcode -DOCKER_IMG="ghdl/ghdl-tools:fedora-llvm-mcode"
\ No newline at end of file diff --git a/dist/linux/envs/ubuntu1204_llvm38.sh b/dist/linux/envs/ubuntu1204_llvm38.sh deleted file mode 100644 index 5f68d2ab0..000000000 --- a/dist/linux/envs/ubuntu1204_llvm38.sh +++ /dev/null @@ -1,2 +0,0 @@ -BLD=ubu1204+llvm-3.8 -DOCKER_IMG="ghdl/ghdl-tools:ubuntu1204-llvm"
\ No newline at end of file diff --git a/dist/linux/envs/ubuntu1404_llvm35.sh b/dist/linux/envs/ubuntu1404_llvm35.sh deleted file mode 100644 index bf4baf236..000000000 --- a/dist/linux/envs/ubuntu1404_llvm35.sh +++ /dev/null @@ -1,2 +0,0 @@ -BLD=ubu1404+llvm-3.5 -DOCKER_IMG="ghdl/ghdl-tools:ubuntu1404-llvm"
\ No newline at end of file diff --git a/dist/linux/envs/ubuntu_mcode.sh b/dist/linux/envs/ubuntu_mcode.sh deleted file mode 100644 index e6f7c3232..000000000 --- a/dist/linux/envs/ubuntu_mcode.sh +++ /dev/null @@ -1,2 +0,0 @@ -BLD=ubu+mcode -DOCKER_IMG="ghdl/ghdl-tools:ubuntu-mcode"
\ No newline at end of file diff --git a/dist/linux/travis-ci.sh b/dist/linux/travis-ci.sh index 1b683833c..e72e2540c 100755 --- a/dist/linux/travis-ci.sh +++ b/dist/linux/travis-ci.sh @@ -1,12 +1,69 @@ -IFS='+' read -ra REFS <<< "$BLD" +#! /bin/sh +# This script is executed in the travis-ci environment. -DBLD=${REFS[1]} -PKG_DTAG=${REFS[0]} -PKG_SHORTCOMMIT="$(echo $TRAVIS_COMMIT | cut -c1-10)" +images=("ghdl/ghdl-tools:ubuntu-mcode" "ghdl/ghdl-tools:ubuntu1404-llvm" "ghdl/ghdl-tools:ubuntu1204-llvm" "ghdl/ghdl-tools:fedora-llvm-mcode") + +#--- image + identifier + compiler + +regular="0+ubuntu+mcode 3+fedora+llvm" +nightly="1+ubuntu1404+llvm-3.5 2+ubuntu1204+llvm-3.8 3+fedora+mcode" +#release=() + +#--- + +. dist/ansi_color.sh + +#disable_color + +thismatrix=regular + +#--- + +task() { + printf "$ANSI_YELLOW[$1| BUILD] $2 $ANSI_NOCOLOR\n" + + IFS='+' read -ra REFS <<< "$2" + DBLD=${REFS[2]} + thisworkdir="../wrk-$1" + cp -r ./ "$thisworkdir" && cd "$thisworkdir" + ./dist/linux/docker-buildtest.sh -i "${images[${REFS[0]}]}" $3-t "$1" -b "$DBLD" -f "ghdl-$PKG_VER-$DBLD-$PKG_TAG-${REFS[1]}-$PKG_SHORTCOMMIT.tgz" + cd "$cloned" + cp "$thisworkdir"/ghdl-*.tgz ./ + cp "$thisworkdir"/log.log "./log_$1.log" +} + +#--- + +PKG_SHORTCOMMIT="$(printf $TRAVIS_COMMIT | cut -c1-10)" PKG_VER=`grep Ghdl_Ver src/version.in | sed -e 's/.*"\(.*\)";/\1/'` PKG_TAG="$TRAVIS_TAG" - -if [ -z "$BUILDTHIS" ]; then BUILDTHIS=$(echo "$TRAVIS_TAG"); fi if [ -z "$TRAVIS_TAG" ]; then PKG_TAG=`date -u +%Y%m%d`; fi -export PKG_FILE="ghdl-$PKG_VER-$DBLD-$PKG_TAG-$PKG_DTAG-$PKG_SHORTCOMMIT.tgz"
\ No newline at end of file +cloned=$(pwd) + +printf "$ANSI_YELLOW[TRAVIS] Running matrix $thismatrix $ANSI_NOCOLOR\n" +eval blds='${'$thismatrix'}' +t=0; for thisbuild in $blds; do + task "$t" "$thisbuild" "$ENABLECOLOR" & + t=$(($t+1)); +done + +printf "$ANSI_YELLOW[TRAVIS] Waiting... $ANSI_NOCOLOR\n" +wait +printf "$ANSI_YELLOW[TRAVIS] Done waiting. Show work dir content: $ANSI_NOCOLOR\n" +ls -la +printf "$ANSI_YELLOW[TRAVIS] Check results $ANSI_NOCOLOR\n" +EXITCODE=0; +t=0; for b in $blds; do + # Read the last line of the log + RESULT[$t]=$(awk '/./{line=$0} END{print line}' "log_$t.log") + # If it did not end with [$t|SUCCESSFUL], break the build + if [ "${RESULT[$t]}" != "[$t|SUCCESSFUL]" ]; then EXITCODE=$(($t+1)); fi + # Anyway, always print the full log + printf "$ANSI_YELLOW[TRAVIS] Print BUILD $t log $ANSI_NOCOLOR\n" + cat "log_$t.log" + t=$(($t+1)); +done + +# The exit code indicates the last broken build (1:bnum) +exit $EXITCODE
\ No newline at end of file |