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