diff --git a/.travis.yml b/.travis.yml index 4f4f7e80f..6aabe329c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,9 @@ services: matrix: include: - - compiler: "gcc" + - stage: "Build & Deploy" + + compiler: "gcc" dist: xenial env: - ARCH=arm @@ -79,6 +81,10 @@ matrix: env: - EXTRA_SSH=-oHostKeyAlgorithms=+ssh-dss + - stage: "Trigger Next In Pipeline" + env: + - TRIGGER_NEXT_BUILD=true + addons: artifacts: true ssh_known_hosts: @@ -98,6 +104,7 @@ script: - if [[ "$ARCH" == "arm" && "$TRAVIS_OS_NAME" == "linux" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/make_linux_qemu ; fi - if [[ -z "$ARCH" && "$TRAVIS_OS_NAME" == "linux" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/make_linux libiio "$OS_TYPE" "$OS_VERSION" ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/make_darwin; fi + - if [[ "$TRIGGER_NEXT_BUILD" == "true" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/after_deploy; fi notifications: email: @@ -159,6 +166,3 @@ deploy: password: secure: KfORvnPyLlMANLpcwJjcO44Kt6meP614omJk2GloD+B51SuV64O6N31VDOTi2xqioEk9Cajq7tmNte5YoHVUjL9iWFsBblpzxZoXcy40dn4pFN0kMiE8scszxckbDwuBZhokUVZ2fhfLKf/8xORcwjS3vKqSj5HwQKKvVgukSbQ= distributions: sdist - -after_deploy: - - ${TRAVIS_BUILD_DIR}/CI/travis/after_deploy diff --git a/CI/travis/after_deploy b/CI/travis/after_deploy index 66705aaaa..4acdeb4b9 100755 --- a/CI/travis/after_deploy +++ b/CI/travis/after_deploy @@ -1,5 +1,7 @@ #!/bin/sh -e +TRIGGERING_NEXT_BUILD=true + . CI/travis/lib.sh should_trigger_next_builds "$TRAVIS_BRANCH" || exit 0 diff --git a/CI/travis/jobs_running_cnt.py b/CI/travis/jobs_running_cnt.py deleted file mode 100644 index e5f412112..000000000 --- a/CI/travis/jobs_running_cnt.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/python - -import os -import sys -import urllib2 -import json - -# This is pretty constant, but allow it to be overriden via env-var -url = os.getenv('TRAVIS_API_URL', 'https://api.travis-ci.org') - -if (not url.lower().startswith("https://")): - print (0) - sys.exit(0) - -ci_token = os.getenv('TRAVIS_API_TOKEN') -build_id = os.getenv('TRAVIS_BUILD_ID') - -headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Travis-API-Version': "3", - 'Authorization': "token {0}".format(ci_token) -} - -# Codacy's bandit linter may complain that we haven't validated -# this URL for permitted schemes; we have validated this a few lines above -req = urllib2.Request("{0}/build/{1}/jobs".format(url, build_id), - headers=headers) - -response = urllib2.urlopen(req).read() -json_r = json.loads(response.decode('utf-8')) - -jobs_running = 0 -for job in json_r['jobs']: - # bump number of jobs higher, so nothing triggers - if (job['state'] in [ 'canceled', 'failed' ]): - jobs_running += 99 - break - if (job['state'] in [ 'started', 'created', 'queued', 'received' ]): - jobs_running += 1 - -print (jobs_running) diff --git a/CI/travis/lib.sh b/CI/travis/lib.sh index 1476b9c91..3a7ef30e4 100644 --- a/CI/travis/lib.sh +++ b/CI/travis/lib.sh @@ -1,12 +1,16 @@ #!/bin/sh -e +if [ "$TRIGGER_NEXT_BUILD" = "true" ] && [ "$TRIGGERING_NEXT_BUILD" != "true" ] ; then + exit 0 +fi + export TRAVIS_API_URL="https://api.travis-ci.org" LOCAL_BUILD_DIR=${LOCAL_BUILD_DIR:-build} HOMEBREW_NO_INSTALL_CLEANUP=1 export HOMEBREW_NO_INSTALL_CLEANUP -COMMON_SCRIPTS="jobs_running_cnt.py inside_docker.sh" +COMMON_SCRIPTS="inside_docker.sh" echo_red() { printf "\033[1;31m$*\033[m\n"; } echo_green() { printf "\033[1;32m$*\033[m\n"; } @@ -65,17 +69,6 @@ should_trigger_next_builds() { [ "$TRAVIS_PULL_REQUEST" = "false" ] || return 1 pipeline_branch "$branch" || return 1 - - local python_script="$(get_script_path jobs_running_cnt.py)" - if [ -z "$python_script" ] ; then - echo "Could not find 'jobs_running_cnt.py'" - return 1 - fi - - local jobs_cnt=$(python $python_script) - - # Trigger next job if we are the last job running - [ "$jobs_cnt" = "1" ] } trigger_build() {