Re: Reducing redundant build at Travis?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Lars Schneider <larsxschneider@xxxxxxxxx> writes:

> To answer your question: I don't see an easy solution to the problem.

That's OK.  Thanks for digging.

I am wondering if the attached would be acceptable as a minimum
impact patch to address this issue.  

I think I got the "are we building a tag, or are we building a
branch that happens to be at a tag?" logic right, but I have no idea
what I am writing in the "script" sections (I am just assuming that
these lines are squashed into a line by removing line-breaks and
become a single loooong shell script), and can certainly use guiding
hands.  I didn't bother skipping the work done in before_script.

Thanks.

diff --git a/.travis.yml b/.travis.yml
index 278943d14a..55af619830 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -53,6 +53,7 @@ matrix:
       script:
         - >
           test "$TRAVIS_REPO_SLUG" != "git/git" ||
+          ci/skip-branch-tip-with-tag.sh ||
           ci/run-windows-build.sh $TRAVIS_BRANCH $(git rev-parse HEAD)
       after_failure:
     - env: Linux32
@@ -65,6 +66,7 @@ matrix:
       before_script:
       script:
         - >
+          ci/skip-branch-tip-with-tag.sh ||
           docker run
           --interactive
           --env DEVELOPER
@@ -145,9 +147,10 @@ before_script: make --jobs=2
 
 script:
   - >
+    ci/skip-branch-tip-with-tag.sh || {
     mkdir -p $HOME/travis-cache;
     ln -s $HOME/travis-cache/.prove t/.prove;
-    make --quiet test;
+    make --quiet test; }
 
 after_failure:
   - >
diff --git a/ci/skip-branch-tip-with-tag.sh b/ci/skip-branch-tip-with-tag.sh
new file mode 100755
index 0000000000..a57e724b35
--- /dev/null
+++ b/ci/skip-branch-tip-with-tag.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Sometimes, a branch is pushed at the same time the tag that points
+# at the same commit as the tip of the branch is pushed, and building
+# both at the same time is a waste.
+#
+# Travis gives a tagname e.g. v2.14.0 in $TRAVIS_BRANCH when
+# the build is triggered by a push to a tag.  Let's see if
+# $TRAVIS_BRANCH is exactly at a tag, and if so, if it is 
+# different from $TRAVIS_BRANCH.  That way, we can tell if
+# we are building the tip of a branch that is tagged---and
+# we can skip the build because we won't be skipping a build
+# of a tag.
+
+if TAG=$(git describe --exact-match "$TRAVIS_BRANCH" 2>/dev/null) &&
+	$TAG != $TRAVIS_BRANCH
+then
+	echo "Tip of $TRAVIS_BRANCH is exactly at $TAG"
+	exit 0
+else
+	exit 1
+fi
+



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux