endtoend-build-ci 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env bash
  2. set -o pipefail
  3. set -o errexit
  4. set -o nounset
  5. # Set magic variables for current file & dir
  6. __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  7. __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
  8. __base="$(basename ${__file} .sh)"
  9. __root="$(cd "$(dirname "${__dir}")" && pwd)"
  10. if [ -z "${CI:-}" ]; then
  11. echo "!! Running CI-style end-to-end tests but CI environment variable is not set"
  12. echo "It is generally ill-advised to run the full end-to-end suite on your local machine."
  13. echo "You are probably looking for this instead:"
  14. echo " npm run test:endtoend:local"
  15. echo ""
  16. echo "Hit Ctrl+C to stop or Enter if you REALLY DO want to run the full thing."
  17. read
  18. else
  19. echo travis_fold:start:endtoend_build_ci
  20. fi
  21. set -o xtrace
  22. VERDACCIO_REGISTRY=http://localhost:4002
  23. CURRENT_COMMIT="$(git rev-parse HEAD)"
  24. cleanup() {
  25. rm -rf "${__root}/test/endtoend/node_modules"
  26. rm -rf "${__root}/test/endtoend/tmp"
  27. git reset
  28. git checkout $CURRENT_COMMIT
  29. if [ -n "${CI:-}" ]; then
  30. echo travis_fold:end:endtoend_build_ci
  31. fi
  32. }
  33. function on_exit() {
  34. # revert to public registry
  35. npm set registry https://registry.npmjs.org
  36. cleanup
  37. }
  38. trap on_exit EXIT
  39. echo "Preparing for end to end test: copying static HTML and CSS, building JS"
  40. rm -rf "${__root}/test/endtoend/node_modules"
  41. # list of @uppy/* packages
  42. PACKAGES="$(for pkg in packages/@uppy/*; do echo "${pkg#packages/}"; done)"
  43. cleanup
  44. # Initialise verdaccio storage path.
  45. mkdir -p "${__root}/test/endtoend/tmp/verdaccio"
  46. npm run build
  47. # https://github.com/facebook/create-react-app/pull/4626
  48. (cd && npm-auth-to-token -u user -p password -e user@example.com -r "$VERDACCIO_REGISTRY")
  49. git checkout -b endtoend-test-build
  50. # HACK this thing changes all the time for some reason on CI
  51. # so I'll just ignore it…
  52. git checkout -- package-lock.json
  53. # Simulate a publish of everything, to the local registry,
  54. # without changing things in git
  55. ENDTOEND=1 lerna version prerelease --yes \
  56. --exact \
  57. --force-publish \
  58. --no-push
  59. ENDTOEND=1 lerna publish from-git --yes \
  60. --registry="$VERDACCIO_REGISTRY" \
  61. --no-verify-access
  62. # install all packages to the endtoend folder
  63. # (Don't use the npm cache, don't generate a package-lock, don't save dependencies to any package.json)
  64. pushd "${__root}/test/endtoend"
  65. PKG_VERSIONS="$(echo uppy $PACKAGES | sed -e 's/\S\+\b/&@latest/g')"
  66. echo '{}' > package.json # temp pkg.json to make sure npm installs deps in this folder
  67. npm install \
  68. --prefer-online \
  69. --registry "$VERDACCIO_REGISTRY" \
  70. --no-package-lock \
  71. --no-save \
  72. $PKG_VERSIONS
  73. rm package.json
  74. popd
  75. bash "${__dir}/endtoend-build-tests"
  76. cleanup