12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #!/usr/bin/env bash
- set -o pipefail
- set -o errexit
- set -o nounset
- # Set magic variables for current file & dir
- __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
- __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
- __base="$(basename ${__file} .sh)"
- __root="$(cd "$(dirname "${__dir}")" && pwd)"
- if [ -z "${CI:-}" ]; then
- echo "!! Running CI-style end-to-end tests but CI environment variable is not set"
- echo "It is generally ill-advised to run the full end-to-end suite on your local machine."
- echo "You are probably looking for this instead:"
- echo " yarn run test:endtoend:local"
- echo ""
- echo "Hit Ctrl+C to stop or Enter if you REALLY DO want to run the full thing."
- read
- else
- echo ::group::endtoend_build_ci
- fi
- set -o xtrace
- YARN="corepack yarn"
- VERDACCIO_REGISTRY=http://localhost:4002
- CURRENT_COMMIT="$(git rev-parse HEAD)"
- cleanup() {
- rm -rf "${__root}/test/endtoend/node_modules"
- rm -rf "${__root}/test/endtoend/tmp"
- git reset
- git checkout $CURRENT_COMMIT
- if [ -n "${CI:-}" ]; then
- echo ::endgroup::
- fi
- }
- function on_exit() {
- # revert to public registry
- $YARN config unset npmScopes --home
- $YARN config unset npmRegistryServer --home
- $YARN config unset npmAuthToken --home
- $YARN config unset unsafeHttpWhitelist --home
- cleanup
- }
- trap on_exit EXIT
- echo "Preparing for end to end test: copying static HTML and CSS, building JS"
- rm -rf "${__root}/test/endtoend/node_modules"
- # list of @uppy/* packages
- PACKAGES="$($YARN workspaces list --json | node -e 'require("readline").createInterface({input:process.stdin}).on("line",l=>{const{name}=JSON.parse(l);if(name?.startsWith("@uppy/"))console.log(name)})')"
- cleanup
- # Initialise verdaccio storage path.
- mkdir -p "${__root}/test/endtoend/tmp/verdaccio"
- $YARN run build
- # https://github.com/facebook/create-react-app/pull/4626
- TOKEN="$($YARN npm-auth-to-token -u user -p password -e user@example.com -r "$VERDACCIO_REGISTRY")"
- git checkout -b endtoend-test-build
- # HACK this thing changes all the time for some reason on CI
- # so I'll just ignore it…
- git checkout -- yarn.lock
- $YARN config set npmRegistryServer "$VERDACCIO_REGISTRY" --home
- $YARN config set npmAuthToken "$TOKEN" --home
- $YARN config set npmScopes.uppy.npmRegistryServer "$VERDACCIO_REGISTRY" --home
- $YARN config set npmScopes.uppy.npmPublishRegistry "$VERDACCIO_REGISTRY" --home
- $YARN config set npmScopes.uppy.npmAuthToken "$TOKEN" --home
- $YARN config set unsafeHttpWhitelist "localhost" --home
- # Simulate a publish of everything, to the local registry,
- # without changing things in git
- ENDTOEND=1 $YARN workspaces foreach --include '@uppy/*'\
- version prerelease -d
- $YARN version apply --all --prerelease
- ENDTOEND=1 $YARN workspaces foreach --include '@uppy/*'\
- npm publish
- bash "${__dir}/endtoend-build-tests"
- cleanup
|