Skip to content

Commit bb76d1e

Browse files
authored
Refine e2e script. (#3470)
1 parent 1529921 commit bb76d1e

File tree

5 files changed

+58
-25
lines changed

5 files changed

+58
-25
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ tfjs-layers/integration_tests/tfjs2keras/test-data/
2828
tfjs-layers/integration/typescript/yarn.lock
2929
e2e/integration_tests/create_save_predict_data
3030
e2e/integration_tests/convert_predict_data
31+
e2e/scripts/storage
32+
e2e/scripts/htpasswd
3133
tfjs-converter/python/tensorflowjs.egg-info
3234
tfjs-inference/binaries
3335

e2e/scripts/local-registry.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,16 @@ function startLocalRegistry {
2727
# Wait for Verdaccio to boot
2828
grep -q 'http address' <(tail -f $tmp_registry_log)
2929

30+
# Login so we can publish packages
31+
npx npm-cli-login -u user -p password -e [email protected] -r $custom_registry_url
32+
3033
# Set registry to local registry
3134
npm set registry "$custom_registry_url"
3235
yarn config set registry "$custom_registry_url"
33-
34-
# Login so we can publish packages
35-
(cd && npx [email protected] -u user -p password -e [email protected] -r "$custom_registry_url")
3636
}
3737

3838
function stopLocalRegistry {
3939
# Restore the original NPM and Yarn registry URLs and stop Verdaccio
4040
npm set registry "$original_npm_registry_url"
4141
yarn config set registry "$original_yarn_registry_url"
4242
}
43-
44-
function publishToLocalRegistry {
45-
git clean -df
46-
./scripts/publish.sh prerelease --yes --force-publish=* --no-git-tag-version --no-commit-hooks --no-push --exact --dist-tag=latest
47-
}

e2e/scripts/publish.sh renamed to e2e/scripts/publish-monorepo-ci.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright 2020 Google LLC. All Rights Reserved.
2+
# Copyright 2020 Google Inc. All Rights Reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -24,13 +24,10 @@ set -e
2424
set -x
2525

2626
# Go to root
27-
cd ..
27+
cd ../../
2828
root_path=$PWD
2929

30-
if [ -n "$(git status --porcelain)" ]; then
31-
echo "Your git status is not clean. Aborting.";
32-
exit 1;
33-
fi
30+
# Yarn in the top-level and in the directory,
31+
yarn
3432

35-
# Publish to local registry
36-
# Todo(linazhao): Develop and use a one step for all release script.
33+
# Todo(linazhao): publish monorepo

e2e/scripts/start-verdaccio.sh

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,56 @@
1919
# Start in scripts/ even if run from root directory
2020
cd "$(dirname "$0")"
2121

22-
if [[ "$RELEASE" = true ]]; then
23-
# Load functions for working with local NPM registry (Verdaccio)
24-
source local-registry.sh
22+
# Load functions for working with local NPM registry (Verdaccio)
23+
source local-registry.sh
24+
25+
function cleanup {
26+
echo 'Cleaning up.'
27+
# Restore the original NPM and Yarn registry URLs and stop Verdaccio
28+
stopLocalRegistry
29+
}
30+
31+
# Error messages are redirected to stderr
32+
function handle_error {
33+
echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2;
34+
cleanup
35+
echo 'Exiting with error.' 1>&2;
36+
exit 1
37+
}
38+
39+
function handle_exit {
40+
cleanup
41+
echo 'Exiting without error.' 1>&2;
42+
exit
43+
}
44+
45+
# Exit the script with a helpful error message when any error is encountered
46+
trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR
47+
48+
# Cleanup before exit on any termination signal
49+
trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP
50+
51+
# Echo every command being executed
52+
set -x
2553

54+
# Go to e2e root
55+
cd ..
56+
e2e_root_path=$PWD
57+
58+
if [[ "$RELEASE" = true ]]; then
2659
# ****************************************************************************
2760
# First, publish the monorepo.
2861
# ****************************************************************************
2962

3063
# Start the local NPM registry
31-
startLocalRegistry verdaccio.yaml
64+
startLocalRegistry "$e2e_root_path"/scripts/verdaccio.yaml
3265

3366
# Publish the monorepo
34-
publishToLocalRegistry
35-
fi
67+
"$e2e_root_path"/scripts/publish-monorepo-ci.sh
3668

37-
# Back to root
38-
cd ..
69+
echo 'Installing package'
70+
yarn
71+
72+
# Cleanup
73+
cleanup
74+
fi

e2e/scripts/verdaccio.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ uplinks:
1414
packages:
1515
'@*/*':
1616
access: $all
17-
publish: $authenticated
17+
publish: $all
1818
proxy: npmjs
1919
'**':
20+
access: $all
21+
publish: $all
22+
# if package is not available locally, proxy requests to 'npmjs' registry
2023
proxy: npmjs
2124

2225
# log settings

0 commit comments

Comments
 (0)