git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Reducing redundant build at Travis?

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 21, 2017, 16:44 UTC
Message-ID
<xmqqo9sdhh9o.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<333FEA3F-BB43-4183-ADD1-14E73E668EA3@gmail.com>
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
+
Previous: Lars SchneiderNext: Lars Schneider
Message 10 of 12 in “Reducing redundant build at Travis?”
  1. Junio C HamanoJul 12, 2017
  2. Lars SchneiderJul 13, 2017
  3. Junio C HamanoJul 13, 2017
  4. Jeff KingJul 14, 2017
  5. Junio C HamanoJul 14, 2017
  6. Jeff KingJul 14, 2017
  7. Lars SchneiderJul 20, 2017
  8. Junio C HamanoJul 20, 2017
  9. Lars SchneiderJul 21, 2017
  10. Junio C HamanoJul 21, 2017
  11. Lars SchneiderJul 26, 2017
  12. Junio C HamanoJul 26, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.