{"thread":{"id":"46731","subject":"[PATCH v1 0/2] travis-ci: dedicated scripts + skip duplicated builds","startedAt":"2017-09-10T14:44:38Z","lastAt":"2017-09-12T11:46:06Z","messageCount":6,"participants":["larsxschneider@gmail.com","Junio C Hamano","SZEDER Gábor","Lars Schneider"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"327834","messageId":"20170910144429.47346-1-larsxschneider@gmail.com","threadId":"46731","inReplyTo":null,"subject":"[PATCH v1 0/2] travis-ci: dedicated scripts + skip duplicated builds","fromName":"","fromEmail":"larsxschneider@gmail.com","sentAt":"2017-09-10T14:44:27Z","receivedAt":"2017-09-10T14:44:38Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"From: Lars Schneider <larsxschneider@gmail.com>\n\nHi,\n\nthe patches were previously discussed here:\nhttps://public-inbox.org/git/xmqqinifrrzh.fsf@gitster.mtv.corp.google.com/#t\n\nOver there Junio posted the original patch to skip a build on Travis\nCI. The patch became 2/2 in this series.\n\nCheers,\nLars\n\nBase Ref: master\nWeb-Diff: https://github.com/larsxschneider/git/commit/65ab003ec9\nCheckout: git fetch https://github.com/larsxschneider/git travisci/move-into-ci-v1 && git checkout 65ab003ec9\n\nLars Schneider (2):\n  travis-ci: move Travis CI code into dedicated scripts\n  travis-ci: skip a branch build if equal tag is present\n\n .travis.yml                | 88 +++++-----------------------------------------\n ci/install-dependencies.sh | 43 ++++++++++++++++++++++\n ci/lib-travisci.sh         | 28 +++++++++++++++\n ci/print-test-failures.sh  | 18 ++++++++++\n ci/run-build.sh            |  8 +++++\n ci/run-linux32-docker.sh   | 23 ++++++++++++\n ci/run-static-analysis.sh  |  8 +++++\n ci/run-tests.sh            | 10 ++++++\n ci/run-windows-build.sh    |  2 ++\n ci/test-documentation.sh   |  4 ++-\n 10 files changed, 151 insertions(+), 81 deletions(-)\n create mode 100755 ci/install-dependencies.sh\n create mode 100755 ci/lib-travisci.sh\n create mode 100755 ci/print-test-failures.sh\n create mode 100755 ci/run-build.sh\n create mode 100755 ci/run-linux32-docker.sh\n create mode 100755 ci/run-static-analysis.sh\n create mode 100755 ci/run-tests.sh\n\n\nbase-commit: 3ec7d702a89c647ddf42a59bc3539361367de9d5\n--\n2.14.1\n\n"},{"id":"327835","messageId":"20170910144429.47346-2-larsxschneider@gmail.com","threadId":"46731","inReplyTo":"20170910144429.47346-1-larsxschneider@gmail.com","subject":"[PATCH v1 1/2] travis-ci: move Travis CI code into dedicated scripts","fromName":"","fromEmail":"larsxschneider@gmail.com","sentAt":"2017-09-10T14:44:28Z","receivedAt":"2017-09-10T14:44:41Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"From: Lars Schneider <larsxschneider@gmail.com>\n\nMost of the Travis CI commands are in the '.travis.yml'. The yml format\ndoes not support functions and therefore code duplication is necessary\nto run commands across all builds.\n\nTo fix this, add a library for common CI functions. Move all Travis CI\ncode into dedicated scripts and make them call the library first.\n\nSigned-off-by: Lars Schneider <larsxschneider@gmail.com>\n---\n .travis.yml                | 88 +++++-----------------------------------------\n ci/install-dependencies.sh | 43 ++++++++++++++++++++++\n ci/lib-travisci.sh         |  5 +++\n ci/print-test-failures.sh  | 18 ++++++++++\n ci/run-build.sh            |  8 +++++\n ci/run-linux32-docker.sh   | 23 ++++++++++++\n ci/run-static-analysis.sh  |  8 +++++\n ci/run-tests.sh            | 10 ++++++\n ci/run-windows-build.sh    |  2 ++\n ci/test-documentation.sh   |  4 ++-\n 10 files changed, 128 insertions(+), 81 deletions(-)\n create mode 100755 ci/install-dependencies.sh\n create mode 100755 ci/lib-travisci.sh\n create mode 100755 ci/print-test-failures.sh\n create mode 100755 ci/run-build.sh\n create mode 100755 ci/run-linux32-docker.sh\n create mode 100755 ci/run-static-analysis.sh\n create mode 100755 ci/run-tests.sh\n\ndiff --git a/.travis.yml b/.travis.yml\nindex 278943d14a..fead995edd 100644\n--- a/.travis.yml\n+++ b/.travis.yml\n@@ -61,23 +61,8 @@ matrix:\n       services:\n         - docker\n       before_install:\n-        - docker pull daald/ubuntu32:xenial\n       before_script:\n-      script:\n-        - >\n-          docker run\n-          --interactive\n-          --env DEVELOPER\n-          --env DEFAULT_TEST_TARGET\n-          --env GIT_PROVE_OPTS\n-          --env GIT_TEST_OPTS\n-          --env GIT_TEST_CLONE_2GB\n-          --volume \"${PWD}:/usr/src/git\"\n-          daald/ubuntu32:xenial\n-          /usr/src/git/ci/run-linux32-build.sh $(id -u $USER)\n-        # Use the following command to debug the docker build locally:\n-        # $ docker run -itv \"${PWD}:/usr/src/git\" --entrypoint /bin/bash daald/ubuntu32:xenial\n-        # root@container:/# /usr/src/git/ci/run-linux32-build.sh\n+      script: ci/run-linux32-docker.sh\n     - env: Static Analysis\n       os: linux\n       compiler:\n@@ -86,9 +71,8 @@ matrix:\n           packages:\n           - coccinelle\n       before_install:\n-      script:\n-        # \"before_script\" that builds Git is inherited from base job\n-        - make coccicheck\n+      # \"before_script\" that builds Git is inherited from base job\n+      script: ci/run-static-analysis.sh\n       after_failure:\n     - env: Documentation\n       os: linux\n@@ -99,70 +83,14 @@ matrix:\n           - asciidoc\n           - xmlto\n       before_install:\n-      before_script: gem install asciidoctor\n+      before_script:\n       script: ci/test-documentation.sh\n       after_failure:\n \n-before_install:\n-  - >\n-    case \"${TRAVIS_OS_NAME:-linux}\" in\n-    linux)\n-      export GIT_TEST_HTTPD=YesPlease\n-\n-      mkdir --parents custom/p4\n-      pushd custom/p4\n-        wget --quiet http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION/bin.linux26x86_64/p4d\n-        wget --quiet http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION/bin.linux26x86_64/p4\n-        chmod u+x p4d\n-        chmod u+x p4\n-        export PATH=\"$(pwd):$PATH\"\n-      popd\n-      mkdir --parents custom/git-lfs\n-      pushd custom/git-lfs\n-        wget --quiet https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz\n-        tar --extract --gunzip --file \"git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz\"\n-        cp git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs .\n-        export PATH=\"$(pwd):$PATH\"\n-      popd\n-      ;;\n-    osx)\n-      brew update --quiet\n-      # Uncomment this if you want to run perf tests:\n-      # brew install gnu-time\n-      brew install git-lfs gettext\n-      brew link --force gettext\n-      brew install caskroom/cask/perforce\n-      ;;\n-    esac;\n-    echo \"$(tput setaf 6)Perforce Server Version$(tput sgr0)\";\n-    p4d -V | grep Rev.;\n-    echo \"$(tput setaf 6)Perforce Client Version$(tput sgr0)\";\n-    p4 -V | grep Rev.;\n-    echo \"$(tput setaf 6)Git-LFS Version$(tput sgr0)\";\n-    git-lfs version;\n-\n-before_script: make --jobs=2\n-\n-script:\n-  - >\n-    mkdir -p $HOME/travis-cache;\n-    ln -s $HOME/travis-cache/.prove t/.prove;\n-    make --quiet test;\n-\n-after_failure:\n-  - >\n-    : '<-- Click here to see detailed test output!                                                        ';\n-    for TEST_EXIT in t/test-results/*.exit;\n-    do\n-      if [ \"$(cat \"$TEST_EXIT\")\" != \"0\" ];\n-      then\n-        TEST_OUT=\"${TEST_EXIT%exit}out\";\n-        echo \"------------------------------------------------------------------------\";\n-        echo \"$(tput setaf 1)${TEST_OUT}...$(tput sgr0)\";\n-        echo \"------------------------------------------------------------------------\";\n-        cat \"${TEST_OUT}\";\n-      fi;\n-    done;\n+before_install: ci/install-dependencies.sh\n+before_script: ci/run-build.sh\n+script: ci/run-tests.sh\n+after_failure: ci/print-test-failures.sh\n \n notifications:\n   email: false\ndiff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh\nnew file mode 100755\nindex 0000000000..067e6eb702\n--- /dev/null\n+++ b/ci/install-dependencies.sh\n@@ -0,0 +1,43 @@\n+#!/usr/bin/env bash\n+#\n+# Install dependencies required to build and test Git on Linux and macOS\n+#\n+\n+. ${0%/*}/lib-travisci.sh\n+\n+case \"${TRAVIS_OS_NAME:-linux}\" in\n+\tlinux)\n+\t\texport GIT_TEST_HTTPD=YesPlease\n+\n+\t\tmkdir --parents custom/p4\n+\t\tpushd custom/p4\n+\t\t\twget --quiet http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION/bin.linux26x86_64/p4d\n+\t\t\twget --quiet http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION/bin.linux26x86_64/p4\n+\t\t\tchmod u+x p4d\n+\t\t\tchmod u+x p4\n+\t\t\texport PATH=\"$(pwd):$PATH\"\n+\t\tpopd\n+\t\tmkdir --parents custom/git-lfs\n+\t\tpushd custom/git-lfs\n+\t\t\twget --quiet https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz\n+\t\t\ttar --extract --gunzip --file \"git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz\"\n+\t\t\tcp git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs .\n+\t\t\texport PATH=\"$(pwd):$PATH\"\n+\t\tpopd\n+\t;;\n+\tosx)\n+\t\tbrew update --quiet\n+\t\t# Uncomment this if you want to run perf tests:\n+\t\t# brew install gnu-time\n+\t\tbrew install git-lfs gettext\n+\t\tbrew link --force gettext\n+\t\tbrew install caskroom/cask/perforce\n+\t;;\n+esac\n+\n+echo \"$(tput setaf 6)Perforce Server Version$(tput sgr0)\"\n+p4d -V | grep Rev.\n+echo \"$(tput setaf 6)Perforce Client Version$(tput sgr0)\"\n+p4 -V | grep Rev.\n+echo \"$(tput setaf 6)Git-LFS Version$(tput sgr0)\"\n+git-lfs version\ndiff --git a/ci/lib-travisci.sh b/ci/lib-travisci.sh\nnew file mode 100755\nindex 0000000000..44d6ba2dd2\n--- /dev/null\n+++ b/ci/lib-travisci.sh\n@@ -0,0 +1,5 @@\n+# Library of functions shared by all CI scripts\n+\n+# Set 'exit on error' for all CI scripts to let the caller know that\n+# something went wrong\n+set -e\ndiff --git a/ci/print-test-failures.sh b/ci/print-test-failures.sh\nnew file mode 100755\nindex 0000000000..8583e61839\n--- /dev/null\n+++ b/ci/print-test-failures.sh\n@@ -0,0 +1,18 @@\n+#!/bin/sh\n+#\n+# Print output of failing tests\n+#\n+\n+. ${0%/*}/lib-travisci.sh\n+\n+for TEST_EXIT in t/test-results/*.exit\n+\tdo\n+\t\tif [ \"$(cat \"$TEST_EXIT\")\" != \"0\" ]\n+\t\tthen\n+\t\t\tTEST_OUT=\"${TEST_EXIT%exit}out\"\n+\t\t\techo \"------------------------------------------------------------------------\"\n+\t\t\techo \"$(tput setaf 1)${TEST_OUT}...$(tput sgr0)\"\n+\t\t\techo \"------------------------------------------------------------------------\"\n+\t\t\tcat \"${TEST_OUT}\"\n+\t\tfi\n+done\ndiff --git a/ci/run-build.sh b/ci/run-build.sh\nnew file mode 100755\nindex 0000000000..4f940d1032\n--- /dev/null\n+++ b/ci/run-build.sh\n@@ -0,0 +1,8 @@\n+#!/bin/sh\n+#\n+# Build Git\n+#\n+\n+. ${0%/*}/lib-travisci.sh\n+\n+make --jobs=2\ndiff --git a/ci/run-linux32-docker.sh b/ci/run-linux32-docker.sh\nnew file mode 100755\nindex 0000000000..0edf63acfa\n--- /dev/null\n+++ b/ci/run-linux32-docker.sh\n@@ -0,0 +1,23 @@\n+#!/bin/sh\n+#\n+# Download and run Docker image to build and test 32-bit Git\n+#\n+\n+. ${0%/*}/lib-travisci.sh\n+\n+docker pull daald/ubuntu32:xenial\n+\n+# Use the following command to debug the docker build locally:\n+# $ docker run -itv \"${PWD}:/usr/src/git\" --entrypoint /bin/bash daald/ubuntu32:xenial\n+# root@container:/# /usr/src/git/ci/run-linux32-build.sh\n+\n+docker run \\\n+\t--interactive \\\n+\t--env DEVELOPER \\\n+\t--env DEFAULT_TEST_TARGET \\\n+\t--env GIT_PROVE_OPTS \\\n+\t--env GIT_TEST_OPTS \\\n+\t--env GIT_TEST_CLONE_2GB \\\n+\t--volume \"${PWD}:/usr/src/git\" \\\n+\tdaald/ubuntu32:xenial \\\n+\t/usr/src/git/ci/run-linux32-build.sh $(id -u $USER)\ndiff --git a/ci/run-static-analysis.sh b/ci/run-static-analysis.sh\nnew file mode 100755\nindex 0000000000..68dd0f080e\n--- /dev/null\n+++ b/ci/run-static-analysis.sh\n@@ -0,0 +1,8 @@\n+#!/bin/sh\n+#\n+# Perform various static code analysis checks\n+#\n+\n+. ${0%/*}/lib-travisci.sh\n+\n+make coccicheck\ndiff --git a/ci/run-tests.sh b/ci/run-tests.sh\nnew file mode 100755\nindex 0000000000..f0c743de94\n--- /dev/null\n+++ b/ci/run-tests.sh\n@@ -0,0 +1,10 @@\n+#!/bin/sh\n+#\n+# Test Git\n+#\n+\n+. ${0%/*}/lib-travisci.sh\n+\n+mkdir -p $HOME/travis-cache\n+ln -s $HOME/travis-cache/.prove t/.prove\n+make --quiet test\ndiff --git a/ci/run-windows-build.sh b/ci/run-windows-build.sh\nindex 2d98f6b2f9..8757b3a97c 100755\n--- a/ci/run-windows-build.sh\n+++ b/ci/run-windows-build.sh\n@@ -6,6 +6,8 @@\n # supported) and a commit hash.\n #\n \n+. ${0%/*}/lib-travisci.sh\n+\n test $# -ne 2 && echo \"Unexpected number of parameters\" && exit 1\n test -z \"$GFW_CI_TOKEN\" && echo \"GFW_CI_TOKEN not defined\" && exit\n \ndiff --git a/ci/test-documentation.sh b/ci/test-documentation.sh\nindex 6214e6acb4..7a0a848e83 100755\n--- a/ci/test-documentation.sh\n+++ b/ci/test-documentation.sh\n@@ -3,7 +3,9 @@\n # Perform sanity checks on documentation and build it.\n #\n \n-set -e\n+. ${0%/*}/lib-travisci.sh\n+\n+gem install asciidoctor\n \n make check-builtins\n make check-docs\n-- \n2.14.1\n\n"},{"id":"327836","messageId":"20170910144429.47346-3-larsxschneider@gmail.com","threadId":"46731","inReplyTo":"20170910144429.47346-1-larsxschneider@gmail.com","subject":"[PATCH v1 2/2] travis-ci: skip a branch build if equal tag is present","fromName":"","fromEmail":"larsxschneider@gmail.com","sentAt":"2017-09-10T14:44:29Z","receivedAt":"2017-09-10T14:44:43Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"From: Lars Schneider <larsxschneider@gmail.com>\n\nIf we push a branch and a tag pointing to the HEAD of this branch,\nthen Travis CI would run the build twice. This wastes resources and\nslows the testing.\n\nAdd a function to detect this situation and skip the build the branch\nif appropriate. Invoke this function on every build.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Lars Schneider <larsxschneider@gmail.com>\n---\n ci/lib-travisci.sh | 23 +++++++++++++++++++++++\n 1 file changed, 23 insertions(+)\n\ndiff --git a/ci/lib-travisci.sh b/ci/lib-travisci.sh\nindex 44d6ba2dd2..9c4ae9bdd0 100755\n--- a/ci/lib-travisci.sh\n+++ b/ci/lib-travisci.sh\n@@ -1,5 +1,28 @@\n # Library of functions shared by all CI scripts\n \n+skip_branch_tip_with_tag () {\n+\t# Sometimes, a branch is pushed at the same time the tag that points\n+\t# at the same commit as the tip of the branch is pushed, and building\n+\t# both at the same time is a waste.\n+\t#\n+\t# Travis gives a tagname e.g. v2.14.0 in $TRAVIS_BRANCH when\n+\t# the build is triggered by a push to a tag.  Let's see if\n+\t# $TRAVIS_BRANCH is exactly at a tag, and if so, if it is\n+\t# different from $TRAVIS_BRANCH.  That way, we can tell if\n+\t# we are building the tip of a branch that is tagged and\n+\t# we can skip the build because we won't be skipping a build\n+\t# of a tag.\n+\n+\tif TAG=$(git describe --exact-match \"$TRAVIS_BRANCH\" 2>/dev/null) &&\n+\t\t$TAG != $TRAVIS_BRANCH\n+\tthen\n+\t\techo \"Tip of $TRAVIS_BRANCH is exactly at $TAG\"\n+\t\texit 0\n+\tfi\n+}\n+\n # Set 'exit on error' for all CI scripts to let the caller know that\n # something went wrong\n set -e\n+\n+skip_branch_tip_with_tag\n-- \n2.14.1\n\n"},{"id":"327839","messageId":"xmqqy3pm3ufh.fsf@gitster.mtv.corp.google.com","threadId":"46731","inReplyTo":"20170910144429.47346-2-larsxschneider@gmail.com","subject":"Re: [PATCH v1 1/2] travis-ci: move Travis CI code into dedicated scripts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-09-11T01:17:38Z","receivedAt":"2017-09-11T01:17:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"larsxschneider@gmail.com writes:\n\n> From: Lars Schneider <larsxschneider@gmail.com>\n>\n> Most of the Travis CI commands are in the '.travis.yml'. The yml format\n> does not support functions and therefore code duplication is necessary\n> to run commands across all builds.\n>\n> To fix this, add a library for common CI functions. Move all Travis CI\n> code into dedicated scripts and make them call the library first.\n>\n> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>\n> ---\n\nThanks.  I _think_ you ended up not having to use shell function to\navoid code duplication ;-) but I find the script part of the result\nmuch easier to understand.\n\nTwo things I noticed:\n\n - run-windows-build.sh did not use to run with \"set -e\" but now it\n   does because it includes lib-travisci.sh; if (I didn't check with\n   fine toothed comb) the original were not \"set -e\" clean, we may\n   see unwanted errors in run-windows-build.sh, but that is\n   sometihng we can fix going forward.\n\n - it seems that the test output section lost \": <- click here...\";\n   I do not know if there is a negative consequence of this change.\n\nIndentation of some scripts were a bit too deep and I found it hard\nto read them, so the following is what I did (but did not commit)\nwhile reading them through.\n\nThanks.\n\n ci/install-dependencies.sh | 51 ++++++++++++++++++++++++----------------------\n ci/print-test-failures.sh  | 18 ++++++++--------\n 2 files changed, 36 insertions(+), 33 deletions(-)\n\ndiff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh\nindex 067e6eb702..a29246af35 100755\n--- a/ci/install-dependencies.sh\n+++ b/ci/install-dependencies.sh\n@@ -5,33 +5,36 @@\n \n . ${0%/*}/lib-travisci.sh\n \n+P4WHENCE=http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION\n+LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION\n+\n case \"${TRAVIS_OS_NAME:-linux}\" in\n-\tlinux)\n-\t\texport GIT_TEST_HTTPD=YesPlease\n+linux)\n+\texport GIT_TEST_HTTPD=YesPlease\n \n-\t\tmkdir --parents custom/p4\n-\t\tpushd custom/p4\n-\t\t\twget --quiet http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION/bin.linux26x86_64/p4d\n-\t\t\twget --quiet http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION/bin.linux26x86_64/p4\n-\t\t\tchmod u+x p4d\n-\t\t\tchmod u+x p4\n-\t\t\texport PATH=\"$(pwd):$PATH\"\n-\t\tpopd\n-\t\tmkdir --parents custom/git-lfs\n-\t\tpushd custom/git-lfs\n-\t\t\twget --quiet https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz\n-\t\t\ttar --extract --gunzip --file \"git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz\"\n-\t\t\tcp git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs .\n-\t\t\texport PATH=\"$(pwd):$PATH\"\n-\t\tpopd\n+\tmkdir --parents custom/p4\n+\tpushd custom/p4\n+\t\twget --quiet \"$P4WHENCE/bin.linux26x86_64/p4d\"\n+\t\twget --quiet \"$P4WHENCE/bin.linux26x86_64/p4\"\n+\t\tchmod u+x p4d\n+\t\tchmod u+x p4\n+\t\texport PATH=\"$(pwd):$PATH\"\n+\tpopd\n+\tmkdir --parents custom/git-lfs\n+\tpushd custom/git-lfs\n+\t\twget --quiet \"$LFSWHENCE/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz\"\n+\t\ttar --extract --gunzip --file \"git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz\"\n+\t\tcp git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs .\n+\t\texport PATH=\"$(pwd):$PATH\"\n+\tpopd\n \t;;\n-\tosx)\n-\t\tbrew update --quiet\n-\t\t# Uncomment this if you want to run perf tests:\n-\t\t# brew install gnu-time\n-\t\tbrew install git-lfs gettext\n-\t\tbrew link --force gettext\n-\t\tbrew install caskroom/cask/perforce\n+osx)\n+\tbrew update --quiet\n+\t# Uncomment this if you want to run perf tests:\n+\t# brew install gnu-time\n+\tbrew install git-lfs gettext\n+\tbrew link --force gettext\n+\tbrew install caskroom/cask/perforce\n \t;;\n esac\n \ndiff --git a/ci/print-test-failures.sh b/ci/print-test-failures.sh\nindex 8583e61839..8c8973cbf3 100755\n--- a/ci/print-test-failures.sh\n+++ b/ci/print-test-failures.sh\n@@ -6,13 +6,13 @@\n . ${0%/*}/lib-travisci.sh\n \n for TEST_EXIT in t/test-results/*.exit\n-\tdo\n-\t\tif [ \"$(cat \"$TEST_EXIT\")\" != \"0\" ]\n-\t\tthen\n-\t\t\tTEST_OUT=\"${TEST_EXIT%exit}out\"\n-\t\t\techo \"------------------------------------------------------------------------\"\n-\t\t\techo \"$(tput setaf 1)${TEST_OUT}...$(tput sgr0)\"\n-\t\t\techo \"------------------------------------------------------------------------\"\n-\t\t\tcat \"${TEST_OUT}\"\n-\t\tfi\n+do\n+\tif [ \"$(cat \"$TEST_EXIT\")\" != \"0\" ]\n+\tthen\n+\t\tTEST_OUT=\"${TEST_EXIT%exit}out\"\n+\t\techo \"------------------------------------------------------------------------\"\n+\t\techo \"$(tput setaf 1)${TEST_OUT}...$(tput sgr0)\"\n+\t\techo \"------------------------------------------------------------------------\"\n+\t\tcat \"${TEST_OUT}\"\n+\tfi\n done\n"},{"id":"327851","messageId":"20170911145241.18571-1-szeder.dev@gmail.com","threadId":"46731","inReplyTo":"20170910144429.47346-3-larsxschneider@gmail.com","subject":"Re: [PATCH v1 2/2] travis-ci: skip a branch build if equal tag is present","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2017-09-11T14:52:41Z","receivedAt":"2017-09-11T14:53:56Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"> If we push a branch and a tag pointing to the HEAD of this branch,\n\ns/the HEAD of//, perhaps?\nThere is no such thing as \"HEAD\" (all capital!) of a branch, is it?\n\n> then Travis CI would run the build twice. This wastes resources and\n\nNit: s/run the build/build and test the same tree/, to further stress\nthat the two builds are redundant.\n\n> slows the testing.\n> \n> Add a function to detect this situation and skip the build the branch\n\ns/skip the build/skip building/ ?\n\n> if appropriate. Invoke this function on every build.\n> \n> Helped-by: Junio C Hamano <gitster@pobox.com>\n> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>\n> ---\n>  ci/lib-travisci.sh | 23 +++++++++++++++++++++++\n>  1 file changed, 23 insertions(+)\n> \n> diff --git a/ci/lib-travisci.sh b/ci/lib-travisci.sh\n> index 44d6ba2dd2..9c4ae9bdd0 100755\n> --- a/ci/lib-travisci.sh\n> +++ b/ci/lib-travisci.sh\n> @@ -1,5 +1,28 @@\n>  # Library of functions shared by all CI scripts\n>  \n> +skip_branch_tip_with_tag () {\n> +\t# Sometimes, a branch is pushed at the same time the tag that points\n> +\t# at the same commit as the tip of the branch is pushed, and building\n> +\t# both at the same time is a waste.\n> +\t#\n> +\t# Travis gives a tagname e.g. v2.14.0 in $TRAVIS_BRANCH when\n> +\t# the build is triggered by a push to a tag.  Let's see if\n> +\t# $TRAVIS_BRANCH is exactly at a tag, and if so, if it is\n> +\t# different from $TRAVIS_BRANCH.  That way, we can tell if\n> +\t# we are building the tip of a branch that is tagged and\n> +\t# we can skip the build because we won't be skipping a build\n> +\t# of a tag.\n> +\n> +\tif TAG=$(git describe --exact-match \"$TRAVIS_BRANCH\" 2>/dev/null) &&\n> +\t\t$TAG != $TRAVIS_BRANCH\n\nThis must be\n\n    [ $TAG != $TRAVIS_BRANCH ]\n\notherwise the shell will rightfully complain:\n\n  $ TRAVIS_BRANCH=v2.14.0 ./ci/lib-travisci.sh \n  ./ci/lib-travisci.sh: line 17: v2.14.0: command not found\n\nFurthermore, I would prefer quotes around $TAG and $TRAVIS_BRANCH.  If\neither one of those two variables were empty (or contain multiple\nwords) at that point, the shell would complain.  Now, I don't think\nthat either can end up being empty, so quotes are not necessary, but\nhaving quotes around them would save future readers from spending\nbrain cycles on this unnecessarily.\n\n> +\tthen\n> +\t\techo \"Tip of $TRAVIS_BRANCH is exactly at $TAG\"\n> +\t\texit 0\n> +\tfi\n> +}\n> +\n>  # Set 'exit on error' for all CI scripts to let the caller know that\n>  # something went wrong\n>  set -e\n> +\n> +skip_branch_tip_with_tag\n> -- \n> 2.14.1\n> \n> \n"},{"id":"327885","messageId":"3B175D35-5B1C-43CD-A7E9-85693335B10A@gmail.com","threadId":"46731","inReplyTo":"20170911145241.18571-1-szeder.dev@gmail.com","subject":"Re: [PATCH v1 2/2] travis-ci: skip a branch build if equal tag is present","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2017-09-12T11:45:53Z","receivedAt":"2017-09-12T11:46:06Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\n> On 11 Sep 2017, at 16:52, SZEDER Gábor <szeder.dev@gmail.com> wrote:\n> \n>> If we push a branch and a tag pointing to the HEAD of this branch,\n> \n> s/the HEAD of//, perhaps?\n> There is no such thing as \"HEAD\" (all capital!) of a branch, is it?\n\nAgreed, maybe:\n\"If we push a branch and a tag pointing to the tip of this branch...\"\n\nWould that be OK for you?\n\n\n>> then Travis CI would run the build twice. This wastes resources and\n> \n> Nit: s/run the build/build and test the same tree/, to further stress\n> that the two builds are redundant.\n\nOK, will fix.\n\n\n>> slows the testing.\n>> \n>> Add a function to detect this situation and skip the build the branch\n> \n> s/skip the build/skip building/ ?\n\nOK, will fix.\n\n\n>> if appropriate. Invoke this function on every build.\n>> \n>> Helped-by: Junio C Hamano <gitster@pobox.com>\n>> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>\n>> ---\n>> ci/lib-travisci.sh | 23 +++++++++++++++++++++++\n>> 1 file changed, 23 insertions(+)\n>> \n>> diff --git a/ci/lib-travisci.sh b/ci/lib-travisci.sh\n>> index 44d6ba2dd2..9c4ae9bdd0 100755\n>> --- a/ci/lib-travisci.sh\n>> +++ b/ci/lib-travisci.sh\n>> @@ -1,5 +1,28 @@\n>> # Library of functions shared by all CI scripts\n>> \n>> +skip_branch_tip_with_tag () {\n>> +\t# Sometimes, a branch is pushed at the same time the tag that points\n>> +\t# at the same commit as the tip of the branch is pushed, and building\n>> +\t# both at the same time is a waste.\n>> +\t#\n>> +\t# Travis gives a tagname e.g. v2.14.0 in $TRAVIS_BRANCH when\n>> +\t# the build is triggered by a push to a tag.  Let's see if\n>> +\t# $TRAVIS_BRANCH is exactly at a tag, and if so, if it is\n>> +\t# different from $TRAVIS_BRANCH.  That way, we can tell if\n>> +\t# we are building the tip of a branch that is tagged and\n>> +\t# we can skip the build because we won't be skipping a build\n>> +\t# of a tag.\n>> +\n>> +\tif TAG=$(git describe --exact-match \"$TRAVIS_BRANCH\" 2>/dev/null) &&\n>> +\t\t$TAG != $TRAVIS_BRANCH\n> \n> This must be\n> \n>    [ $TAG != $TRAVIS_BRANCH ]\n> \n> otherwise the shell will rightfully complain:\n> \n>  $ TRAVIS_BRANCH=v2.14.0 ./ci/lib-travisci.sh \n>  ./ci/lib-travisci.sh: line 17: v2.14.0: command not found\n> \n> Furthermore, I would prefer quotes around $TAG and $TRAVIS_BRANCH.  If\n> either one of those two variables were empty (or contain multiple\n> words) at that point, the shell would complain.  Now, I don't think\n> that either can end up being empty, so quotes are not necessary, but\n> having quotes around them would save future readers from spending\n> brain cycles on this unnecessarily.\n\nAgreed. I will fix both things!\n\n\nThanks for the review,\nLars"}]}