File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 2121#
2222# Note: in GitHub Actions environments, `/cloudsql` is not valid.
2323# Ensure any INSTANCE_UNIX_SOCKET value is ~= $UNIX_SOCKET_DIR/$CLOUD_SQL_CONNECTION_NAME
24- #
24+
25+ usage () {
26+ cat << EOF
2527# Usage:
26- # sql-proxy.sh [..]
28+ # CLOUD_SQL_CONNECTION_NAME=project:region:instance sql-proxy.sh [..]
2729#
2830# Defaults to TCP socket proxy. Set ` SOCKET=unix` for Unix sockets.
2931#
3032# Usage in package.json:
3133#
32- # "proxy": "bash $GITHUB_WORKSPACE/.github/workflows/utils/debug-sql-proxy.sh",
34+ # "proxy": "$GITHUB_WORKSPACE /.github/workflows/utils/debug-sql-proxy.sh",
3335# "system-test": "npm run proxy -- c8 mocha test/... ",
3436# "system-test-unix": "SOCKET=unix npm run proxy -- c8 mocha test/... ",
37+ EOF
38+ }
39+
3540
3641PROXY_VERSION=" v2.15.1"
3742SOCKET=${SOCKET:- tcp}
3843
39- echop (){
44+ echop (){ # Print Echo
4045 echo " 👾 $1 "
4146}
4247
48+ exit_message () { # Error Echo
49+ echo " ❌ $1 "
50+ usage ()
51+ exit 1
52+ }
53+
54+ if [[ -z " $CLOUD_SQL_CONNECTION_NAME " ]]; then
55+ exit_message " Must provide CLOUD_SQL_CONNECTION_NAME"
56+ fi
4357
4458if [[ $SOCKET == " unix" ]]; then
4559 UNIX_SOCKET_DIR=${UNIX_SOCKET_DIR:- " tmp/cloudsql" }
60+
61+ if [[ $UNIX_SOCKET_DIR == " /cloudsql " ]]; then
62+ exit_message " Cannot use /cloudsql in a GitHub Actions context"
63+ fi
64+
4665 mkdir -p $UNIX_SOCKET_DIR && chmod 777 $UNIX_SOCKET_DIR
4766 socket=" --unix-socket $UNIX_SOCKET_DIR "
4867fi
Original file line number Diff line number Diff line change 1313 },
1414 "scripts" : {
1515 "start" : " node server/server.js" ,
16- "proxy" : " bash $GITHUB_WORKSPACE/.github/workflows/utils/sql-proxy.sh" ,
16+ "proxy" : " $GITHUB_WORKSPACE/.github/workflows/utils/sql-proxy.sh" ,
1717 "system-test" : " npm run proxy -- c8 mocha -p -j 2 test/server.test.js --colors --timeout=60000 --exit" ,
1818 "system-test-unix" : " SOCKET=unix npm run proxy -- c8 mocha -p -j 2 test/server-unix.test.js --colors --timeout=60000 --exit" ,
1919 "test" : " npm run system-test && npm run system-test-unix"
You can’t perform that action at this time.
0 commit comments