github-actions[bot] commented on code in PR #40561: URL: https://github.com/apache/beam/pull/40561#discussion_r4263741941
########## .github/workflows/gemini_code_review.yml: ########## @@ -0,0 +1,211 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +name: Gemini Enterprise Code Review + +on: + pull_request: Review Comment: **🟠 High**: The temporary `pull_request` trigger added for testing should be removed before merging. This trigger could cause the workflow to run unexpectedly on every push to a PR branch that modifies this file, which is likely not the intended behavior for the final workflow. ########## .github/workflows/gemini_code_review.yml: ########## @@ -0,0 +1,211 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +name: Gemini Enterprise Code Review + +on: + pull_request: + paths: + - '.github/workflows/gemini_code_review.yml' + pull_request_target: + types: [opened, reopened, ready_for_review] + workflow_dispatch: + inputs: + pr_number: + description: 'Pull Request number to review' + required: true + type: number + +permissions: read-all + +concurrency: + group: gemini-code-review-${{ github.event.pull_request.number || inputs.pr_number }} + cancel-in-progress: true + +jobs: + gemini-review: + name: Gemini Enterprise PR Review + if: github.repository == 'apache/beam' + runs-on: [self-hosted, ubuntu-24.04, main] + timeout-minutes: 15 Review Comment: **🟠 High**: The `github-script` version should be pinned to a specific commit hash or at least a major version (`@v6`) instead of `@v9`. Using a floating tag like `@v9` can introduce unexpected breaking changes into the workflow. For stability and security, it's best to use a more specific version. ```suggestion uses: actions/github-script@v6 ``` ########## .github/workflows/gemini_code_review.yml: ########## @@ -0,0 +1,211 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +name: Gemini Enterprise Code Review + +on: + pull_request: + paths: + - '.github/workflows/gemini_code_review.yml' + pull_request_target: + types: [opened, reopened, ready_for_review] + workflow_dispatch: + inputs: + pr_number: + description: 'Pull Request number to review' + required: true + type: number + +permissions: read-all + +concurrency: + group: gemini-code-review-${{ github.event.pull_request.number || inputs.pr_number }} + cancel-in-progress: true + +jobs: + gemini-review: + name: Gemini Enterprise PR Review + if: github.repository == 'apache/beam' + runs-on: [self-hosted, ubuntu-24.04, main] + timeout-minutes: 15 + permissions: + contents: read + pull-requests: write + + steps: + - name: Setup Node.js + uses: actions/setup-node@v7 + with: + node-version: '20' + + - name: Run Gemini Enterprise Code Review Agent + id: gemini_review + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GEMINI_CLI_TRUST_WORKSPACE: 'true' + GEMINI_FORCE_FILE_STORAGE: 'true' + GOOGLE_GENAI_USE_VERTEXAI: 'true' + GOOGLE_CLOUD_PROJECT: ${{ secrets.GCP_PROJECT_ID || 'apache-beam-testing' }} + GOOGLE_CLOUD_LOCATION: ${{ secrets.GCP_REGION || 'us-central1' }} + GEMINI_MODEL: ${{ vars.GEMINI_MODEL || 'gemini-2.5-pro' }} + PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }} + REPOSITORY: ${{ github.repository }} + run: | + set -euo pipefail + + PR_URL="https://github.com/${REPOSITORY}/pull/${PR_NUMBER}" + + mkdir -p .gemini + cat << 'EOF' > .gemini/settings.json + { + "model": { + "maxSessionTurns": 10 + }, + "experimental": { + "directWebFetch": true + }, + "tools": { + "core": [ + "web_fetch", + "run_shell_command(gh pr view)", + "run_shell_command(gh pr diff)" + ] + } + } + EOF + + cat << EOF > prompt.txt + You are an autonomous Apache Beam code review agent running on the Gemini Enterprise Agent Platform. + Review Pull Request: ${PR_URL} + + Respond with ONLY a single valid JSON object matching this exact schema (no markdown prose outside the JSON): + { + "summary": "## 📋 Review Summary\n\n2-3 sentence high-level assessment.\n\n## 🔍 General Feedback\n- Key architectural or cross-file observations.", + "comments": [ + { + "path": "relative/path/to/file.ext", + "line": 123, + "side": "RIGHT", + "severity": "🟠 High", + "body": "Clear explanation of why this is an issue and how to fix it.", + "suggestion": "optional exact replacement line(s) without backticks, or null" + } + ] + } + EOF + + npx --yes @google/gemini-cli@latest \ + --debug \ + --yolo \ + --model "${GEMINI_MODEL}" \ + --prompt "$(cat prompt.txt)" \ Review Comment: **🟠 High**: Adding `--debug` to the `gemini-cli` command is great for development and testing, but it should be removed before merging into the main branch. Debug logs can be very verbose and may contain sensitive information. It's best to run the CLI in its standard, less verbose mode in production. ```suggestion npx --yes @google/gemini-cli@latest \ ``` ########## .github/workflows/gemini_code_review.yml: ########## @@ -0,0 +1,211 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +name: Gemini Enterprise Code Review + +on: + pull_request: + paths: + - '.github/workflows/gemini_code_review.yml' + pull_request_target: + types: [opened, reopened, ready_for_review] + workflow_dispatch: + inputs: + pr_number: + description: 'Pull Request number to review' + required: true + type: number + +permissions: read-all + +concurrency: + group: gemini-code-review-${{ github.event.pull_request.number || inputs.pr_number }} + cancel-in-progress: true + +jobs: + gemini-review: + name: Gemini Enterprise PR Review + if: github.repository == 'apache/beam' + runs-on: [self-hosted, ubuntu-24.04, main] + timeout-minutes: 15 + permissions: + contents: read + pull-requests: write + + steps: + - name: Setup Node.js + uses: actions/setup-node@v7 + with: + node-version: '20' + + - name: Run Gemini Enterprise Code Review Agent + id: gemini_review + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GEMINI_CLI_TRUST_WORKSPACE: 'true' + GEMINI_FORCE_FILE_STORAGE: 'true' + GOOGLE_GENAI_USE_VERTEXAI: 'true' + GOOGLE_CLOUD_PROJECT: ${{ secrets.GCP_PROJECT_ID || 'apache-beam-testing' }} + GOOGLE_CLOUD_LOCATION: ${{ secrets.GCP_REGION || 'us-central1' }} + GEMINI_MODEL: ${{ vars.GEMINI_MODEL || 'gemini-2.5-pro' }} + PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }} + REPOSITORY: ${{ github.repository }} + run: | + set -euo pipefail + + PR_URL="https://github.com/${REPOSITORY}/pull/${PR_NUMBER}" + + mkdir -p .gemini + cat << 'EOF' > .gemini/settings.json + { + "model": { + "maxSessionTurns": 10 + }, + "experimental": { + "directWebFetch": true + }, + "tools": { + "core": [ + "web_fetch", + "run_shell_command(gh pr view)", + "run_shell_command(gh pr diff)" + ] + } Review Comment: **🟠 High**: Enabling `directWebFetch` is a good optimization, but it's important to be aware of the security implications. When this feature is enabled, the Gemini agent can fetch content from any URL. This could be a security risk if the agent is tricked into fetching malicious content. Given the context of a code review workflow, this is probably fine, but it's worth noting. The list of allowed tools is also quite permissive. It might be better to restrict the tools to only those that are absolutely necessary for the code review task. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
