-
Notifications
You must be signed in to change notification settings - Fork 2k
chore(ci): migrate mysql/mysql + proof of concept proxy helper #4040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+113
−3
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
f46b2a1
wip: proof of concept cloud-sql mysql
glasnt c54abd2
chmod
glasnt e1d0de8
add sleep to ensure proxy starts before use
glasnt 3507ff7
use correct envvar
glasnt 41ad376
extra bit
glasnt ae36e28
debugging
glasnt 5ecb710
instance_host is deleted by the server-unix test
glasnt 6326bd3
proxy all tests
glasnt c004e1a
accepting gemini-code-assist code
glasnt 6a98c4d
oop
glasnt 0bbd11b
Merge branch 'main' into sql-tests-2
glasnt d82ed40
wip: tcp or unix
glasnt 43a8e53
syntax
glasnt 81781de
cause she looks like a flower
glasnt 4ff9afc
more shell logic
glasnt a47abdf
sh
glasnt b7dcf45
continued proof of concept
glasnt 8699edf
call shutdown
glasnt 23b9430
format value
glasnt 23f3a2e
order?
glasnt 986a700
Merge branch 'main' into sql-tests-2
glasnt 0cf5917
debug: echo
glasnt 184e6c4
hoisted by my own petard.
glasnt 5b00c53
tmp file
glasnt 0e60a3d
-p
glasnt d43ccb1
WIP: shared proxy setup
glasnt a82cdbf
chmod
glasnt 2c8a076
maybe?
glasnt f0fbd65
??
glasnt e8594a6
bash
glasnt f13d4eb
debug
glasnt 629fa09
debug
glasnt 8bf31b9
maybe
glasnt a62e1bf
more bash
glasnt 24bd715
simplify usage
glasnt f26c218
cleanup
glasnt 82ff1dd
actually use the new setting
glasnt 8d5befd
remove old setting
glasnt b83a1af
attempt formatting
glasnt 1e5b92d
add mocha colour
glasnt a8f39d5
at least use something
glasnt 41bc54a
code review comments
glasnt 21ebc78
syntax
glasnt 919bd8f
syntax
glasnt c425a7e
fix usage
glasnt a811f0f
Merge branch 'main' into sql-tests-2
glasnt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| #!/bin/bash -ex | ||
|
|
||
| # Copyright 2025 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Shared Cloud SQL Proxy setup | ||
| # Presumes the following variables in ci-setup.json: | ||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # * CLOUD_SQL_CONNECTION_NAME - the project:region:instance of a Cloud SQL instance. | ||
| # * UNIX_SOCKET_DIR - a local directory to set the proxy to (default tmp/cloudsql) | ||
| # | ||
| # Note: in GitHub Actions environments, `/cloudsql` is not valid. | ||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Ensure any INSTANCE_UNIX_SOCKET value is ~= $UNIX_SOCKET_DIR/$CLOUD_SQL_CONNECTION_NAME | ||
|
|
||
| usage() { | ||
| cat << EOF | ||
| # Usage: | ||
| # CLOUD_SQL_CONNECTION_NAME=project:region:instance sql-proxy.sh [..] | ||
| # | ||
| # Defaults to TCP socket proxy. Set `SOCKET=unix` for Unix sockets. | ||
| # | ||
| # Usage in package.json: | ||
glasnt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # | ||
| # "proxy": "$GITHUB_WORKSPACE/.github/workflows/utils/sql-proxy.sh", | ||
| # "system-test": "npm run proxy -- c8 mocha test/... ", | ||
| # "system-test-unix": "SOCKET=unix npm run proxy -- c8 mocha test/... ", | ||
| EOF | ||
| } | ||
|
|
||
|
|
||
| PROXY_VERSION="v2.15.1" | ||
| SOCKET=${SOCKET:-tcp} | ||
|
|
||
| echop(){ # Print Echo | ||
| echo "👾 $1" | ||
| } | ||
|
|
||
| exit_message() { # Error Echo | ||
| echo "❌ $1" | ||
| usage | ||
| exit 1 | ||
| } | ||
|
|
||
| if [[ -z "$CLOUD_SQL_CONNECTION_NAME" ]]; then | ||
| exit_message "Must provide CLOUD_SQL_CONNECTION_NAME" | ||
| fi | ||
|
|
||
| if [[ $SOCKET == "unix" ]]; then | ||
| UNIX_SOCKET_DIR=${UNIX_SOCKET_DIR:-"tmp/cloudsql"} | ||
|
|
||
| if [[ $UNIX_SOCKET_DIR == "/cloudsql" ]]; then | ||
| exit_message "Cannot use /cloudsql in a GitHub Actions context" | ||
| fi | ||
|
|
||
| mkdir -p $UNIX_SOCKET_DIR && chmod 777 $UNIX_SOCKET_DIR | ||
| socket="--unix-socket $UNIX_SOCKET_DIR" | ||
| fi | ||
| echop "Setting up cloud-sql-proxy for $SOCKET socket connections" | ||
|
|
||
| # Download the Cloud SQL Auth Proxy (only once) | ||
| if [[ ! -f cloud-sql-proxy ]]; then | ||
| curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/${PROXY_VERSION}/cloud-sql-proxy.linux.amd64 | ||
| if [[ $? -ne 0 ]]; then | ||
| echo "Failed to download cloud-sql-proxy" | ||
| exit 1 | ||
| fi | ||
| chmod +x cloud-sql-proxy | ||
| else | ||
| echo "cloud-sql-proxy already downloaded" | ||
| fi | ||
|
|
||
| # Setup proxy | ||
| ./cloud-sql-proxy $socket $CLOUD_SQL_CONNECTION_NAME & | ||
| sleep 5 | ||
| echop "Proxy ready for use" | ||
|
|
||
| # Run whatever command was passed to this script | ||
| $@ || STATUS=$? | ||
|
|
||
| # Cleanup | ||
| echop "Shutting down proxy process" | ||
| pkill -f "cloud-sql-proxy" || echo "cloud-sql-proxy process not found. Was it already stopped?" | ||
|
|
||
| # Fail if the tests failed | ||
| exit $STATUS | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "env": { | ||
| "INSTANCE_HOST": "127.0.0.1", | ||
| "INSTANCE_CONNECTION_NAME": "nodejs-docs-samples-tests:us-central1:mysql-ci", | ||
| "UNIX_SOCKET_DIR": "tmp/cloudsql", | ||
| "CLOUD_SQL_CONNECTION_NAME": "$INSTANCE_CONNECTION_NAME", | ||
| "INSTANCE_UNIX_SOCKET": "$UNIX_SOCKET_DIR/$INSTANCE_CONNECTION_NAME", | ||
| "DB_NAME": "kokoro_ci", | ||
| "DB_USER": "kokoro_ci" | ||
| }, | ||
| "secrets": { | ||
| "DB_PASS": "nodejs-docs-samples-tests/nodejs-docs-samples-sql-password" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.