git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Lars Schneider <larsxschneider@gmail.com>
Cc: Jeff King <peff@peff.net>, Git Users <git@vger.kernel.org>
Subject: Re: Reducing redundant build at Travis?
Date: Fri, 21 Jul 2017 09:44:03 -0700	[thread overview]
Message-ID: <xmqqo9sdhh9o.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <333FEA3F-BB43-4183-ADD1-14E73E668EA3@gmail.com> (Lars Schneider's message of "Fri, 21 Jul 2017 18:11:26 +0200")

Lars Schneider <larsxschneider@gmail.com> 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
+

  reply	other threads:[~2017-07-21 16:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12 23:44 Reducing redundant build at Travis? Junio C Hamano
2017-07-13 21:21 ` Lars Schneider
2017-07-13 21:53   ` Junio C Hamano
2017-07-14 12:24     ` Jeff King
2017-07-14 14:54       ` Junio C Hamano
2017-07-14 15:32         ` Jeff King
2017-07-20  8:18           ` Lars Schneider
2017-07-20 15:16             ` Junio C Hamano
2017-07-21 16:11               ` Lars Schneider
2017-07-21 16:44                 ` Junio C Hamano [this message]
2017-07-26 16:43                   ` Lars Schneider
2017-07-26 18:08                     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqo9sdhh9o.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=larsxschneider@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).