Skip to content

Commit

Permalink
ci,build: split trigger-next-build into it's own stage
Browse files Browse the repository at this point in the history
This change creates a new stage for triggering the next build in the
pipeline and removes the old python script that checks if this is the last
job in the build.

At the current time, I am not sure if the triggering will happen if the
previous stage succeeded or not. But even so, it should be ok, since this
shouldn't occur too often, and would only happen on master and release
branches (which should be stable; and if they aren't this should show).

Also, one main advantage of this approach is that we reduce access to
Github's API which has a rate-limit.

Signed-off-by: Alexandru Ardelean <[email protected]>
  • Loading branch information
commodo committed Mar 31, 2020
1 parent c597156 commit 6f7ae64
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 58 deletions.
12 changes: 8 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ services:

matrix:
include:
- compiler: "gcc"
- stage: "Build & Deploy"

compiler: "gcc"
dist: xenial
env:
- ARCH=arm
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -159,6 +166,3 @@ deploy:
password:
secure: KfORvnPyLlMANLpcwJjcO44Kt6meP614omJk2GloD+B51SuV64O6N31VDOTi2xqioEk9Cajq7tmNte5YoHVUjL9iWFsBblpzxZoXcy40dn4pFN0kMiE8scszxckbDwuBZhokUVZ2fhfLKf/8xORcwjS3vKqSj5HwQKKvVgukSbQ=
distributions: sdist

after_deploy:
- ${TRAVIS_BUILD_DIR}/CI/travis/after_deploy
2 changes: 2 additions & 0 deletions CI/travis/after_deploy
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh -e

TRIGGERING_NEXT_BUILD=true

. CI/travis/lib.sh

should_trigger_next_builds "$TRAVIS_BRANCH" || exit 0
Expand Down
42 changes: 0 additions & 42 deletions CI/travis/jobs_running_cnt.py

This file was deleted.

17 changes: 5 additions & 12 deletions CI/travis/lib.sh
Original file line number Diff line number Diff line change
@@ -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"; }
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 6f7ae64

Please sign in to comment.