Skip to content
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

feat: custard integration #5205

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft

feat: custard integration #5205

wants to merge 17 commits into from

Conversation

davidcavazos
Copy link
Contributor

Description

🍮 Initial custard CI integration.

Checklist

  • I have followed Contributing Guidelines from CONTRIBUTING.MD
  • Tests pass: go test -v ./.. (see Testing)
  • Code formatted: gofmt (see Formatting)
  • Vetting pass: go vet (see Formatting)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Mar 4, 2025
Copy link

@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 @davidcavazos, 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 introduces the initial integration of Custard CI for the repository. It includes configuration files, scripts, and workflow definitions to enable automated testing and CI setup based on affected packages. The changes aim to streamline the testing process by identifying and testing only the relevant parts of the codebase that are affected by a particular change.

Highlights

  • Configuration: Adds a new configuration file (.github/config/golang-dev.jsonc) to define CI setup defaults, ignored files, and excluded packages.
  • Custard Setup Action: Introduces a new composite action (.github/custard-setup/action.yaml) to set up the testing environment, authenticate with Google Cloud, and export environment variables.
  • Scripts: Adds new scripts (.github/scripts/cmd/vars.js, .github/scripts/setup-vars.js, .github/scripts/setup-vars.test.js, .github/scripts/package.json) for setting up environment variables and running tests.
  • Workflows: Defines new workflows (.github/workflows/custard-affected.yaml, .github/workflows/custard-ci-dev.yaml) for finding affected tests and running CI jobs.

Changelog

Click here to see the changelog
  • .github/config/golang-dev.jsonc
    • Added a new configuration file to define CI setup defaults, ignored files, and excluded packages.
    • Specifies package files, CI setup filename, default environment variables, secrets, Go versions, timeout minutes, and files/directories to ignore during testing.
  • .github/custard-setup/action.yaml
    • Introduced a new composite action to set up the testing environment.
    • Takes inputs such as package path, affected packages, Google Cloud project ID, workload identity provider, and service account.
    • Authenticates with Google Cloud using workload identity federation.
    • Exports environment variables using a script.
    • Retrieves secrets from Google Cloud Secret Manager.
  • .github/scripts/cmd/vars.js
    • Added a new script to set up environment variables.
    • Reads the project ID from the environment variables.
    • Reads the setup file from the command line arguments.
    • Parses the setup file as JSON.
    • Calls the setupVars function to set up the environment variables.
  • .github/scripts/package.json
    • Added a new package.json file for the scripts.
    • Defines the name, version, type, license, and scripts for the package.
    • Includes dependencies such as mocha for testing.
  • .github/scripts/setup-vars.js
    • Added a new script to set up environment variables.
    • Defines automatic variables such as PROJECT_ID, RUN_ID, and SERVICE_ACCOUNT.
    • Applies variable interpolation to the environment variables.
    • Exports the environment variables.
    • Exports secrets from Google Cloud Secret Manager.
    • Sets a global secret for the Service Account identity token.
  • .github/scripts/setup-vars.test.js
    • Added a new test file for the setup-vars.js script.
    • Includes tests for the env, secrets, substituteVars, and uniqueId functions.
  • .github/workflows/custard-affected.yaml
    • Added a new workflow to find affected tests.
    • Takes inputs such as Go version and timeout minutes.
    • Checks out the code and cloud-samples-tools repository.
    • Sets up Go.
    • Builds Custard from cloud-samples-tools.
    • Gets the diffs using git.
    • Finds affected packages using Custard.
  • .github/workflows/custard-ci-dev.yaml
    • Added a new workflow for Custard CI (dev).
    • Triggers on push to main branch and pull requests.
    • Uses the custard-affected.yaml workflow to find affected tests.
    • Runs tests for the affected packages using a matrix strategy.
    • Sets up Go.
    • Runs the tests using make.
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.


Trivia time!

What is the purpose of the 'go.mod' file in a Go project?

Click here for the answer
The 'go.mod' file defines the module's module path and its dependency requirements. It is used for dependency management in Go projects.

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

@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 initial Custard CI integration, which is a great step towards automating and improving the testing process. The changes include configuration files, a composite action, and workflow definitions. Overall, the structure looks good, but there are a few areas that need attention before merging.

Summary of Findings

  • TODO in .github/config/golang-dev.jsonc: The TODO comment in .github/config/golang-dev.jsonc should be addressed. Determine if the .github/config/ directory should still be ignored or if it's time to include it in the checks.
  • Missing workload_identity_provider value: The workload_identity_provider input in .github/workflows/custard-ci-dev.yaml is currently set to TODO. This needs to be replaced with the actual workload identity provider value for the CI setup to function correctly.

Merge Readiness

The pull request is not quite ready for merging. The TODO in .github/config/golang-dev.jsonc and the missing workload_identity_provider value in .github/workflows/custard-ci-dev.yaml need to be addressed. I am unable to approve this pull request, and recommend that these issues be resolved and the code be reviewed again before merging.

Comment on lines +47 to +48
workload_identity_provider: TODO
service_account: kokoro-golang-samples-tests@golang-samples-tests.iam.gserviceaccount.com

Choose a reason for hiding this comment

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

high

The workload_identity_provider is currently a TODO. This needs to be replaced with the actual workload identity provider value.

@davidcavazos davidcavazos changed the title test: custard integration feat: custard integration Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant