Repository navigation
Add read-only permissions and self-repo actions in python_tests.yml - #41526
Conversation
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR appears to be a test PR that introduces several breaking changes to .github/workflows/python_tests.yml without a description or linked issue. As currently written, the changes will cause the Python Tests workflow to fail immediately and disable pull_request triggers across nearly all branches.
🔍 General Feedback
- The
pull_requesttrigger is restricted to a non-standardmaster2branch, which disables pre-commit testing onmaster. - The checkout action is downgraded from
actions/checkout@v6toactions/checkout@v1(which uses the deprecated and removed Node 12 runtime on GitHub-hosted runners). - Both the
runs-onrunner label (ubuntu-latest-invalid) and the local composite action path ($/.github/actions/setup-environment-action) are invalid and will prevent the job from executing.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
💬 Inline Findings
-
.github/workflows/python_tests.yml(line 36): 🔴 Critical: Restrictingpull_requesttriggers tomaster2prevents this workflow from running on pull requests targetingmasteror release branches. Unless this is strictly for temporary testing, thebranchesfilter should be removed. -
.github/workflows/python_tests.yml(line 44): 🔴 Critical:ubuntu-latest-invalidis not a valid GitHub-hosted or self-hosted runner label in this repository, which will cause jobs to remain queued indefinitely and fail to acquire a runner.
runs-on: [ubuntu-latest]
.github/workflows/python_tests.yml(line 53): 🟠 High: Downgradingactions/checkoutfromv6tov1will break workflow execution on modern GitHub-hosted runners becausev1relies on the deprecated Node 12 runtime and lacks critical security and git fetch updates.
uses: actions/checkout@v6
.github/workflows/python_tests.yml(line 55): 🔴 Critical: Local composite action paths in GitHub Actionsuses:must start with./. Using$/is invalid syntax and causes workflow validation to fail (PreCommit GHA).
uses: ./.github/actions/setup-environment-action
|
Note: The initial automated review above ran immediately at PR creation before the PR diff endpoint populated (referencing nonexistent /gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR hardens .github/workflows/python_tests.yml by setting explicit top-level contents: read permissions and updating local composite action references to use the self-repository syntax ($/...). The changes are clean, minimal, and properly address the CodeQL and zizmor findings without altering workflow behavior.
🔍 General Feedback
- All four jobs (
check_gcp_variables,build_python_sdk_source,python_unit_tests, andpython_wordcount_direct_runner) only perform checkouts, local builds/tests, and artifact uploads, so restrictingGITHUB_TOKENtocontents: readat the workflow level is safe and appropriate. - Switching
setup-environment-actionreferences from./.github/actions/...to$/...aligns with GitHub Actions self-repository syntax andzizmorsecurity best practices.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @Abacn for label build. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
Verified via sample |
Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria:
CodeQL/zizmor) onmasterwithout altering intended public API or workflow semanticsIf you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :)
Summary
CodeQL+zizmor) in.github/workflows/python_tests.yml:actions/missing-workflow-permissions(#30,#31,#32,#35) &zizmor/excessive-permissions(#1612,#1613,#1614,#1615,#1616): adds explicit top-levelpermissions: contents: readacross all four read-only test jobs.zizmor/self-repository(#3139,#3140,#3141): updates local composite action references from./.github/actions/setup-environment-actionto$/.github/actions/setup-environment-action.Verification
./gradlew :beam-test-gha:preCommitworkflow_dispatchrun on branchcodescan/gha-python-tests-permissions: https://github.com/apache/beam/actions/runs/45211013785 (succeeded across Linux, macOS, and Windows for Python 3.11–3.14)