Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ concurrency:
jobs:
mypy:
runs-on: ubuntu-latest
# Skip this job entirely if the actor is codegen-sh[bot]
if: github.actor != 'codegen-sh[bot]'
Comment on lines +15 to +16
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Extract bot actor into environment variable for maintainability

Hardcoding codegen-sh[bot] in multiple workflows increases maintenance overhead and risks typos if the bot name ever changes. Consider defining a reusable environment variable (e.g., TRUSTED_BOT) at the job or workflow level and referencing it in the if condition, for example:

 jobs:
   mypy:
     runs-on: ubuntu-latest
+    env:
+      TRUSTED_BOT: codegen-sh[bot]
     # Skip this job entirely if the actor is codegen-sh[bot]
-    if: github.actor != 'codegen-sh[bot]'
+    if: github.actor != env.TRUSTED_BOT
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Skip this job entirely if the actor is codegen-sh[bot]
if: github.actor != 'codegen-sh[bot]'
jobs:
mypy:
runs-on: ubuntu-latest
env:
TRUSTED_BOT: codegen-sh[bot]
# Skip this job entirely if the actor is codegen-sh[bot]
if: github.actor != env.TRUSTED_BOT
🤖 Prompt for AI Agents (early access)
In .github/workflows/mypy.yml around lines 15 to 16, the bot actor 'codegen-sh[bot]' is hardcoded in the if condition. To improve maintainability and reduce risk of typos, define an environment variable like TRUSTED_BOT at the job or workflow level with the bot name, then update the if condition to compare github.actor against this variable instead of the hardcoded string.

timeout-minutes: 20

steps:
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
jobs:
access-check:
runs-on: ubuntu-latest
# Skip this job entirely if the actor is codegen-sh[bot]
Copy link
Author

Choose a reason for hiding this comment

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

I agree with codecov-ai's suggestion to use environment variables for the bot name in the workflow files. This would make the configuration more maintainable and reduce the risk of errors if the bot name changes. Consider implementing this approach across all workflow files.

if: github.actor != 'codegen-sh[bot]'
steps:
- uses: actions-cool/check-user-permission@v2
with:
Expand All @@ -21,7 +23,8 @@ jobs:
error-if-missing: true

unit-tests:
needs: access-check
# Run this job without depending on access-check if actor is codegen-sh[bot]
needs: ${{ github.actor != 'codegen-sh[bot]' && 'access-check' || '' }}
runs-on: ubuntu-latest-8
steps:
- uses: actions/checkout@v4
Expand All @@ -48,7 +51,8 @@ jobs:
codecov_token: ${{ secrets.CODECOV_TOKEN }}

codemod-tests:
needs: access-check
# Run this job without depending on access-check if actor is codegen-sh[bot]
needs: ${{ github.actor != 'codegen-sh[bot]' && 'access-check' || '' }}
# TODO: re-enable when this check is a develop required check
if: false
runs-on: ubuntu-latest-32
Expand Down Expand Up @@ -90,7 +94,8 @@ jobs:
GITHUB_WORKSPACE: $GITHUB_WORKSPACE

parse-tests:
needs: access-check
# Run this job without depending on access-check if actor is codegen-sh[bot]
needs: ${{ github.actor != 'codegen-sh[bot]' && 'access-check' || '' }}
if: contains(github.event.pull_request.labels.*.name, 'parse-tests') || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest-32
steps:
Expand Down Expand Up @@ -161,7 +166,8 @@ jobs:
}

integration-tests:
needs: access-check
# Run this job without depending on access-check if actor is codegen-sh[bot]
needs: ${{ github.actor != 'codegen-sh[bot]' && 'access-check' || '' }}
runs-on: ubuntu-latest-16
steps:
- uses: actions/checkout@v4
Expand Down
Loading
Loading