Skip to content

feat(pr-generator-infra): configure Cloud Run job, Workflows definition, and Dockerfile#28431

Open
joneba-google wants to merge 2 commits into
google-gemini:mainfrom
JonE01:pr-generator-infra
Open

feat(pr-generator-infra): configure Cloud Run job, Workflows definition, and Dockerfile#28431
joneba-google wants to merge 2 commits into
google-gemini:mainfrom
JonE01:pr-generator-infra

Conversation

@joneba-google

@joneba-google joneba-google commented Jul 17, 2026

Copy link
Copy Markdown

Overview

This PR introduces the foundational cloud infrastructure and container configurations for the Gemini CLI SSR Code Generation Pipeline. It establishes the containerized runtime environment, declarative Cloud Run Job specifications, and the Eventarc-triggered Cloud Workflow that coordinates Pub/Sub ingestion and failure recovery.
──────

Summary of Changes

1. Container Specification (Dockerfile)

• Configures a python:3.11-slim base image with Node.js 20 runtime support, Git, bubblewrap sandbox utilities, and root CA certificates.
• Installs core Python dependencies (google-antigravity, pydantic, google-cloud-firestore, google-genai, google-cloud-aiplatform).
• Packages the pipeline orchestrator and system prompt instructions under /app/workflow and sets the container entrypoint.

2. Declarative Cloud Run Job (job.yaml)

• Defines the pr-gen-job resource configuration in region us-central1.
• Allocates 2 vCPUs and 8Gi RAM with a 3600-second execution timeout.
• Binds dedicated runtime service account code-gen-job-execution-sa@gcli-intern-project-2026.iam.gserviceaccount.com.
• Injects environment variables for Firestore (FIRESTORE_DATABASE=test-gcli-db-clone, FIRESTORE_COLLECTION=test_issues) and maps the GEMINI_API_KEY from Secret Manager.

3. Cloud Workflow Orchestration (workflow.yaml)

• Event Ingestion: Decodes incoming Pub/Sub issue payloads and determines explicit or derived Firestore document IDs (github_{owner}{repo}{issue_number}).
• Secret Access: Fetches GitHub authentication keys (PR_GEN_GITHUB_PUSH_KEY) dynamically from Secret Manager.
• Execution Tracking: Injects the active ${sys.get_env("GOOGLE_CLOUD_WORKFLOW_EXECUTION_ID")} into the Cloud Run container environment overrides (EXECUTION_ID).
• Resilient Failure Handling: Catches container-level crashes or timeouts via a try/except block and performs a transactional patch on the Firestore document to set status: "NEEDS_HUMAN", log failure
details, and release concurrency locks.

@joneba-google
joneba-google requested a review from a team as a code owner July 17, 2026 18:21
@github-actions github-actions Bot added the size/m A medium sized PR label Jul 17, 2026
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 190
  • Additions: +190
  • Deletions: -0
  • Files changed: 3

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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!

This pull request establishes the core infrastructure for the Gemini CLI Issue-to-PR Code Generation Pipeline. It provides the necessary container environment, job specifications, and workflow orchestration logic to automate the processing of GitHub issues, ensuring robust execution and failure recovery via Firestore integration.

Highlights

  • Container Environment: Introduced a Dockerfile based on python:3.11-slim, including Node.js 20, Git, and necessary sandbox utilities to support the pipeline runtime.
  • Cloud Run Job Configuration: Defined a declarative Cloud Run Job (pr-gen-job) with specific resource allocations, service account bindings, and secret management for the Gemini API key.
  • Workflow Orchestration: Implemented a Google Cloud Workflow to handle Pub/Sub event ingestion, dynamic secret retrieval, and resilient error handling with automated Firestore status updates.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the 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 may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

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.

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

Copy link
Copy Markdown
Contributor

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 Dockerfile, a Cloud Run Job configuration, and a Google Cloud Workflow to orchestrate code generation and evaluation. The review feedback highlights several critical issues in the workflow configuration: the repository URL and GCP project ID are hardcoded instead of being dynamically resolved, there is a mismatch in the Firestore database and collection names between the workflow and the job configuration, and there are high-severity path traversal vulnerabilities due to a lack of validation on the Firestore document ID and GitHub metadata fields before constructing database paths.

Comment on lines +13 to +19
- repo_url: "https://github.com/joneba-google/gemini-cli-clone"
- workflow_execution_id: '${sys.get_env("GOOGLE_CLOUD_WORKFLOW_EXECUTION_ID")}'

# Decode Pub/Sub message
- pubsub_message_bytes: '${base64.decode(event.data.message.data)}'
- firestore_doc_str: '${text.decode(pubsub_message_bytes)}'
- firestore_doc: '${json.decode(firestore_doc_str)}'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The repository URL is currently hardcoded to a specific personal clone (https://github.com/joneba-google/gemini-cli-clone). This will cause the PR generator to always run against this repository, completely ignoring the actual repository owner and name from the incoming Pub/Sub event.

To make the pipeline dynamic and support any repository triggering the event, construct the repo_url dynamically using the decoded firestore_doc.github_metadata fields.

          - workflow_execution_id: '${sys.get_env("GOOGLE_CLOUD_WORKFLOW_EXECUTION_ID")}'
          
          # Decode Pub/Sub message
          - pubsub_message_bytes: '${base64.decode(event.data.message.data)}'
          - firestore_doc_str: '${text.decode(pubsub_message_bytes)}'
          - firestore_doc: '${json.decode(firestore_doc_str)}'
          - repo_url: '${"https://github.com/" + firestore_doc.github_metadata.owner + "/" + firestore_doc.github_metadata.repo}'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's currently hard coded for testing. I plan to make this change when transitioning it to the gemini-cli repo.

Comment thread tools/caretaker-agent/cloudrun/pr-generator/workflow.yaml Outdated
Comment thread tools/caretaker-agent/cloudrun/pr-generator/workflow.yaml Outdated
Comment thread tools/caretaker-agent/cloudrun/pr-generator/workflow.yaml Outdated
Comment thread tools/caretaker-agent/cloudrun/pr-generator/workflow.yaml Outdated
@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Jul 17, 2026
@joneba-google joneba-google changed the title infra: configure Cloud Run job, Workflows definition, and Dockerfile feat(pr-generator-infra): configure Cloud Run job, Workflows definition, and Dockerfile Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m A medium sized PR status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant