endtoend-build-ci 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. fi
  19. set -o xtrace
  20. VERDACCIO_REGISTRY=http://localhost:4002
  21. CURRENT_COMMIT="$(git rev-parse HEAD)"
  22. cleanup() {
  23. rm -rf "${__root}/test/endtoend/node_modules"
  24. rm -rf "${__root}/test/endtoend/tmp"
  25. git reset
  26. git checkout $CURRENT_COMMIT
  27. }
  28. function on_exit() {
  29. # revert to public registry
  30. npm set registry https://registry.npmjs.org
  31. cleanup
  32. }
  33. trap on_exit EXIT
  34. echo "Preparing for end to end test: copying static HTML and CSS, building JS"
  35. rm -rf "${__root}/test/endtoend/node_modules"
  36. # list of @uppy/* packages
  37. PACKAGES="$(for pkg in packages/@uppy/*; do echo "${pkg#packages/}"; done)"
  38. cleanup
  39. # Initialise verdaccio storage path.
  40. mkdir -p "${__root}/test/endtoend/tmp/verdaccio"
  41. npm run build
  42. # https://github.com/facebook/create-react-app/pull/4626
  43. (cd && npm-auth-to-token -u user -p password -e user@example.com -r "$VERDACCIO_REGISTRY")
  44. git checkout -b endtoend-test-build
  45. # HACK this thing changes all the time for some reason on CI
  46. # so I'll just ignore it…
  47. git checkout -- package-lock.json
  48. # Simulate a publish of everything, to the local registry,
  49. # without changing things in git
  50. ENDTOEND=1 lerna version prerelease --yes \
  51. --exact \
  52. --force-publish \
  53. --npm-client=npm \
  54. --no-push
  55. ENDTOEND=1 lerna publish from-git --yes \
  56. --registry="$VERDACCIO_REGISTRY" \
  57. --no-verify-access \
  58. --npm-client=npm
  59. # install all packages to the endtoend folder
  60. # (Don't use the npm cache, don't generate a package-lock, don't save dependencies to any package.json)
  61. pushd "${__root}/test/endtoend"
  62. npm install \
  63. --prefer-online \
  64. --registry "$VERDACCIO_REGISTRY" \
  65. --no-package-lock \
  66. --no-save \
  67. uppy $PACKAGES
  68. popd
  69. bash "${__dir}/endtoend-build-tests"
  70. cleanup