endtoend-build-ci 2.0 KB

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