-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[update_lib] show deps #6821
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
[update_lib] show deps #6821
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| name: Lib Dependencies Check | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, synchronize, reopened] | ||
| paths: | ||
| - 'Lib/**' | ||
|
|
||
| concurrency: | ||
| group: lib-deps-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| check_deps: | ||
| permissions: | ||
| pull-requests: write | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - name: Checkout base branch | ||
| uses: actions/[email protected] | ||
| with: | ||
| # Use base branch for scripts (security: don't run PR code with elevated permissions) | ||
| ref: ${{ github.event.pull_request.base.ref }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Fetch PR head | ||
| run: | | ||
| git fetch origin ${{ github.event.pull_request.head.sha }} | ||
|
|
||
| - name: Checkout CPython | ||
| run: | | ||
| git clone --depth 1 --branch v3.14.2 https://github.com/python/cpython.git cpython | ||
|
|
||
| - name: Get changed Lib files | ||
| id: changed-files | ||
| run: | | ||
| # Get the list of changed files under Lib/ | ||
| changed=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- 'Lib/*.py' 'Lib/**/*.py' | head -50) | ||
| echo "Changed files:" | ||
| echo "$changed" | ||
|
|
||
| # Extract unique module names (top-level only, skip test/) | ||
| modules="" | ||
| for file in $changed; do | ||
| # Skip test files | ||
| if [[ "$file" == Lib/test/* ]]; then | ||
| continue | ||
| fi | ||
| # Extract module name: Lib/foo.py -> foo, Lib/foo/__init__.py -> foo | ||
| module=$(echo "$file" | sed -E 's|^Lib/||; s|/__init__\.py$||; s|\.py$||; s|/.*||') | ||
| if [[ -n "$module" && ! " $modules " =~ " $module " ]]; then | ||
| modules="$modules $module" | ||
| fi | ||
| done | ||
|
|
||
| modules=$(echo "$modules" | xargs) # trim whitespace | ||
| echo "Detected modules: $modules" | ||
| echo "modules=$modules" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Setup Python | ||
| if: steps.changed-files.outputs.modules != '' | ||
| uses: actions/[email protected] | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Run deps check | ||
| if: steps.changed-files.outputs.modules != '' | ||
| id: deps-check | ||
| run: | | ||
| # Run deps for all modules at once | ||
| python scripts/update_lib deps ${{ steps.changed-files.outputs.modules }} --depth 2 > /tmp/deps_output.txt 2>&1 || true | ||
|
|
||
| # Read output for GitHub Actions | ||
| echo "deps_output<<EOF" >> $GITHUB_OUTPUT | ||
| cat /tmp/deps_output.txt >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
|
|
||
| # Check if there's any meaningful output | ||
| if [ -s /tmp/deps_output.txt ]; then | ||
| echo "has_output=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "has_output=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
|
Comment on lines
+67
to
+85
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard against command injection from PR-controlled module names. Line 72 expands untrusted module names directly into a shell command in a 🔒 Proposed fix (no shell eval of module names)- python scripts/update_lib deps ${{ steps.changed-files.outputs.modules }} --depth 2 > /tmp/deps_output.txt 2>&1 || true
+ printf '%s\n' ${{ steps.changed-files.outputs.modules }} | \
+ xargs -r python scripts/update_lib deps --depth 2 -- > /tmp/deps_output.txt 2>&1 || true🤖 Prompt for AI Agents |
||
| - name: Post comment | ||
| if: steps.deps-check.outputs.has_output == 'true' | ||
| uses: marocchino/sticky-pull-request-comment@v2 | ||
| with: | ||
| header: lib-deps-check | ||
| number: ${{ github.event.pull_request.number }} | ||
| message: | | ||
| ## 📦 Library Dependencies | ||
|
|
||
| The following Lib/ modules were modified. Here are their dependencies: | ||
|
|
||
| <details> | ||
| <summary>Click to expand dependency information</summary> | ||
|
|
||
| ``` | ||
| ${{ steps.deps-check.outputs.deps_output }} | ||
| ``` | ||
|
|
||
| </details> | ||
|
|
||
| **Legend:** | ||
| - `[+]` path exists, `[-]` path missing | ||
| - `[x]` up-to-date, `[ ]` outdated | ||
| - `native:` Rust/C extension modules | ||
|
|
||
| - name: Remove comment if no Lib changes | ||
| if: steps.changed-files.outputs.modules == '' | ||
| uses: marocchino/sticky-pull-request-comment@v2 | ||
| with: | ||
| header: lib-deps-check | ||
| number: ${{ github.event.pull_request.number }} | ||
| delete: true | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix duplicate-module detection (substring match can skip modules).
Line 52 uses a regex substring check against a concatenated string, which can treat
osas already present whenposixis in the list. This can silently drop modules from the deps run.🔧 Proposed fix (exact-match dedup)
📝 Committable suggestion
🤖 Prompt for AI Agents