{"thread":{"id":"45492","subject":"[PATCH v2] travis-ci: build and test Git on Windows","startedAt":"2017-03-24T11:37:57Z","lastAt":"2017-03-29T23:26:27Z","messageCount":8,"participants":["Lars Schneider","Daniel Stenberg","Sebastian Schuberth","Jeff King","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"315236","messageId":"20170324113747.44991-1-larsxschneider@gmail.com","threadId":"45492","inReplyTo":null,"subject":"[PATCH v2] travis-ci: build and test Git on Windows","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2017-03-24T11:37:47Z","receivedAt":"2017-03-24T11:37:57Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"Most Git developers work on Linux and they have no way to know if their\nchanges would break the Git for Windows build. Let's fix that by adding\na job to TravisCI that builds and tests Git on Windows. Unfortunately,\nTravisCI does not support Windows.\n\nTherefore, we did the following:\n* Johannes Schindelin set up a Visual Studio Team Services build\n  sponsored by Microsoft and made it accessible via an Azure Function\n  that speaks a super-simple API. We made TravisCI use this API to\n  trigger a build, wait until its completion, and print the build and\n  test results.\n* A Windows build and test run takes up to 3h and TravisCI has a timeout\n  after 50min for Open Source projects. Since the TravisCI job does not\n  use heavy CPU/memory/etc. resources, the friendly TravisCI folks\n  extended the job timeout for git/git to 3h.\n\nThings, that would need to be done:\n* Someone with write access to https://travis-ci.org/git/git would need\n  to add the secret token as \"GFW_CI_TOKEN\" variable in the TravisCI\n  repository setting [1]. Afterwards the build should just work.\n\nThings, that might need to be done:\n* The Windows box can only process a single build at a time. A second\n  Windows build would need to wait until the first finishes. This\n  waiting time and the build time after the wait could exceed the 3h\n  threshold. If this is a problem, then it is likely to happen every day\n  as usually multiple branches are pushed at the same time (pu/next/\n  master/maint). I cannot test this as my TravisCI account has the 50min\n  timeout. One solution could be to limit the number of concurrent\n  TravisCI jobs [2].\n\n[1] https://docs.travis-ci.com/user/environment-variables#Defining-Variables-in-Repository-Settings\n[2] https://docs.travis-ci.com/user/customizing-the-build#Limiting-Concurrent-Builds\n\nSigned-off-by: Lars Schneider <larsxschneider@gmail.com>\n---\n\nHi,\n\nI think I addressed all issues from the v1 review (see interdiff below)\nwith one exception. The script still uses bash instead of sh. Something\nabout this does not work in sh:\n    --output >(sed \"$(printf '1s/^\\xef\\xbb\\xbf//')\" >cat >&3)\n\nDoes anyone know how to make this sh compatible?\n\nThanks,\nLars\n\n\nNotes:\n    Base Ref: master\n    Web-Diff: https://github.com/larsxschneider/git/commit/7c527f3571\n    Checkout: git fetch https://github.com/larsxschneider/git travisci/win-v2 && git checkout 7c527f3571\n\n    Interdiff (v1..v2):\n\n    diff --git a/.travis.yml b/.travis.yml\n    index a7e98ae519..c757a111ce 100644\n    --- a/.travis.yml\n    +++ b/.travis.yml\n    @@ -48,7 +48,7 @@ matrix:\n           script:\n             - >\n               test \"$TRAVIS_REPO_SLUG\" != \"git/git\" ||\n    -          ci/run-windows-build.sh $GFW_CI_TOKEN $TRAVIS_BRANCH $(git rev-parse HEAD)\n    +          ci/run-windows-build.sh $TRAVIS_BRANCH $(git rev-parse HEAD)\n           after_failure:\n         - env: Linux32\n           os: linux\n    diff --git a/ci/run-windows-build.sh b/ci/run-windows-build.sh\n    index 324a9ea4e6..234a235c77 100755\n    --- a/ci/run-windows-build.sh\n    +++ b/ci/run-windows-build.sh\n    @@ -1,30 +1,49 @@\n     #!/usr/bin/env bash\n     #\n     # Script to trigger the a Git for Windows build and test run.\n    -# Pass a token, the branch (only branches on https://github.com/git/git)\n    -# are supported), and a commit hash.\n    +# Set the $GFW_CI_TOKEN as environment variable.\n    +# Pass the branch (only branches on https://github.com/git/git are\n    +# supported) and a commit hash.\n     #\n\n    -[ $# -eq 3 ] || (echo \"Unexpected number of parameters\" && exit 1)\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\n    -TOKEN=$1\n    -BRANCH=$2\n    -COMMIT=$3\n    +BRANCH=$1\n    +COMMIT=$2\n\n     gfwci () {\n    -\tcurl \\\n    -\t\t-H \"Authentication: Bearer $TOKEN\" \\\n    -\t\t--silent --retry 5 \\\n    -\t\t\"https://git-for-windows-ci.azurewebsites.net/api/TestNow?$1\" |\n    -\tsed \"$(printf '1s/^\\xef\\xbb\\xbf//')\"  # Remove the Byte Order Mark\n    +\tlocal CURL_ERROR_CODE HTTP_CODE\n    +\texec 3>&1\n    +\tHTTP_CODE=$(curl \\\n    +\t\t-H \"Authentication: Bearer $GFW_CI_TOKEN\" \\\n    +\t\t--silent --retry 5 --write-out '%{HTTP_CODE}' \\\n    +\t\t--output >(sed \"$(printf '1s/^\\xef\\xbb\\xbf//')\" >cat >&3) \\\n    +\t\t\"https://git-for-windows-ci.azurewebsites.net/api/TestNow?$1\" \\\n    +\t)\n    +\tCURL_ERROR_CODE=$?\n    +\tif test $CURL_ERROR_CODE -ne 0\n    +\tthen\n    +\t\treturn $CURL_ERROR_CODE\n    +\tfi\n    +\tif test \"$HTTP_CODE\" -ge 400 && test \"$HTTP_CODE\" -lt 600\n    +\tthen\n    +\t\treturn 127\n    +\tfi\n     }\n\n     # Trigger build job\n     BUILD_ID=$(gfwci \"action=trigger&branch=$BRANCH&commit=$COMMIT&skipTests=false\")\n    +if test $? -ne 0\n    +then\n    +\techo \"Unable to trigger Visual Studio Team Services Build\"\n    +\techo \"$BUILD_ID\"\n    +\texit 1\n    +fi\n\n     # Check if the $BUILD_ID contains a number\n     case $BUILD_ID in\n    -\t''|*[!0-9]*) echo $BUILD_ID && exit 1\n    +''|*[!0-9]*) echo \"Unexpected build number: $BUILD_ID\" && exit 1\n     esac\n\n     echo \"Visual Studio Team Services Build #${BUILD_ID}\"\n    @@ -36,13 +55,13 @@ while true\n     do\n     \tLAST_STATUS=$STATUS\n     \tSTATUS=$(gfwci \"action=status&buildId=$BUILD_ID\")\n    -\t[ \"$STATUS\" == \"$LAST_STATUS\" ] || printf \"\\nStatus: $STATUS \"\n    +\ttest \"$STATUS\" = \"$LAST_STATUS\" || printf \"\\nStatus: $STATUS \"\n     \tprintf \".\"\n\n    -\tcase $STATUS in\n    +\tcase \"$STATUS\" in\n     \tinProgress|postponed|notStarted) sleep 10               ;; # continue\n     \t         \"completed: succeeded\") RESULT=\"success\"; break;; # success\n    -\t\t                              *) echo \"Unknown: $STATUS\"; break;; # failure\n    +\t*) echo \"Unhandled status: $STATUS\";               break;; # failure\n     \tesac\n     done\n\n    @@ -52,4 +71,5 @@ echo \"\"\n     gfwci \"action=log&buildId=$BUILD_ID\" | cut -c 30-\n\n     # Set exit code for TravisCI\n    -[ \"$RESULT\" == \"success\" ]\n    +test \"$RESULT\" = \"success\"\n    +\n\n    \\0\n\n .travis.yml             | 11 ++++++++\n ci/run-windows-build.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 86 insertions(+)\n create mode 100755 ci/run-windows-build.sh\n\ndiff --git a/.travis.yml b/.travis.yml\nindex 591cc57b80..c757a111ce 100644\n--- a/.travis.yml\n+++ b/.travis.yml\n@@ -39,6 +39,17 @@ env:\n\n matrix:\n   include:\n+    - env: Windows\n+      os: linux\n+      compiler:\n+      addons:\n+      before_install:\n+      before_script:\n+      script:\n+        - >\n+          test \"$TRAVIS_REPO_SLUG\" != \"git/git\" ||\n+          ci/run-windows-build.sh $TRAVIS_BRANCH $(git rev-parse HEAD)\n+      after_failure:\n     - env: Linux32\n       os: linux\n       services:\ndiff --git a/ci/run-windows-build.sh b/ci/run-windows-build.sh\nnew file mode 100755\nindex 0000000000..234a235c77\n--- /dev/null\n+++ b/ci/run-windows-build.sh\n@@ -0,0 +1,75 @@\n+#!/usr/bin/env bash\n+#\n+# Script to trigger the a Git for Windows build and test run.\n+# Set the $GFW_CI_TOKEN as environment variable.\n+# Pass the branch (only branches on https://github.com/git/git are\n+# supported) and a commit hash.\n+#\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+\n+BRANCH=$1\n+COMMIT=$2\n+\n+gfwci () {\n+\tlocal CURL_ERROR_CODE HTTP_CODE\n+\texec 3>&1\n+\tHTTP_CODE=$(curl \\\n+\t\t-H \"Authentication: Bearer $GFW_CI_TOKEN\" \\\n+\t\t--silent --retry 5 --write-out '%{HTTP_CODE}' \\\n+\t\t--output >(sed \"$(printf '1s/^\\xef\\xbb\\xbf//')\" >cat >&3) \\\n+\t\t\"https://git-for-windows-ci.azurewebsites.net/api/TestNow?$1\" \\\n+\t)\n+\tCURL_ERROR_CODE=$?\n+\tif test $CURL_ERROR_CODE -ne 0\n+\tthen\n+\t\treturn $CURL_ERROR_CODE\n+\tfi\n+\tif test \"$HTTP_CODE\" -ge 400 && test \"$HTTP_CODE\" -lt 600\n+\tthen\n+\t\treturn 127\n+\tfi\n+}\n+\n+# Trigger build job\n+BUILD_ID=$(gfwci \"action=trigger&branch=$BRANCH&commit=$COMMIT&skipTests=false\")\n+if test $? -ne 0\n+then\n+\techo \"Unable to trigger Visual Studio Team Services Build\"\n+\techo \"$BUILD_ID\"\n+\texit 1\n+fi\n+\n+# Check if the $BUILD_ID contains a number\n+case $BUILD_ID in\n+''|*[!0-9]*) echo \"Unexpected build number: $BUILD_ID\" && exit 1\n+esac\n+\n+echo \"Visual Studio Team Services Build #${BUILD_ID}\"\n+\n+# Wait until build job finished\n+STATUS=\n+RESULT=\n+while true\n+do\n+\tLAST_STATUS=$STATUS\n+\tSTATUS=$(gfwci \"action=status&buildId=$BUILD_ID\")\n+\ttest \"$STATUS\" = \"$LAST_STATUS\" || printf \"\\nStatus: $STATUS \"\n+\tprintf \".\"\n+\n+\tcase \"$STATUS\" in\n+\tinProgress|postponed|notStarted) sleep 10               ;; # continue\n+\t         \"completed: succeeded\") RESULT=\"success\"; break;; # success\n+\t*) echo \"Unhandled status: $STATUS\";               break;; # failure\n+\tesac\n+done\n+\n+# Print log\n+echo \"\"\n+echo \"\"\n+gfwci \"action=log&buildId=$BUILD_ID\" | cut -c 30-\n+\n+# Set exit code for TravisCI\n+test \"$RESULT\" = \"success\"\n+\n\nbase-commit: afd6726309f57f532b4b989a75c1392359c611cc\n--\n2.12.1\n\n"},{"id":"315237","messageId":"alpine.DEB.2.20.1703241242210.17768@tvnag.unkk.fr","threadId":"45492","inReplyTo":"20170324113747.44991-1-larsxschneider@gmail.com","subject":"Re: [PATCH v2] travis-ci: build and test Git on Windows","fromName":"Daniel Stenberg","fromEmail":"daniel@haxx.se","sentAt":"2017-03-24T11:48:38Z","receivedAt":"2017-03-24T11:56:22Z","isPatch":true,"sender":{"key":"daniel@haxx.se","avatar":"https://gravatar.com/avatar/69fdca87edd17cee21ca2e79fc2ff671d644603c3dc27167430f3cd3dbab7ba8?d=mp&s=160"},"body":"On Fri, 24 Mar 2017, Lars Schneider wrote:\n\n> Most Git developers work on Linux and they have no way to know if their \n> changes would break the Git for Windows build. Let's fix that by adding a \n> job to TravisCI that builds and tests Git on Windows. Unfortunately, \n> TravisCI does not support Windows.\n\nForgive me for bursting in and possibly repeating what you've already \ndiscussed. I just read about the limitations for doing windows builds via \ntravis so I thought I'd at least let you know that you can avoid those \nlimitations without too much work:\n\nTwo alternative approaches would be:\n\n1. use appveyor.com, as that is a Travis-like service for Windows. We do our\n    windows-builds in the curl project using that.\n\n2. run your own buildbot and submit data using the regular github hook and\n    have buildbot submit the results back (it has a plugin that can do that).\n    We do solaris-builds in the curl project using that method (thanks to\n    opencsw.org) and some additional windows-builds thanks to private\n    individuals.\n\n-- \n\n  / daniel.haxx.se\n"},{"id":"315241","messageId":"CD7E9F8C-77CA-44D4-AEC8-CEACD0528E3A@gmail.com","threadId":"45492","inReplyTo":"alpine.DEB.2.20.1703241242210.17768@tvnag.unkk.fr","subject":"Re: [PATCH v2] travis-ci: build and test Git on Windows","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2017-03-24T12:35:51Z","receivedAt":"2017-03-24T12:36:04Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\n> On 24 Mar 2017, at 12:48, Daniel Stenberg <daniel@haxx.se> wrote:\n> \n> On Fri, 24 Mar 2017, Lars Schneider wrote:\n> \n>> Most Git developers work on Linux and they have no way to know if their changes would break the Git for Windows build. Let's fix that by adding a job to TravisCI that builds and tests Git on Windows. Unfortunately, TravisCI does not support Windows.\n> \n> Forgive me for bursting in and possibly repeating what you've already discussed. I just read about the limitations for doing windows builds via travis so I thought I'd at least let you know that you can avoid those limitations without too much work:\n\nYou are not bursting in - I am happy to get your feedback! Thanks a lot for CURL BTW :-)\n\n\n> Two alternative approaches would be:\n> \n> 1. use appveyor.com, as that is a Travis-like service for Windows. We do our\n>   windows-builds in the curl project using that.\n\nThe Git for Windows build and tests are *really* resources intensive and they\ntake a lot of setup time. AFAIK we would run into timeouts with AppVeyor.\nMaybe Sebastian or Dscho know details?\n\n\n> 2. run your own buildbot and submit data using the regular github hook and\n>   have buildbot submit the results back (it has a plugin that can do that).\n>   We do solaris-builds in the curl project using that method (thanks to\n>   opencsw.org) and some additional windows-builds thanks to private\n>   individuals.\n\nWe could do that! However, the idea was to have the entire build status \nfor all platforms in one place.\n\n\n- Lars"},{"id":"315245","messageId":"alpine.DEB.2.20.1703241341570.17768@tvnag.unkk.fr","threadId":"45492","inReplyTo":"CD7E9F8C-77CA-44D4-AEC8-CEACD0528E3A@gmail.com","subject":"Re: [PATCH v2] travis-ci: build and test Git on Windows","fromName":"Daniel Stenberg","fromEmail":"daniel@haxx.se","sentAt":"2017-03-24T12:42:48Z","receivedAt":"2017-03-24T12:43:01Z","isPatch":true,"sender":{"key":"daniel@haxx.se","avatar":"https://gravatar.com/avatar/69fdca87edd17cee21ca2e79fc2ff671d644603c3dc27167430f3cd3dbab7ba8?d=mp&s=160"},"body":"On Fri, 24 Mar 2017, Lars Schneider wrote:\n\n>> 2. run your own buildbot and submit data using the regular github hook and\n>>   have buildbot submit the results back (it has a plugin that can do that).\n>>   We do solaris-builds in the curl project using that method (thanks to\n>>   opencsw.org) and some additional windows-builds thanks to private\n>>   individuals.\n>\n> We could do that! However, the idea was to have the entire build status for \n> all platforms in one place.\n\nAs the status is (or at least can be) passed back to github, all CI jobs are \nshown at the same place: below each commit and each pull-request...\n\n-- \n\n  / daniel.haxx.se\n"},{"id":"315246","messageId":"CAHGBnuPdve_5Xrmde6cjbXBjSWfZLrT5eT90hayG0jfbBTkq6Q@mail.gmail.com","threadId":"45492","inReplyTo":"CD7E9F8C-77CA-44D4-AEC8-CEACD0528E3A@gmail.com","subject":"Re: [PATCH v2] travis-ci: build and test Git on Windows","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2017-03-24T12:43:03Z","receivedAt":"2017-03-24T12:43:10Z","isPatch":true,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On Fri, Mar 24, 2017 at 1:35 PM, Lars Schneider\n<larsxschneider@gmail.com> wrote:\n\n>> 1. use appveyor.com, as that is a Travis-like service for Windows. We do our\n>>   windows-builds in the curl project using that.\n>\n> The Git for Windows build and tests are *really* resources intensive and they\n> take a lot of setup time. AFAIK we would run into timeouts with AppVeyor.\n> Maybe Sebastian or Dscho know details?\n\nAt lot of setup time, in terms of installing the Git for Windows SDK,\ncould probably be saved by only installing the required packages on\ntop of MSYS2 that's already installed in AppVeyor nodes [1].\n\n[1] https://www.appveyor.com/docs/build-environment/#mingw-msys-cygwin\n\n-- \nSebastian Schuberth\n"},{"id":"315253","messageId":"20170324145940.xqjmwxphwmtx67ug@sigill.intra.peff.net","threadId":"45492","inReplyTo":"20170324113747.44991-1-larsxschneider@gmail.com","subject":"Re: [PATCH v2] travis-ci: build and test Git on Windows","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-03-24T14:59:40Z","receivedAt":"2017-03-24T14:59:52Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Mar 24, 2017 at 12:37:47PM +0100, Lars Schneider wrote:\n\n> I think I addressed all issues from the v1 review (see interdiff below)\n> with one exception. The script still uses bash instead of sh. Something\n> about this does not work in sh:\n>     --output >(sed \"$(printf '1s/^\\xef\\xbb\\xbf//')\" >cat >&3)\n> \n> Does anyone know how to make this sh compatible?\n\nProcess substitution is a bash-ism. Just looking at this snippet I would\nask why you aren't just using stdout, but from the whole diff it looks\nlike you're using --write-out and want to keep the streams separate.\n\nThe POSIX shell way would be to make your own named pipe rather than\nanonymous one:\n\n  mkfifo data\n  sed ... <data &\n  curl ... --output data\n  rm data\n\nBut I don't think relying on bash is that big a deal, as long as the\nscript is clearly marked with the correct #!-line (which it is).\n\nThe \">cat\" isn't doing AFAICT, though.\n\n-Peff\n"},{"id":"315274","messageId":"xmqqh92i8vdr.fsf@gitster.mtv.corp.google.com","threadId":"45492","inReplyTo":"20170324113747.44991-1-larsxschneider@gmail.com","subject":"Re: [PATCH v2] travis-ci: build and test Git on Windows","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-03-24T16:58:08Z","receivedAt":"2017-03-24T16:58:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lars Schneider <larsxschneider@gmail.com> writes:\n\n> I think I addressed all issues from the v1 review (see interdiff below)\n> with one exception. The script still uses bash instead of sh. Something\n> about this does not work in sh:\n>     --output >(sed \"$(printf '1s/^\\xef\\xbb\\xbf//')\" >cat >&3)\n>\n> Does anyone know how to make this sh compatible?\n\nMaking this runnable under any shell is not a goal; if your script\ndoes rely on that bash-ism, then leave it as-is and mark it with\n#!/bin/bash or somesuch.\n\nThanks.\n\n"},{"id":"315724","messageId":"alpine.DEB.2.20.1703300119310.4068@virtualbox","threadId":"45492","inReplyTo":"CAHGBnuPdve_5Xrmde6cjbXBjSWfZLrT5eT90hayG0jfbBTkq6Q@mail.gmail.com","subject":"Re: [PATCH v2] travis-ci: build and test Git on Windows","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-03-29T23:26:10Z","receivedAt":"2017-03-29T23:26:27Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 24 Mar 2017, Sebastian Schuberth wrote:\n\n> On Fri, Mar 24, 2017 at 1:35 PM, Lars Schneider\n> <larsxschneider@gmail.com> wrote:\n> \n> >> 1. use appveyor.com, as that is a Travis-like service for Windows. We do our\n> >>   windows-builds in the curl project using that.\n> >\n> > The Git for Windows build and tests are *really* resources intensive and they\n> > take a lot of setup time. AFAIK we would run into timeouts with AppVeyor.\n> > Maybe Sebastian or Dscho know details?\n> \n> At lot of setup time, in terms of installing the Git for Windows SDK,\n> could probably be saved by only installing the required packages on\n> top of MSYS2 that's already installed in AppVeyor nodes [1].\n> \n> [1] https://www.appveyor.com/docs/build-environment/#mingw-msys-cygwin\n\nAnd that is indeed what Git for Windows' Git fork has configured. Sadly,\nthe job timed out too often for me, even if I disabled the tests.\n\nAs of recent, things turned more green, with the build taking only about 3\nminutes. Of course, re-enabling the tests would let us run smack into the\n20 minutes time out, *and* we still would have to disable the tests that\nfail because MSYS2's maintainer ignored the PRs trying to integrate Git\nfor Windows' patches to the MSYS2 runtime.\n\nExample for a green job:\nhttps://ci.appveyor.com/project/dscho/git/build/1.0.676\n\nCiao,\nJohannes\n"}]}