E2E test Babel with itself before publishing (#10569)
* Add e2e test using Babel itself * Make checks run again
This commit is contained in:
30
scripts/integration-tests/utils/cleanup.sh
Executable file
30
scripts/integration-tests/utils/cleanup.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
function cleanup {
|
||||
echo "Cleaning up."
|
||||
stopLocalRegistry
|
||||
|
||||
if [ -n "$GIT_E2E_SETUP" ]; then
|
||||
cleanupE2Egit
|
||||
fi
|
||||
}
|
||||
|
||||
# Error messages are redirected to stderr
|
||||
function handle_error {
|
||||
echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2;
|
||||
cleanup
|
||||
echo "Exiting with error." 1>&2;
|
||||
exit 1
|
||||
}
|
||||
|
||||
function handle_exit {
|
||||
cleanup
|
||||
echo "Exiting without error." 1>&2;
|
||||
exit
|
||||
}
|
||||
|
||||
# Exit the script with a helpful error message when any error is encountered
|
||||
trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR
|
||||
|
||||
# Cleanup before exit on any termination signal
|
||||
trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP
|
||||
29
scripts/integration-tests/utils/git.sh
Executable file
29
scripts/integration-tests/utils/git.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
original_git_branch=`git rev-parse --abbrev-ref HEAD`
|
||||
tmp_branch_name="integration-tests-$(date +'%F-%H-%M-%N')"
|
||||
original_user_name=`git config user.name`
|
||||
original_user_email=`git config user.email`
|
||||
|
||||
export GIT_E2E_SETUP="true"
|
||||
|
||||
function initializeE2Egit {
|
||||
git checkout -b $tmp_branch_name
|
||||
|
||||
# This is needed by lerna, which commits when publishing
|
||||
git config user.name "Babel E2E Test"
|
||||
git config user.email "babel-e2e@example.com"
|
||||
}
|
||||
|
||||
function cleanupE2Egit {
|
||||
# Delete release tags
|
||||
git tag -d $(git tag -l "version-e2e-test-*")
|
||||
|
||||
# Checkout the previous branch
|
||||
git checkout -f $original_git_branch
|
||||
git branch -D $tmp_branch_name
|
||||
|
||||
# Restore git user
|
||||
git config user.name "$original_user_name"
|
||||
git config user.email "$original_user_email"
|
||||
}
|
||||
34
scripts/integration-tests/utils/local-registry.sh
Executable file
34
scripts/integration-tests/utils/local-registry.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copied from https://github.com/facebook/create-react-app/blob/053f9774d3f592c17741d2a86de66a7ca58f90c0/tasks/local-registry.sh
|
||||
|
||||
custom_registry_url=http://localhost:4873
|
||||
original_npm_registry_url=`npm get registry`
|
||||
original_yarn_registry_url=`yarn config get registry`
|
||||
default_verdaccio_package=verdaccio@~4.3.3
|
||||
|
||||
function startLocalRegistry {
|
||||
# Start local registry
|
||||
tmp_registry_log=`mktemp`
|
||||
echo "Registry output file: $tmp_registry_log"
|
||||
(cd && nohup npx ${VERDACCIO_PACKAGE:-$default_verdaccio_package} -c $1 &>$tmp_registry_log &)
|
||||
|
||||
# Wait for Verdaccio to boot
|
||||
grep -q "http address" <(tail -f $tmp_registry_log)
|
||||
|
||||
# Set registry to local registry
|
||||
npm set registry "$custom_registry_url"
|
||||
yarn config set registry "$custom_registry_url"
|
||||
}
|
||||
|
||||
function loginLocalRegistry {
|
||||
# Login so we can publish packages
|
||||
(cd && npx npm-auth-to-token@1.0.0 -u user -p password -e user@example.com -r "$custom_registry_url")
|
||||
}
|
||||
|
||||
function stopLocalRegistry {
|
||||
# Restore the original NPM and Yarn registry URLs and stop Verdaccio
|
||||
fuser -k 4873/tcp
|
||||
npm set registry "$original_npm_registry_url"
|
||||
yarn config set registry "$original_yarn_registry_url"
|
||||
}
|
||||
Reference in New Issue
Block a user