From 609a3054f655a97e172b4705d0db8925f4198fc4 Mon Sep 17 00:00:00 2001 From: Paulchen-Panther Date: Mon, 10 Jun 2019 16:50:22 +0200 Subject: [PATCH] Microsoft Azure Pipeline added (mit unbegrenzten Minuten und mit bis zu 10 kostenlosen parallelen Jobs) Signed-off-by: Paulchen-Panther --- .azure.yml | 48 +++++++++++++++++++++++ .ci/ci_build.sh | 80 +++++++++++++++++++++++++++++++++++++++ .ci/ci_deploy.sh | 67 ++++++++++++++++++++++++++++++++ .ci/ci_install.sh | 42 ++++++++++++++++++++ .travis.yml | 6 +-- .travis/travis_build.sh | 67 -------------------------------- .travis/travis_deploy.sh | 64 ------------------------------- .travis/travis_install.sh | 26 ------------- README.md | 2 + 9 files changed, 242 insertions(+), 160 deletions(-) create mode 100644 .azure.yml create mode 100755 .ci/ci_build.sh create mode 100755 .ci/ci_deploy.sh create mode 100755 .ci/ci_install.sh delete mode 100755 .travis/travis_build.sh delete mode 100755 .travis/travis_deploy.sh delete mode 100755 .travis/travis_install.sh diff --git a/.azure.yml b/.azure.yml new file mode 100644 index 00000000..74604fea --- /dev/null +++ b/.azure.yml @@ -0,0 +1,48 @@ +jobs: +- job: Linux + pool: + vmImage: 'ubuntu-16.04' + strategy: + matrix: + AMD64 (x64): + dockerTag: 'amd64' + dockerName: 'Debian Stretch (AMD64)' + i386 (x86): + dockerTag: 'i386' + dockerName: 'Debian Stretch (i386)' + ARMv6hf (Raspberry Pi v1 & ZERO): + dockerTag: 'armv6hf' + dockerName: 'Debian Stretch (Raspberry Pi v1 & ZERO)' + platform: 'rpi' + ARMv7hf (Raspberry Pi 2 & 3): + dockerTag: 'armv7hf' + dockerName: 'Debian Stretch (Raspberry Pi 2 & 3)' + platform: 'rpi' + ARMv8 (Generic AARCH64): + dockerTag: 'aarch64' + dockerName: 'ARMv8 (Generic AARCH64)' + platform: 'amlogic' + steps: + - checkout: self + submodules: recursive + - bash: ./.ci/ci_build.sh + displayName: 'Build $(dockerName)' + env: + DOCKER_TAG: $(dockerTag) + DOCKER_NAME: $(dockerName) + PLATFORM: $(platform) + - bash: ./.ci/ci_deploy.sh + displayName: 'Upload $(dockerName)' + +- job: macOS + pool: + vmImage: 'macOS-10.13' + steps: + - checkout: self + submodules: recursive + - bash: ./.ci/ci_install.sh + displayName: 'Install dependencies' + - bash: ./.ci/ci_build.sh + displayName: 'Build macOS 10.13' + - bash: ./.ci/ci_deploy.sh + displayName: 'Upload macOS 10.13' diff --git a/.ci/ci_build.sh b/.ci/ci_build.sh new file mode 100755 index 00000000..016dae6e --- /dev/null +++ b/.ci/ci_build.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +# detect CI +if [ -n "${TRAVIS-}" ]; then + # Travis-CI + CI_NAME="$(echo "$TRAVIS_OS_NAME" | tr '[:upper:]' '[:lower:]')" + CI_BUILD_DIR="$TRAVIS_BUILD_DIR" +elif [ "$SYSTEM_COLLECTIONID" != "" ]; then + # Azure Pipelines + CI_NAME="$(echo "$AGENT_OS" | tr '[:upper:]' '[:lower:]')" + CI_BUILD_DIR="$BUILD_SOURCESDIRECTORY" +else + # for executing in non ci environment + CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')" +fi + +# set environment variables +BUILD_TYPE="Debug" +PACKAGES="" +[ -z "${PLATFORM}" ] && PLATFORM="x11" + +# Detect number of processor cores +# default is 4 jobs +if [[ "$CI_NAME" == 'osx' || "$CI_NAME" == 'darwin' ]]; then + JOBS=$(sysctl -n hw.ncpu) + PLATFORM=osx +elif [[ "$CI_NAME" == 'linux' ]]; then + JOBS=$(nproc) +fi +echo "compile jobs: ${JOBS:=4}" + +# Determine cmake build type; tag builds are Release, else Debug +if [ -n "${TRAVIS_TAG:-}" ] || [[ $BUILD_SOURCEBRANCH == *"refs/tags"* ]]; then + BUILD_TYPE=Release +fi + +# Determine package creation; True for cron/schedule and tag builds +if [ "${TRAVIS_EVENT_TYPE:-}" == 'cron' ] || [ -n "${TRAVIS_TAG:-}" ] || [[ $BUILD_REASON == "Schedule" ]] || [[ $BUILD_SOURCEBRANCH == *"refs/tags"* ]]; then + PACKAGES="package" +fi + +# Determie -dev appends to platform; +# Commented because tests are currently broken +# [ "${TRAVIS_EVENT_TYPE:-}" != 'cron' -a -z "${TRAVIS_TAG:-}" ] && PLATFORM=${PLATFORM}-dev + +# Build the package on osx or docker for linux +if [[ "$CI_NAME" == 'osx' || "$CI_NAME" == 'darwin' ]]; then + # compile prepare + mkdir build || exit 1 + mkdir ${CI_BUILD_DIR}/deploy || exit 1 + cd build + cmake -DPLATFORM=$PLATFORM -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=/usr .. || exit 2 + make -j ${JOBS} ${PACKAGES} || exit 3 + echo "---> Copy binaries and packages to folder: ${CI_BUILD_DIR}/deploy" + cp -v ${CI_BUILD_DIR}/build/bin/h* ${CI_BUILD_DIR}/deploy/ 2>/dev/null || : && + cp -v ${CI_BUILD_DIR}/build/Hyperion-* ${CI_BUILD_DIR}/deploy/ 2>/dev/null || : && + exit 0; +elif [[ "$CI_NAME" == 'linux' ]]; then + echo "Compile Hyperion with DOCKER_TAG = ${DOCKER_TAG} and friendly name DOCKER_NAME = ${DOCKER_NAME}" + # take ownership of deploy dir + mkdir ${CI_BUILD_DIR}/deploy + + # run docker + docker run --rm \ + -v "${CI_BUILD_DIR}/deploy:/deploy" \ + -v "${CI_BUILD_DIR}:/source:ro" \ + hyperionproject/hyperion-ci:$DOCKER_TAG \ + /bin/bash -c "mkdir build && cp -r source/. /build && + cd /build && mkdir build && cd build && + cmake -DPLATFORM=${PLATFORM} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} .. || exit 2 && + make -j ${JOBS} ${PACKAGES} || exit 3 && + echo '---> Copy binaries and packages to host folder: ${CI_BUILD_DIR}/deploy' && + cp -v /build/build/bin/h* /deploy/ 2>/dev/null || : && + cp -v /build/build/Hyperion-* /deploy/ 2>/dev/null || : && + exit 0; + exit 1 " || { echo "---> Hyperion compilation failed! Abort"; exit 4; } + + # overwrite file owner to current user + sudo chown -fR $(stat -c "%U:%G" ${CI_BUILD_DIR}/deploy) ${CI_BUILD_DIR}/deploy +fi diff --git a/.ci/ci_deploy.sh b/.ci/ci_deploy.sh new file mode 100755 index 00000000..df3ef780 --- /dev/null +++ b/.ci/ci_deploy.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# detect CI +if [ -n "${TRAVIS-}" ]; then + # Travis-CI + CI_NAME="$(echo "$TRAVIS_OS_NAME" | tr '[:upper:]' '[:lower:]')" + CI_BUILD_DIR="$TRAVIS_BUILD_DIR" +elif [ "$SYSTEM_COLLECTIONID" != "" ]; then + # Azure Pipelines + CI_NAME="$(echo "$AGENT_OS" | tr '[:upper:]' '[:lower:]')" + CI_BUILD_DIR="$BUILD_SOURCESDIRECTORY" +else + # for executing in non ci environment + CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')" +fi + +# sf_upload +# { +# echo "Uploading following files: ${1} to dir /hyperion-project/${2}" +# +# } + +# append current Date to filename (just packages no binaries) +appendDate() +{ + D=$(date +%Y-%m-%d) + for F in $CI_BUILD_DIR/deploy/Hy* + do + mv "$F" "${F%.*}-$D.${F##*.}" + done +} + +# append friendly name (just packages no binaries) +appendName() +{ + for F in $CI_BUILD_DIR/deploy/Hy* + do + mv "$F" "${F%.*}-($DOCKER_NAME).${F##*.}" + done +} + +# get all files to deploy (just packages no binaries) +getFiles() +{ + FILES="" + for f in $CI_BUILD_DIR/deploy/Hy*; + do FILES+="${f} "; + done; +} + +if [[ $CI_NAME == 'linux' || "$CI_NAME" == 'osx' || "$CI_NAME" == 'darwin' ]]; then + if [[ -n $TRAVIS_TAG ]] || [[ $BUILD_SOURCEBRANCH == *"refs/tags"* ]]; then + echo "tag upload" + appendName + appendDate + getFiles + # sf_upload $FILES release + elif [[ $TRAVIS_EVENT_TYPE == 'cron' ]] || [[ $BUILD_REASON == "Schedule" ]]; then + echo "cron/schedule upload" + appendName + appendDate + getFiles + # sf_upload $FILES dev/alpha + else + echo "Direct pushed no upload, PRs not possible" + fi +fi diff --git a/.ci/ci_install.sh b/.ci/ci_install.sh new file mode 100755 index 00000000..7efa31d4 --- /dev/null +++ b/.ci/ci_install.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# detect CI +if [ -n "${TRAVIS-}" ]; then + # Travis-CI + CI_NAME="$(echo "$TRAVIS_OS_NAME" | tr '[:upper:]' '[:lower:]')" +elif [ "$SYSTEM_COLLECTIONID" != "" ]; then + # Azure Pipelines + CI_NAME="$(echo "$AGENT_OS" | tr '[:upper:]' '[:lower:]')" +else + # for executing in non ci environment + CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')" +fi + +function installAndUpgrade() +{ + arr=("$@") + for i in "${arr[@]}"; + do + list_output=`brew list | grep $i` + outdated_output=`brew outdated | grep $i` + + if [[ ! -z "$list_output" ]]; then + if [[ ! -z "$outdated_output" ]]; then + brew upgrade $i + fi + else + brew install $i + fi + done +} + +# install osx deps for hyperion compile +if [[ $CI_NAME == 'osx' || $CI_NAME == 'darwin' ]]; then + echo "Install dependencies" + brew update + dependencies=("qt5" "python" "libusb" "cmake" "doxygen") + installAndUpgrade "${dependencies[@]}" +elif [[ $CI_NAME != 'linux' ]]; then + echo "Unsupported platform: $CI_NAME" + exit 5 +fi diff --git a/.travis.yml b/.travis.yml index 3b6ee5fc..a3a3c573 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ notifications: language: cpp before_install: - - ./.travis/travis_install.sh + - ./.ci/ci_install.sh jobs: include: @@ -54,7 +54,7 @@ jobs: - HOMEBREW_CACHE=$HOME/brew-cache script: - - ./.travis/travis_build.sh + - ./.ci/ci_build.sh after_success: - - ./.travis/travis_deploy.sh + - ./.ci/ci_deploy.sh diff --git a/.travis/travis_build.sh b/.travis/travis_build.sh deleted file mode 100755 index c7eb7768..00000000 --- a/.travis/travis_build.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -# for executing in non travis environment -[ -z "$TRAVIS_OS_NAME" ] && TRAVIS_OS_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')" - -if [ -z "${PLATFORM}" ]; then - PLATFORM=x86 -fi -BUILD_TYPE=Debug -PACKAGES="" - -# Detect number of processor cores -# default is 4 jobs -if [[ "$TRAVIS_OS_NAME" == 'osx' || "$TRAVIS_OS_NAME" == 'darwin' ]] -then - JOBS=$(sysctl -n hw.ncpu) - PLATFORM=osx -elif [[ "$TRAVIS_OS_NAME" == 'linux' ]] -then - JOBS=$(nproc) -fi -echo "compile jobs: ${JOBS:=4}" - -# Determine cmake build type; tag builds are Release, else Debug -[ -n "${TRAVIS_TAG:-}" ] && BUILD_TYPE=Release - -# Determine package creation; True for cron and tag builds -# Commented because tests are currently broken -# [ "${TRAVIS_EVENT_TYPE:-}" == 'cron' ] || [ -n "${TRAVIS_TAG:-}" ] && PACKAGES=package - -# Determie -dev appends to platform; -# [ "${TRAVIS_EVENT_TYPE:-}" != 'cron' -a -z "${TRAVIS_TAG:-}" ] && PLATFORM=${PLATFORM}-dev - -# Build the package on osx -if [[ "$TRAVIS_OS_NAME" == 'osx' || "$TRAVIS_OS_NAME" == 'darwin' ]] -then - # compile prepare - mkdir build || exit 1 - cd build - cmake -DPLATFORM=$PLATFORM -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=/usr .. || exit 2 - make -j ${JOBS} || exit 3 -fi - -# Build the package with docker -if [[ $TRAVIS_OS_NAME == 'linux' ]] -then - echo "Compile Hyperion with DOCKER_TAG = ${DOCKER_TAG} and friendly name DOCKER_NAME = ${DOCKER_NAME}" - # take ownership of deploy dir - mkdir $TRAVIS_BUILD_DIR/deploy - # run docker - docker run --rm \ - -v "${TRAVIS_BUILD_DIR}/deploy:/deploy" \ - -v "${TRAVIS_BUILD_DIR}:/source:ro" \ - hyperionproject/hyperion-ci:$DOCKER_TAG \ - /bin/bash -c "mkdir build && cp -r /source/. /build && - cd /build && mkdir build && cd build && - cmake -DPLATFORM=${PLATFORM} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} .. || exit 2 && - make -j $(nproc) ${PACKAGES} || exit 3 && - echo '---> Copy binaries and packages to host folder: ${TRAVIS_BUILD_DIR}/deploy' && - cp -v /build/build/bin/h* /deploy/ 2>/dev/null || : && - cp -v /build/build/Hyperion-* /deploy/ 2>/dev/null || : && - exit 0; - exit 1 " || { echo "---> Hyperion compilation failed! Abort"; exit 4; } - - # overwrite file owner to current user - sudo chown -fR $(stat -c "%U:%G" $TRAVIS_BUILD_DIR/deploy) $TRAVIS_BUILD_DIR/deploy -fi diff --git a/.travis/travis_deploy.sh b/.travis/travis_deploy.sh deleted file mode 100755 index 2f41c285..00000000 --- a/.travis/travis_deploy.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -# sf_upload -sf_upload() -{ -echo "Uploading following files: ${1} -to dir /hyperion-project/${2}" - - /usr/bin/expect <<-EOD - spawn scp $1hyperionsf37@frs.sourceforge.net:/home/frs/project/hyperion-project/$2 - expect "*(yes/no)*" - send "yes\r" - expect "*password:*" - send "$SFPW\r" - expect eof - EOD -} - -# append current Date to filename (just packages no binaries) -appendDate() -{ - D=$(date +%Y-%m-%d) - for F in $TRAVIS_BUILD_DIR/deploy/Hy* - do - mv "$F" "${F%.*}-$D.${F##*.}" - done -} - -# append friendly name (just packages no binaries) -appendName() -{ - for F in $TRAVIS_BUILD_DIR/deploy/Hy* - do - mv "$F" "${F%.*}-($DOCKER_NAME).${F##*.}" - done -} - -# get all files to deploy (just packages no binaries) -getFiles() -{ - FILES="" - for f in $TRAVIS_BUILD_DIR/deploy/Hy*; - do FILES+="${f} "; - done; -} - -if [[ $TRAVIS_OS_NAME == 'linux' ]]; then - if [[ -n $TRAVIS_TAG ]]; then - echo "tag upload" - appendName - appendDate - getFiles - sf_upload $FILES release - elif [[ $TRAVIS_EVENT_TYPE == 'cron' ]]; then - echo "cron upload" - appendName - appendDate - getFiles - sf_upload $FILES dev/alpha - else - echo "Direct pushed no upload, PRs not possible" - #sf_upload $FILES pr - fi -fi diff --git a/.travis/travis_install.sh b/.travis/travis_install.sh deleted file mode 100755 index 414bd412..00000000 --- a/.travis/travis_install.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# for executing in non travis environment -[ -z "$TRAVIS_OS_NAME" ] && TRAVIS_OS_NAME="$( uname -s | tr '[:upper:]' '[:lower:]' )" - -# install osx deps for hyperion compile -if [[ $TRAVIS_OS_NAME == 'osx' || $TRAVIS_OS_NAME == 'darwin' ]] -then - echo "Install OSX deps" - brew update - brew install qt5 || true - brew upgrade python3 || true - brew upgrade libusb || true - brew upgrade cmake || true - brew install doxygen || true - -# install linux deps for hyperion compile -elif [[ $TRAVIS_OS_NAME == 'linux' ]] -then - echo "Install linux deps" - #sudo apt-get -qq update - #sudo apt-get install -qq -y qtbase5-dev libqt5serialport5-dev libusb-1.0-0-dev python3-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev doxygen expect -else - echo "Unsupported platform: $TRAVIS_OS_NAME" - exit 5 -fi diff --git a/README.md b/README.md index 2dcacdf9..287ab94f 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ + +