Skip to content

Conversation

@glasnt
Copy link
Contributor

@glasnt glasnt commented Mar 25, 2025

Description

migrates cloud-sql/mysql/mysql to Custard CI

Introduces sql-proxy.sh helper in the root(-ish) utils/ folder to assist in setting up either TCP or Unix socket connections through Cloud SQL Auth Proxy

Usage docs on file, including proxy script target (rather than creating a new file in each sample), and the SOCKET=unix to use unix as opposed to a default tcp socket.

Requires using a local folder for the socket connection, as /cloudsql is not accessible in github actions environment.

Should also fail and fail hard if tests fail, rather than silently failing.

Also turns out github actions has colors so let's make mocha do that (optional)

  • Please give this PR a thorough review, as it introduces shared utilities
  • Please merge this PR for me once it is approved

@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: cloudsql Issues related to the Cloud SQL for MySQL API. asset: pattern DEE Asset tagging - Pattern. labels Mar 25, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @glasnt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request is a work-in-progress proof of concept for integrating Cloud SQL with MySQL. It includes changes to the CI configuration to enable testing, updates the package.json to include a proxy setup script, and adds a new script to set up the Cloud SQL proxy for testing.

Highlights

  • CI Configuration: The pull request adds cloud-sql/mysql/mysql to the nodejs-dev.jsonc configuration file, enabling CI tests for this sample. It also removes cloud-sql/mysql/mysql from the nodejs-prod.jsonc configuration file, likely due to previous test failures.
  • Proxy Setup: A new shell script test/proxy-setup.sh is introduced to download and configure the Cloud SQL proxy. This script is executed before the system tests to establish a connection to the Cloud SQL instance.
  • Environment Variables: A ci-setup.json file is added to define environment variables required for the CI environment, including the Cloud SQL connection name, database name, user, and password (obtained from a secret).

Changelog

  • .github/config/nodejs-dev.jsonc
    • Added cloud-sql/mysql/mysql to the list of tested samples.
  • .github/config/nodejs-prod.jsonc
    • Removed cloud-sql/mysql/mysql from the list of tested samples, likely due to test failures.
  • cloud-sql/mysql/mysql/ci-setup.json
    • Added a new file to define environment variables for the CI environment, including database connection details and credentials.
  • cloud-sql/mysql/mysql/package.json
    • Modified the system-test script to execute test/proxy-setup.sh before running the tests.
  • cloud-sql/mysql/mysql/test/proxy-setup.sh
    • Added a new shell script to download, configure, and run the Cloud SQL proxy.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Did you know?

MySQL is named after co-founder Michael 'Monty' Widenius's daughter, My.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a proof of concept for connecting to Cloud SQL using MySQL. It includes necessary configurations and a script to set up the proxy. Overall, the changes seem reasonable, but there are a few points that need attention.

Summary of Findings

  • Hardcoded version in proxy-setup.sh: The version of cloud-sql-proxy is hardcoded in test/proxy-setup.sh. It's better to use a variable for the version to make it easier to update in the future.
  • Missing error handling in proxy-setup.sh: The test/proxy-setup.sh script lacks error handling. It should check if the curl command was successful and exit if it failed.
  • Unnecessary removal of cloud-sql/mysql/mysql from nodejs-prod.jsonc: The removal of cloud-sql/mysql/mysql from nodejs-prod.jsonc seems counterintuitive, especially since the goal is to add support for Cloud SQL MySQL. It's marked as untested with an internal server error, but removing it entirely might not be the best approach.

Merge Readiness

The pull request introduces a proof of concept for Cloud SQL MySQL integration. However, the hardcoded version and lack of error handling in proxy-setup.sh should be addressed before merging. Additionally, the removal of cloud-sql/mysql/mysql from the production config should be reconsidered. I am unable to approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issues should be addressed before merging.

@glasnt glasnt changed the title wip: proof of concept cloud-sql mysql chore(ci): migrate mysql/mysql + proof of concept proxy helper Mar 28, 2025
@glasnt glasnt marked this pull request as ready for review March 28, 2025 04:18
@glasnt glasnt requested review from a team as code owners March 28, 2025 04:18
Copy link
Contributor

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! ✅

Copy link

@davidcavazos davidcavazos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM! Left some minor comments.

@glasnt
Copy link
Contributor Author

glasnt commented Mar 31, 2025

Quickchecked in #4054 that knex will cleanly migrate using this (did have to fix the usage to suit)

@glasnt glasnt merged commit fd6ec65 into main Mar 31, 2025
12 checks passed
@glasnt glasnt deleted the sql-tests-2 branch March 31, 2025 22:54
rudrakhsha-crest pushed a commit to rudrakhsha-crest/nodejs-docs-samples that referenced this pull request Apr 18, 2025
…eCloudPlatform#4040)

* wip: proof of concept cloud-sql mysql

* chmod

* add sleep to ensure proxy starts before use

* use correct envvar

* extra bit

* debugging

* instance_host is deleted by the server-unix test

* proxy all tests

* accepting gemini-code-assist code

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* oop

* wip: tcp or unix

* syntax

* cause she looks like a flower

* more shell logic

* sh

* continued proof of concept

* call shutdown

* format value

* order?

* debug: echo

* hoisted by my own petard.

* tmp file

* -p

* WIP: shared proxy setup

* chmod

* maybe?

* ??

* bash

* debug

* debug

* maybe

* more bash

* simplify usage

* cleanup

* actually use the new setting

* remove old setting

* attempt formatting

* add mocha colour

* at least use something

* code review comments

* syntax

* syntax

* fix usage

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: cloudsql Issues related to the Cloud SQL for MySQL API. asset: pattern DEE Asset tagging - Pattern. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants