endtoend-build-ci 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env bash
  2. set -o pipefail
  3. set -o errexit
  4. set -o nounset
  5. set -o xtrace
  6. # Set magic variables for current file & dir
  7. __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  8. __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
  9. __base="$(basename ${__file} .sh)"
  10. __root="$(cd "$(dirname "${__dir}")" && pwd)"
  11. VERDACCIO_REGISTRY=http://localhost:4002
  12. cleanup() {
  13. rm -rf "${__root}/test/endtoend/node_modules"
  14. rm -rf "${__root}/test/endtoend/tmp"
  15. }
  16. function on_exit() {
  17. # revert to public registry
  18. npm set registry https://registry.npmjs.org
  19. cleanup
  20. }
  21. trap on_exit EXIT
  22. echo "Preparing for end to end test: copying static HTML and CSS, building JS"
  23. rm -rf "${__root}/test/endtoend/node_modules"
  24. # list of @uppy/* packages
  25. PACKAGES="$(for pkg in packages/@uppy/*; do echo "${pkg#packages/}"; done)"
  26. cleanup
  27. # Initialise verdaccio storage path.
  28. mkdir -p "${__root}/test/endtoend/tmp/verdaccio"
  29. npm run build
  30. # https://github.com/facebook/create-react-app/pull/4626
  31. (cd && npm-auth-to-token -u user -p password -e user@example.com -r "$VERDACCIO_REGISTRY")
  32. git checkout -b endtoend-test-build
  33. # HACK this thing changes all the time for some reason on CI
  34. # so I'll just ignore it…
  35. git checkout -- package-lock.json
  36. # Simulate a publish of everything, to the local registry,
  37. # without changing things in git
  38. lerna version prerelease --yes \
  39. --exact \
  40. --force-publish \
  41. --npm-client=npm \
  42. --no-push
  43. lerna publish from-git --yes \
  44. --registry="$VERDACCIO_REGISTRY" \
  45. --no-verify-access \
  46. --npm-client=npm
  47. # revert version changes
  48. git checkout -- packages/*/package.json packages/@uppy/*/package.json
  49. # install all packages to the endtoend folder
  50. # (Don't use the npm cache, don't generate a package-lock, don't save dependencies to any package.json)
  51. pushd "${__root}/test/endtoend"
  52. npm install \
  53. --prefer-online \
  54. --registry "$VERDACCIO_REGISTRY" \
  55. --no-package-lock \
  56. --no-save \
  57. uppy $PACKAGES
  58. popd
  59. bash "${__dir}/endtoend-build-tests"
  60. cleanup