Subject: Reducing redundant build at Travis?

From: Junio C Hamano <[email-masked]>
Date: Wed, 12 Jul 2017 16:44:12 -0700

I usually try to stay as late as possible to finish all the
integration branches in order before pushing out the result; it is
more efficient to be able to batch things (for humans).  

I however noticed that This often means we would have multiple build
jobs at Travis for branches and builds on Windows often fails
waiting for its response.  Since I tagged the tip of 'maint', and I
wanted to give all the build a fair chance to succeed without other
build jobs starving it of resources, I pushed out 'maint' and the
tag before others, even though I already have all the other
integration branches ready.

Unfortunately, https://travis-ci.org/git/git/builds/ shows that it
does not care if it spawned a job to build the tip of 'maint' and
another for 'v2.13.3' that point at the same thing.

I do not mind this behaviour terribly for Linux builds that never
seem to time out, but it is wasteful.  Here is what I came up with
to skip the build and test on a branch tip that is tagged, but I
suspect this would not actually work (when told to build a tag, I
suspect that it would try to find an exact-match and ends up finding
itself, refusing to do the work).

I also do not quite like the way that I had to add a check like this
for every script: thing in the .travis.yml file (the attached does
not even cover MacOS whose build tends to take a lot longer).  I
suspect that you or others who are better versed with the system may
have better idea to have a single centralized check that avoids a
tip of a branch that is pointed at by a release tag.

Thanks.

 ci/run-linux32-build.sh | 6 ++++++
 ci/run-windows-build.sh | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/ci/run-linux32-build.sh b/ci/run-linux32-build.sh
index e30fb2cddc..ffb5c8fdf1 100755
--- a/ci/run-linux32-build.sh
+++ b/ci/run-linux32-build.sh
@@ -6,6 +6,12 @@
 #   run-linux32-build.sh [host-user-id]
 #
 
+if TAG=$(git describe --exact-match HEAD 2>/dev/null)
+then
+	echo "The tip of the branch is exactly at $TAG"
+	exit 0
+fi
+
 # Update packages to the latest available versions
 linux32 --32bit i386 sh -c '
     apt update >/dev/null &&
diff --git a/ci/run-windows-build.sh b/ci/run-windows-build.sh
index 2d98f6b2f9..74d4819d74 100755
--- a/ci/run-windows-build.sh
+++ b/ci/run-windows-build.sh
@@ -12,6 +12,12 @@ test -z "$GFW_CI_TOKEN" && echo "GFW_CI_TOKEN not defined" && exit
 BRANCH=$1
 COMMIT=$2
 
+if TAG=$(git describe --exact-match "$COMMIT" 2>/dev/null)
+then
+	echo "Tip of $BRANCH exactly at $TAG"
+	exit 0
+fi
+
 gfwci () {
 	local CURL_ERROR_CODE HTTP_CODE
 	CONTENT_FILE=$(mktemp -t "git-windows-ci-XXXXXX")