travis: move script sections to files in `.travis/` subject to shellcheck #13863

pull scravy wants to merge 7 commits into bitcoin:master from scravy:travis-extract-scripts changing 10 files +218 −63
  1. scravy commented at 2:00 PM on August 3, 2018: contributor

    This PR is extracted from #13816 to make that one easier to review. It follows on #13849 and #13851

    In here the shell script parts from travis.yml are extracted into .travis/before_install.sh, .travis/install.sh, .travis/before_script.sh, .travis/script.sh, and .travis/lint.sh.

    This has the benefit that test/lint/lint-shell.sh will also shellcheck these parts. Also it makes the individual script parts more readable.

  2. scravy cross-referenced this on Aug 3, 2018 from issue travis: WIP - build and run tests on os: osx by scravy
  3. scravy renamed this:
    Travis extract scripts
    travis: move script sections to files in `.travis/` subject to shellcheck
    on Aug 3, 2018
  4. Empact commented at 2:19 PM on August 3, 2018: member

    Concept ACK

  5. practicalswift commented at 2:28 PM on August 3, 2018: contributor

    Concept ACK

    Very good idea!

  6. MarcoFalke commented at 2:37 PM on August 3, 2018: member

    ACK, this way we could also reset old travis pull request runs, since it is less likely that the travis.yml changed in the meantime.

  7. fanquake added the label Tests on Aug 3, 2018
  8. Empact commented at 2:52 PM on August 3, 2018: member

    Could squash d3d19e39111f5a2b7318b8e80a1fbf61f3bb4f99 and d913a4b into 67eee3cc56e6b8014b73c07d8a064b5731a8239e

  9. in .travis/before_install.sh:3 in d913a4bb01 outdated
       0 | @@ -0,0 +1,25 @@
       1 | +#!/usr/bin/env bash
       2 | +#
       3 | +# Copyright (c) 2017 The Bitcoin Core developers
    


    ken2812221 commented at 3:03 PM on August 3, 2018:

    2018?


    scravy commented at 3:17 PM on August 3, 2018:

    fixed

  10. ken2812221 changes_requested
  11. ken2812221 commented at 3:05 PM on August 3, 2018: contributor

    Concept ACK

  12. scravy force-pushed on Aug 3, 2018
  13. MarcoFalke commented at 3:09 PM on August 3, 2018: member

    I wonder if it helps to prefix the scripts with two digits to clarify the order in which they are run (03_before_install, 04_...) https://docs.travis-ci.com/user/customizing-the-build/#the-build-lifecycle

  14. scravy force-pushed on Aug 3, 2018
  15. scravy commented at 3:18 PM on August 3, 2018: contributor

    @Empact squashed and reordered the commits a bit

  16. scravy commented at 3:29 PM on August 3, 2018: contributor

    @MarcoFalke I've changed the names of the files according to your suggestion and added a README with the rationale/link to the travis documentation in d55d49c0f9c672327c4eea87aaa7b0f03381eebb

  17. scravy force-pushed on Aug 3, 2018
  18. scravy commented at 3:36 PM on August 3, 2018: contributor

    Now with the build steps numbered I moved the remaining steps too in a8803bd9e64e6416e6012c22eee849a20a64f633

  19. Empact commented at 3:40 PM on August 3, 2018: member

    Big issue with this PR: Travis - sections check the return code on a per-command basis. The newly sourced files do not, so failures are not detected unless you detect them in the script and propagate them to Travis.

    E.g. see https://travis-ci.org/Empact/bitcoin/jobs/411794591 where I deleted a file to force the test/lint/git-subtree-check.sh src/secp256k1 lint to fail

  20. scravy commented at 4:06 PM on August 3, 2018: contributor

    @Empact great catch, I added set -e before the source step. WDYT?

  21. in .travis.yml:30 in d7ed3452f2 outdated
      26 | @@ -27,15 +27,15 @@ env:
      27 |      - WINEDEBUG=fixme-all
      28 |      - DOCKER_PACKAGES="build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git ca-certificates ccache"
      29 |  before_install:
      30 | -  - source .travis/test_03_before_install.sh
      31 | +  - set -e; source .travis/test_03_before_install.sh
    


    Empact commented at 4:08 PM on August 3, 2018:

    nit: How about set -o errexit as more self-documenting?

  22. scravy force-pushed on Aug 3, 2018
  23. scravy force-pushed on Aug 3, 2018
  24. DrahtBot commented at 4:39 PM on August 3, 2018: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->Note to reviewers: This pull request conflicts with the following ones:

    • #13954 (lint: Check for common misspellings using codespell. Fix typos reported by codespell. by practicalswift)
    • #13845 (Include tinyformat as a subtree by Empact)
    • #13728 (Scripts and tools: Run the CI lint stage on mac and linux both by Empact)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  25. DrahtBot cross-referenced this on Aug 3, 2018 from issue qa: Add emojis to test_runner path and wallet filename by MarcoFalke
  26. DrahtBot cross-referenced this on Aug 3, 2018 from issue travis: upload binaries by ken2812221
  27. DrahtBot cross-referenced this on Aug 3, 2018 from issue Include tinyformat as a subtree by Empact
  28. DrahtBot cross-referenced this on Aug 3, 2018 from issue lint: Run the CI lint stage on mac by Empact
  29. DrahtBot cross-referenced this on Aug 3, 2018 from issue travis: Enable qt for all jobs by ken2812221
  30. scravy force-pushed on Aug 6, 2018
  31. scravy cross-referenced this on Aug 6, 2018 from issue extract script from .travis.yml + generally improve readability by scravy
  32. scravy force-pushed on Aug 6, 2018
  33. scravy force-pushed on Aug 6, 2018
  34. scravy force-pushed on Aug 6, 2018
  35. scravy force-pushed on Aug 6, 2018
  36. scravy force-pushed on Aug 6, 2018
  37. scravy force-pushed on Aug 6, 2018
  38. scravy force-pushed on Aug 6, 2018
  39. scravy force-pushed on Aug 6, 2018
  40. scravy commented at 6:46 PM on August 6, 2018: contributor

    rebased.

    in between #13859 was merged, I'm now invoking python with LC_ALL=C.UTF_8 in a31bdfcb918469c9d0400a2bd8433fbfddcc411b as it requires that to interpret the emoji correctly. or parse the source file in the first place. Otherwise nothing changed.

  41. in .travis/test_04_install.sh:10 in a31bdfcb91 outdated
       5 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php.
       6 | +
       7 | +export LC_ALL=C
       8 | +
       9 | +travis_retry docker pull "$DOCKER_NAME_TAG"
      10 | +env | grep -E '^(CCACHE_|WINEDEBUG|LC_ALL|BOOST_TEST_RANDOM|CONFIG_SHELL)' | tee /tmp/env
    


    MarcoFalke commented at 6:58 PM on August 6, 2018:

    It is somewhat confusing to set LC_ALL=C.UTF-8 in the travis yaml, then set it to LC_ALL=C here, save it into a file, read that by docker, but then overwrite it again with LC_ALL=C.UTF-8 for the test runner.


    scravy commented at 7:31 PM on August 6, 2018:

    The lint-shell-locale.sh requires scripts to set LC_ALL=C. I could change it to also accept LC_ALL=C.UTF-8.

  42. scravy force-pushed on Aug 6, 2018
  43. scravy force-pushed on Aug 6, 2018
  44. scravy force-pushed on Aug 6, 2018
  45. scravy force-pushed on Aug 6, 2018
  46. scravy commented at 8:25 PM on August 6, 2018: contributor

    @MarcoFalke I've changed the scripts to export LC_ALL=C.UTF-8 and allowed that in lint-shell-locale in 50a51061fd04549625dedeed02bdf890548e3506 (rebased, now 54949499c1fdb860a6019d0b213b187e51a0a1b6)

  47. scravy force-pushed on Aug 7, 2018
  48. scravy force-pushed on Aug 7, 2018
  49. scravy force-pushed on Aug 7, 2018
  50. Gnappuraz commented at 1:10 PM on August 7, 2018: contributor

    utACK

  51. scravy force-pushed on Aug 7, 2018
  52. scravy force-pushed on Aug 7, 2018
  53. in test/lint/lint-shell-locale.sh:20 in a8bf3c5a70 outdated
      16 | @@ -16,7 +17,7 @@ for SHELL_SCRIPT in $(git ls-files -- "*.sh" | grep -vE "src/(secp256k1|univalue
      17 |          continue
      18 |      fi
      19 |      FIRST_NON_COMMENT_LINE=$(grep -vE '^(#.*|)$' "${SHELL_SCRIPT}" | head -1)
      20 | -    if [[ ${FIRST_NON_COMMENT_LINE} != "export LC_ALL=C" ]]; then
      21 | +    if [[ ${FIRST_NON_COMMENT_LINE} != "export LC_ALL=C" && ${FIRST_NON_COMMENT_LINE} != "export LC_ALL=C.UTF-8" ]]; then
    


    ken2812221 commented at 7:26 AM on August 8, 2018:

    nit: if [[ ! ${FIRST_NON_COMMENT_LINE} =~ "export LC_ALL=C"(|\.UTF-8)$ ]]; then


    practicalswift commented at 7:34 AM on August 8, 2018:

    I prefer the current version. It allows for copy and paste.


    scravy commented at 8:43 AM on August 8, 2018:

    @ken2812221 @practicalswift

    what about

        case "${FIRST_NON_COMMENT_LINE}" in
          "export LC_ALL=C");;
          "export LC_ALL=C.UTF-8");;
          *)
            echo "Missing \"export LC_ALL=C\" (to avoid locale dependence) as first non-comment non-empty line in ${SHELL_SCRIPT}"
            EXIT_CODE=1
        esac
    

    ken2812221 commented at 8:49 AM on August 8, 2018:

    LGTM


    scravy commented at 8:55 AM on August 8, 2018:

    pushed 336b9ae61511275570bebf4797343f6973c5e9a3


    practicalswift commented at 9:02 AM on August 8, 2018:

    @scravy Oh, I think a simple if-statement is much clearer than the suggested case construction. I suggest reverting back to the original version which was perfectly fine and simple :-)


    scravy commented at 9:07 AM on August 8, 2018:

    🧐removed the commit again.


    practicalswift commented at 9:17 AM on August 8, 2018:

    @scravy Looks good now! Keep it that way :-)

  54. scravy force-pushed on Aug 8, 2018
  55. ken2812221 approved
  56. ken2812221 commented at 4:40 AM on August 9, 2018: contributor

    utACK a8bf3c5a70e9924fd967d62a25915b68d2a6b0bc

  57. scravy force-pushed on Aug 9, 2018
  58. scravy force-pushed on Aug 10, 2018
  59. scravy commented at 9:04 AM on August 10, 2018: contributor

    About conflicting pull requests:

    • #13845 will be part of 0.18 and won't be merged soon
    • #13728 is fine and AFAICS ready to go and is perfectly reconcilable with this one (in deed this PR has it's origin in #13816 which has very much the same spirit - running tests on os x natively)
    • #13515 has untackled review comments and an outstanding requested review

    This one I just rebased.

  60. DrahtBot cross-referenced this on Aug 13, 2018 from issue Warn (don't fail!) on spelling errors. Fix typos reported by codespell. by practicalswift
  61. DrahtBot cross-referenced this on Aug 14, 2018 from issue ~~Correctly~~ terminate HTTP server by promag
  62. scravy force-pushed on Aug 15, 2018
  63. scravy force-pushed on Aug 15, 2018
  64. scravy commented at 12:56 PM on August 15, 2018: contributor

    Can this be merged or are there any more remarks/suggestions?

  65. MarcoFalke commented at 1:06 PM on August 15, 2018: member

    @scravy It needs review and testing

  66. scravy commented at 1:30 PM on August 15, 2018: contributor

    @MarcoFalke

    So I was wondering about that. If something touches the travis-definitions only – what is the difference between ACK and utACK here, what could I do to test it? I am rebasing this PR every day and the travis build works splendidly every time (except for this one time where everything in travis failed as it did not at all have any network connectivity).

    Because I do not see what more I could do (as a reviewer) but look at travis whether it worked or not. Possibly I could imagine forking and pushing it in my own github-space and looking at travis for my repo, seeing if I can make it fail in the way it should fail (again, as a reviewer; obviously I did that but I'm the author).

    I'm mostly asking out of curiosity.

  67. MarcoFalke commented at 3:09 PM on August 15, 2018: member

    Travis is completely useless when it passes every time. It must also detect any issues that are present and report them correctly.

  68. scravy commented at 3:30 PM on August 15, 2018: contributor

    Obviously it passes every time because there is no other development happening on this branch, and I'm rebasing against things which passed the CI check before. While reacting to change requests in the discussion in here it very well failed a few times.

    For easier verification would it make sense to link these failing builds?

    Again though, what is a reviewer supposed to do in order to test this? The only thing I can imagine is push it from your own repository to trigger a travis build for that and try to make it break there, right?

  69. practicalswift commented at 3:50 PM on August 15, 2018: contributor

    @scravy Yes, a good start would be your idea to try to cause each script to fail individually and verify that the build fails as expected. For the linting script - introduce a linting violation that should make it fail, etc :-)

  70. DrahtBot cross-referenced this on Aug 26, 2018 from issue travis: Run unit tests --with-sanitizers=undefined by MarcoFalke
  71. DrahtBot added the label Needs rebase on Aug 27, 2018
  72. move script sections info individual files and comply with shellcheck 4f2f88c7b0
  73. abort script in END_FOLD on non-zero exit code 86d34f0e65
  74. move lint stage up to resemble travis build ui
    adjust indentation to 2 spaces
    519e2739cf
  75. number .travis/ script according to build lifecycle and add README to explain 272306ea57
  76. move remaining travis build steps into individual files 506890b24d
  77. make script exit if a command fails 728c82d029
  78. use export LC_ALL=C.UTF-8 414326952c
  79. scravy force-pushed on Aug 27, 2018
  80. DrahtBot removed the label Needs rebase on Aug 27, 2018
  81. scravy commented at 11:41 AM on August 27, 2018: contributor

    Rebased.

  82. scravy force-pushed on Aug 27, 2018
  83. scravy force-pushed on Aug 27, 2018
  84. scravy force-pushed on Aug 27, 2018
  85. scravy force-pushed on Aug 27, 2018
  86. scravy commented at 12:27 PM on August 27, 2018: contributor

    In https://github.com/bitcoin/bitcoin/pull/13863/commits/8ad042b4bebbfd2e38bb4cc7ed36bc047aaf09cd I am explicitly breaking the build by introducing an undocumented argument, which is supposed to fail the lint stage.

    Here's the build failing in the lint stage in my repository: https://travis-ci.org/scravy/bitcoin/jobs/421068804#L575

    Here's the build failing in the lint stage as a pull request: https://travis-ci.org/bitcoin/bitcoin/jobs/421068842#L580

    Screenshots of the failing build: <img width="1570" alt="screen shot 2018-08-27 at 14 32 16" src="https://user-images.githubusercontent.com/295504/44659955-493c1480-aa06-11e8-9bbd-bcd0c7ab499f.png"> <img width="1557" alt="screen shot 2018-08-27 at 14 31 57" src="https://user-images.githubusercontent.com/295504/44659959-4c370500-aa06-11e8-8730-a27035ba4c4a.png">

  87. scravy commented at 12:47 PM on August 27, 2018: contributor

    In https://github.com/bitcoin/bitcoin/pull/13863/commits/236091eebfa9fb0234b0ff7549ec730e87d5a589 I'm undoing the lint-error such that the lint stage passes again and introduce a compilation error in src/init.cpp to fail the build in the test stage.

    Here's the build failing in the test stage in my repository: https://travis-ci.org/scravy/bitcoin/builds/421075688 (exact failure: https://travis-ci.org/scravy/bitcoin/jobs/421075692#L2865 )

    <img width="1583" alt="screen shot 2018-08-27 at 14 43 39" src="https://user-images.githubusercontent.com/295504/44660343-9cfb2d80-aa07-11e8-955a-f12e5ec6cda6.png"> <img width="1543" alt="screen shot 2018-08-27 at 14 42 38" src="https://user-images.githubusercontent.com/295504/44660304-7fc65f00-aa07-11e8-8646-a3ccb3f7f379.png">

    Here's the build failing in the test stage as a pull request: https://travis-ci.org/bitcoin/bitcoin/builds/421075705 (exact failure: https://travis-ci.org/bitcoin/bitcoin/jobs/421075707#L3120 )

    <img width="1551" alt="screen shot 2018-08-27 at 14 44 47" src="https://user-images.githubusercontent.com/295504/44660445-ddf34200-aa07-11e8-8c92-8eda08dcde86.png"> <img width="1548" alt="screen shot 2018-08-27 at 14 46 46" src="https://user-images.githubusercontent.com/295504/44660501-0c711d00-aa08-11e8-8984-e4c052d70694.png">

  88. scravy commented at 12:57 PM on August 27, 2018: contributor

    In https://github.com/bitcoin/bitcoin/pull/13863/commits/b1ab0435ad245161c3a4906b0fe4a68bd211927a I undo the compile error and introduce a lint violation insisde on of the travis script files (not using LC_ALL=c, violating lint-shell-locale).

    This is how it's failing in my repository: https://travis-ci.org/scravy/bitcoin/jobs/421082198#L579

    This is how it's failing as a pull request: https://travis-ci.org/bitcoin/bitcoin/jobs/421082215#L585

    <img width="1553" alt="screen shot 2018-08-27 at 14 55 42" src="https://user-images.githubusercontent.com/295504/44660888-4f7fc000-aa09-11e8-9323-c3981a2faacc.png"> <img width="1545" alt="screen shot 2018-08-27 at 14 55 33" src="https://user-images.githubusercontent.com/295504/44660889-4f7fc000-aa09-11e8-8eb3-78b43cceb22d.png"> <img width="1548" alt="screen shot 2018-08-27 at 14 54 20" src="https://user-images.githubusercontent.com/295504/44660891-4f7fc000-aa09-11e8-9622-51236f9adf51.png"> <img width="1554" alt="screen shot 2018-08-27 at 14 54 10" src="https://user-images.githubusercontent.com/295504/44660893-4f7fc000-aa09-11e8-93e0-90ccd1430bec.png">

  89. MarcoFalke force-pushed on Aug 27, 2018
  90. MarcoFalke merged this on Aug 27, 2018
  91. MarcoFalke closed this on Aug 27, 2018

  92. MarcoFalke referenced this in commit ca4510c15d on Aug 27, 2018
  93. in .travis/test_06_script.sh:47 in 414326952c
      42 | +
      43 | +BEGIN_FOLD build
      44 | +DOCKER_EXEC make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && DOCKER_EXEC make $GOAL V=1 ; false )
      45 | +END_FOLD
      46 | +
      47 | +if [ "$RUN_TESTS" = "true" ]; then
    


    MarcoFalke commented at 1:57 PM on August 27, 2018:

    There is no symbol with that name, please adjust

  94. in .travis/test_06_script.sh:63 in 414326952c
      58 | +
      59 | +if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then
      60 | +  extended="--extended --exclude feature_pruning,feature_dbcrash"
      61 | +fi
      62 | +
      63 | +if [ "$RUN_TESTS" = "true" ]; then
    


    MarcoFalke commented at 1:57 PM on August 27, 2018:

    Same here

  95. scravy commented at 2:11 PM on August 27, 2018: contributor

    @MarcoFalke I see two review comments of yours, yet the PR was merged. You say RUN_TESTS is not exported? Will send a follow-up PR then.

  96. scravy cross-referenced this on Aug 27, 2018 from issue travis: fix missing differentiation between UNIT and FUNCTIONAL tests by scravy
  97. scravy commented at 2:16 PM on August 27, 2018: contributor
  98. MarcoFalke referenced this in commit 794e55be10 on Aug 27, 2018
  99. ken2812221 cross-referenced this on Sep 16, 2018 from issue travis: Save cache even when build or test fail by ken2812221
  100. scravy cross-referenced this on Nov 30, 2018 from issue Add basic TravisCI support by castarco
  101. MarcoFalke referenced this in commit c62b151189 on Dec 3, 2018
  102. sickpig cross-referenced this on Jan 18, 2019 from issue Improve travis caching by sickpig
  103. str4d cross-referenced this on Oct 27, 2020 from issue Backport useful lints from upstream by str4d
  104. zkbot referenced this in commit 43ac2062f9 on Oct 28, 2020
  105. zkbot referenced this in commit 84a5830aaa on Nov 9, 2020
  106. Munkybooty referenced this in commit e1e77958ce on Jun 30, 2021
  107. Munkybooty referenced this in commit d80d16e5d7 on Jun 30, 2021
  108. Munkybooty referenced this in commit 17362b8fd4 on Jul 1, 2021
  109. Munkybooty referenced this in commit 62e2f0060a on Jul 1, 2021
  110. Munkybooty referenced this in commit 7f7aa533fe on Jul 1, 2021
  111. Munkybooty referenced this in commit a3a381b28b on Jul 1, 2021
  112. Munkybooty referenced this in commit 6235905170 on Jul 2, 2021
  113. Munkybooty referenced this in commit a872c78836 on Jul 2, 2021
  114. Munkybooty referenced this in commit 3f75de340a on Jul 2, 2021
  115. Munkybooty referenced this in commit 251ce629e7 on Jul 2, 2021
  116. Munkybooty referenced this in commit 6accd035a9 on Jul 4, 2021
  117. Munkybooty referenced this in commit a33cfb7c92 on Jul 4, 2021
  118. UdjinM6 referenced this in commit 50d8d8023e on Jul 7, 2021
  119. Munkybooty referenced this in commit 60ce84bffe on Jul 7, 2021
  120. Munkybooty referenced this in commit 9d9efce3f4 on Jul 7, 2021
  121. UdjinM6 referenced this in commit 77bbcd9612 on Jul 7, 2021
  122. Munkybooty referenced this in commit 1ba72e6323 on Jul 7, 2021
  123. Munkybooty referenced this in commit 4c2211dd41 on Jul 8, 2021
  124. Munkybooty referenced this in commit 483520e5e6 on Jul 8, 2021
  125. Munkybooty referenced this in commit 8e25e2f0fe on Jul 8, 2021
  126. Munkybooty referenced this in commit f2d7c6e715 on Jul 9, 2021
  127. linuxsh2 referenced this in commit 660394ead1 on Jul 29, 2021
  128. Munkybooty referenced this in commit faab35dc2d on Aug 2, 2021
  129. Munkybooty referenced this in commit 1a6a42cfd6 on Aug 3, 2021
  130. Munkybooty referenced this in commit b489595fc8 on Aug 5, 2021
  131. Munkybooty referenced this in commit 2a9174c4ec on Aug 17, 2021
  132. bitcoin locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:54 UTC