◐ Shell
reader mode source ↗
Skip to content

Update CI auto-formate#6237

Merged
youknowone merged 4 commits into
RustPython:mainfrom
YashSuthar983:chore/ci-autoformat
Nov 10, 2025
Merged

Update CI auto-formate#6237
youknowone merged 4 commits into
RustPython:mainfrom
YashSuthar983:chore/ci-autoformat

Conversation

@YashSuthar983

@YashSuthar983 YashSuthar983 commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

After running all all test i have added a another which check the rust format and if its not correct it make a commit with
[skip ci] which tell github workflow to ignore this commit.

@youknowone now this should work. i tested again on my fork with different account for testing.
issue :#6204

Summary by CodeRabbit

  • Chores
    • Simplified linting: formatter removed so only the code-quality linter runs.
    • Added an automated formatting workflow that runs the formatter, commits formatting changes with [skip ci], and pushes updates back to the PR branch when needed.
    • Formatting job waits for CI to pass, respects [skip ci] on the head commit, and posts a PR comment when it applies changes.

Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

CI workflows updated: rustfmt removed from the lint job; a new PR-targeted auto-format workflow runs cargo fmt --all, commits/pushes formatting changes with [skip ci], and can post a PR comment. The auto-format run waits for checks and is gated to avoid CI loops.

Changes

Cohort / File(s) Summary
CI workflows (lint change + new auto-format)
/.github/workflows/ci.yaml, /.github/workflows/pr-auto-commit.yaml
Removed explicit rustfmt provisioning and the rustfmt execution step from the lint job (clippy remains). Added a new "PR Auto-format" workflow / auto_format_commit job that waits for checks, runs cargo fmt --all, detects diffs, commits with [skip ci], pushes to the PR branch, and optionally posts a PR comment. Includes concurrency controls, permission scoping, guarded execution for [skip ci], and configurable wait/retry settings.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant PR as Pull Request
  participant GH as GitHub Actions
  participant Core as Core Jobs (tests, clippy)
  participant AF as Auto-format Job
  participant Git as Git (commit/push)
  participant Comment as PR Commenter

  PR->>GH: open/update (pull_request_target)
  GH->>Core: run tests & clippy (rustfmt removed)
  Core-->>GH: status results
  GH->>AF: start auto-format (if head commit != "[skip ci]" and required checks passed)
  AF->>AF: setup toolchain (rustfmt), run `cargo fmt --all`
  alt formatting changes detected
    AF->>Git: commit with "[skip ci]" and push to PR branch
    Git-->>AF: push success
    AF->>Comment: post PR comment with auto-format details
  else no changes
    AF-->>GH: exit (already formatted)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect needs/concurrency groups for cycles and intended ordering.
  • Validate [skip ci] detection and edge cases (rebase/force-push).
  • Verify permissions and token/checkout usage for safe push and comment posting.

Possibly related PRs

Suggested reviewers

  • youknowone

Poem

🐇 I hopped through CI with nimble feet,
I ran cargo fmt to make things neat,
Committed with "[skip ci]" to avoid a loop,
Pushed tidy lines and left a helpful scoop,
A rabbit's touch — crisp, concise, and sweet.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Update CI auto-formate' is vague and contains a typo ('auto-formate' instead of 'auto-format'), making it unclear about the specific changes involved. Revise the title to be more specific and correct the typo, such as 'Add auto-formatting CI workflow with cargo fmt' or 'Implement auto-format CI job for pull requests'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@YashSuthar983

Copy link
Copy Markdown
Contributor Author

I don't know why this failing but I tested on my fork with the help of different account too and its working.

Co-authored-by: fanninpm <luxverdans@sbcglobal.net>

@coderabbitai coderabbitai 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.

Hide comment

Actionable comments posted: 1

🧹 Nitpick comments (2)
.github/workflows/ci.yaml (2)

452-462: Job dependency chain creates significant delay before formatting feedback.

The job depends on 7 prior jobs, which means formatting comments won't appear until all of those jobs finish. Consider whether this is intentional (to avoid conflicts) or whether an earlier checkpoint would be preferable.


481-493: Use git add -A to capture all changes (including untracked files).

Line 487 uses git add -u, which only stages modifications to already-tracked files. While cargo fmt typically doesn't create new files, using git add -A or git add . is more defensive:

-          git add -u
+          git add -A

Additionally, consider checking the git push exit code to ensure the push succeeded before setting formatted=true.

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4a5730 and b6139b5.

📒 Files selected for processing (1)
  • .github/workflows/ci.yaml (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: ShaharNaveh
Repo: RustPython/RustPython PR: 5932
File: .github/workflows/comment-commands.yml:18-24
Timestamp: 2025-07-10T10:08:43.330Z
Learning: In GitHub Actions workflows for the RustPython project, the maintainer ShaharNaveh prefers to keep workflows simple and doesn't mind if steps fail when the desired state is already achieved (e.g., user already assigned to an issue). Avoid suggesting complex error handling for edge cases they don't consider problematic.
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to **/*.rs : Format Rust code with the default rustfmt style (run `cargo fmt`)
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to **/*.rs : Run clippy and fix any warnings or lints introduced by your changes
📚 Learning: 2025-09-11T05:06:59.971Z
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to **/*.rs : Run clippy and fix any warnings or lints introduced by your changes

Applied to files:

  • .github/workflows/ci.yaml
📚 Learning: 2025-09-11T05:06:59.971Z
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to **/*.rs : Format Rust code with the default rustfmt style (run `cargo fmt`)

Applied to files:

  • .github/workflows/ci.yaml
📚 Learning: 2025-09-11T05:06:59.971Z
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to extra_tests/**/*.py : Use ruff to lint custom Python code

Applied to files:

  • .github/workflows/ci.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Check Rust code with clippy
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run tests under miri
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Check the WASM package and demo
🔇 Additional comments (4)
.github/workflows/ci.yaml (4)

309-316: Lint job updates look good.

Removing rustfmt from the lint step and dedicating it to the new auto_format_commit job is a clean separation of concerns.


465-475: Checkout and Rust setup are correct.

Line 469 correctly uses ${{ github.event.pull_request.head.ref || github.ref_name }} to handle both PR and push events—good alignment with the past suggestion from fanninpm.


476-480: Cargo fmt command is standard and correct.


495-501: PR comment logic is sound.

The conditional on line 496 correctly gates the comment to PR events, and the message is clear.

@fanninpm

fanninpm commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

@coderabbitai Why does CI fail?

@coderabbitai

coderabbitai Bot commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get the CI runs for this PR and their status
gh pr view 6237 --repo RustPython/RustPython --json statusCheckRollup | jq '.statusCheckRollup[] | {name: .name, status: .status, conclusion: .conclusion}'

# Get more detailed information about failed checks
gh pr checks 6237 --repo RustPython/RustPython

# Also get the workflow file to examine it
cat .github/workflows/ci.yaml | head -200

Length of output: 8609


🏁 Script executed:

#!/bin/bash
# Get the logs from the failed Auto-format code job
gh run view 19111165461 --repo RustPython/RustPython --job 54610715495 --log

# Also let's look at the auto_format_commit job definition in the workflow file
cat .github/workflows/ci.yaml | grep -A 100 "auto_format_commit:"

Length of output: 23955


@fanninpm The CI is failing because of how the auto_format_commit job handles pull requests from forks. Here's the issue:

Root Cause

The error in the logs shows:

##[error]A branch or tag with the name 'chore/ci-autoformat' could not be found

This happens because:

  1. Branch location: The PR is from a fork (YashSuthar983/RustPython), so the branch chore/ci-autoformat exists in the fork repository, not in the main RustPython/RustPython repository.

  2. Checkout configuration: The workflow uses:

    ref: ${{ github.event.pull_request.head.ref || github.ref_name }}

    This evaluates to just the branch name chore/ci-autoformat, and the checkout action tries to find it in the main repository where it doesn't exist.

  3. Git fetch behavior: The fetch only retrieves branches from origin (the main repo), not from the fork:

    git fetch origin +refs/heads/*:refs/remotes/origin/*
    

Why It Worked on the Fork

When @YashSuthar983 tested this on their own fork, it worked because:

  • The branch exists in their repository
  • They have write permissions to their own repository
  • The checkout action can find and check out the branch

Additional Problem: Write Permissions

Even if the checkout issue were fixed, there's a security restriction: GitHub Actions from forked PRs don't have write permissions to the base repository by default. The workflow tries to push formatting changes back to the PR branch, which would fail for forked PRs.

Solutions

For this auto-format workflow to work properly with forked PRs, you have a few options:

  1. Use the default checkout (recommended for this use case):

    - name: Checkout code
      uses: actions/checkout@v5
      with:
        fetch-depth: 0
        # Remove the ref parameter - let GitHub Actions handle it automatically
  2. Skip auto-format for forked PRs: Add a condition to only run on PRs from the main repository:

    if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && github.event.pull_request.head.repo.full_name == github.repository }}
  3. Use pull_request_target (requires careful security consideration): This event type has write permissions but runs in the context of the base repository, which has security implications.

The simplest fix would be option #2 - only auto-format for PRs from branches in the main repository, not from forks.


🧠 Learnings used
Learnt from: ShaharNaveh
Repo: RustPython/RustPython PR: 5932
File: .github/workflows/comment-commands.yml:18-24
Timestamp: 2025-07-10T10:08:43.330Z
Learning: In GitHub Actions workflows for the RustPython project, the maintainer ShaharNaveh prefers to keep workflows simple and doesn't mind if steps fail when the desired state is already achieved (e.g., user already assigned to an issue). Avoid suggesting complex error handling for edge cases they don't consider problematic.

@YashSuthar983

Copy link
Copy Markdown
Contributor Author

@fanninpm i am still confused as when i tested with my different account where i fork my fork then make a pr ,there it works .
maybe we can confirm this after merging this (this is not proffered but i am confused due to dual behaviour)

Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>

@coderabbitai coderabbitai 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.

Hide comment

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/ci.yaml (1)

459-459: CRITICAL: Condition fails on pull_request events.

Line 459 accesses github.event.head_commit.message, which is only available on push events. The workflow triggers on both push and pull_request (lines 2–5), so this condition is broken for PR events. For PRs, github.event.head_commit is null, causing contains(null, '[skip ci]') to behave unpredictably—the job will likely run unconditionally.

This matches the root cause identified in the previous review: the workflow works on your fork (where you have permissions) but fails here because the condition doesn't distinguish event types. Per previous review recommendations, the simplest fix is to skip auto-format for fork PRs by checking the event type:

-    if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
+    if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }}

This skips the job for fork PRs (where you don't have write permissions anyway) and checks the commit message only on push events where the context is available.

🧹 Nitpick comments (1)
.github/workflows/ci.yaml (1)

459-459: Align skip condition with other jobs.

Other jobs in this workflow use !contains(github.event.pull_request.labels.*.name, 'skip:ci') to determine whether to run (lines 111, 176, 237, etc.). The new job uses a different mechanism: commit message matching. For consistency and predictability, consider aligning the auto-format job to use the same label-based skip pattern already established throughout the workflow:

-    if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
+    if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}

This ensures that all jobs respond to the same skip:ci label, making the workflow behavior uniform and easier to reason about.

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6139b5 and 3ed9216.

📒 Files selected for processing (1)
  • .github/workflows/ci.yaml (2 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: ShaharNaveh
Repo: RustPython/RustPython PR: 5932
File: .github/workflows/comment-commands.yml:18-24
Timestamp: 2025-07-10T10:08:43.330Z
Learning: In GitHub Actions workflows for the RustPython project, the maintainer ShaharNaveh prefers to keep workflows simple and doesn't mind if steps fail when the desired state is already achieved (e.g., user already assigned to an issue). Avoid suggesting complex error handling for edge cases they don't consider problematic.
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to **/*.rs : Format Rust code with the default rustfmt style (run `cargo fmt`)
📚 Learning: 2025-09-11T05:06:59.971Z
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to **/*.rs : Run clippy and fix any warnings or lints introduced by your changes

Applied to files:

  • .github/workflows/ci.yaml
📚 Learning: 2025-09-11T05:06:59.971Z
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to **/*.rs : Format Rust code with the default rustfmt style (run `cargo fmt`)

Applied to files:

  • .github/workflows/ci.yaml
📚 Learning: 2025-07-10T10:08:43.330Z
Learnt from: ShaharNaveh
Repo: RustPython/RustPython PR: 5932
File: .github/workflows/comment-commands.yml:18-24
Timestamp: 2025-07-10T10:08:43.330Z
Learning: In GitHub Actions workflows for the RustPython project, the maintainer ShaharNaveh prefers to keep workflows simple and doesn't mind if steps fail when the desired state is already achieved (e.g., user already assigned to an issue). Avoid suggesting complex error handling for edge cases they don't consider problematic.

Applied to files:

  • .github/workflows/ci.yaml
📚 Learning: 2025-09-11T05:06:59.971Z
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to extra_tests/**/*.py : Use ruff to lint custom Python code

Applied to files:

  • .github/workflows/ci.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run tests under miri
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Check Rust code with clippy
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Ensure compilation on various targets
🔇 Additional comments (1)
.github/workflows/ci.yaml (1)

309-316: Lint job refactor looks good.

Removing rustfmt from the lint job and moving it to a separate auto-format job is a clean separation of concerns. The lint job retains clippy for static analysis, which is appropriate.

@coderabbitai coderabbitai 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.

Hide comment

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ed9216 and 40a778d.

📒 Files selected for processing (1)
  • .github/workflows/pr-auto-commit.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: ShaharNaveh
Repo: RustPython/RustPython PR: 5932
File: .github/workflows/comment-commands.yml:18-24
Timestamp: 2025-07-10T10:08:43.330Z
Learning: In GitHub Actions workflows for the RustPython project, the maintainer ShaharNaveh prefers to keep workflows simple and doesn't mind if steps fail when the desired state is already achieved (e.g., user already assigned to an issue). Avoid suggesting complex error handling for edge cases they don't consider problematic.
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to **/*.rs : Format Rust code with the default rustfmt style (run `cargo fmt`)
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to **/*.rs : Run clippy and fix any warnings or lints introduced by your changes
🪛 actionlint (1.7.8)
.github/workflows/pr-auto-commit.yaml

69-69: "github.event.pull_request.head.ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details

(expression)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run tests under miri
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Check Rust code with clippy
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Ensure compilation on various targets
🔇 Additional comments (2)
.github/workflows/pr-auto-commit.yaml (2)

78-92: Well-designed PR comment notification.

The PR comment step is appropriately gated to only run when formatting changes are detected, and the message clearly explains what happened and how to pull the latest changes. This is good UX.


37-46: ****

The poseidon/wait-for-status-checks action waits until all watched checks succeed (or are skipped) or one fails, meaning it validates success and exits with failure if any check fails. The workflow will not proceed past that step if checks don't pass. The echo at lines 45–46 merely confirms that the validation passed; no additional verification is needed.

Likely an incorrect or invalid review comment.

@YashSuthar983

YashSuthar983 commented Nov 8, 2025

Copy link
Copy Markdown
Contributor Author

@fanninpm @youknowone now i have done diff approach here i used pull_request_target as this has more permissions then workflow_run .
now as i tested it working and auto-format only passes or give undesirable results when there is approval needed to run workflow(majorly fro first time contributors).

tested in pr

Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>

@coderabbitai coderabbitai 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.

Hide comment

Actionable comments posted: 0

♻️ Duplicate comments (2)
.github/workflows/pr-auto-commit.yaml (2)

16-19: ⚠️ Critical: Add fork guard to prevent workflow failure on forked PRs.

The job condition lacks a check to ensure the PR originates from the base repository. When this workflow runs on PRs from forked repositories, GitHub Actions in the base repo cannot push to the fork's branch, causing the workflow to fail. This is why the workflow succeeds in the author's fork but fails in the main repository.

Add a guard to skip auto-format for forked PRs:

  auto_format:
    if: |
      !contains(github.event.pull_request.labels.*.name, 'skip:ci') &&
      !contains(github.event.pull_request.head.sha, '[skip ci]') &&
+     github.event.pull_request.head.repo.full_name == github.repository

This ensures the job only runs for PRs opened against the main repository, not forked PRs.


67-76: ⚠️ Major: Mitigate script injection risk by passing ref through environment variable.

Line 76 directly interpolates github.event.pull_request.head.ref into the inline shell script. An untrusted PR ref could be crafted to inject arbitrary shell commands. Per GitHub's security guidance, pass the ref through an environment variable instead:

  - name: Commit and push formatting changes
    if: steps.check_changes.outputs.has_changes == 'true'
+   env:
+     HEAD_REF: ${{ github.event.pull_request.head.ref }}
    run: |
      git config user.name "github-actions[bot]"
      git config user.email "github-actions[bot]@users.noreply.github.com"
      
      git add -u
      git commit -m "Auto-format code [skip ci]"
      
-     git push origin HEAD:${{ github.event.pull_request.head.ref }}
+     git push origin HEAD:"$HEAD_REF"
🧹 Nitpick comments (1)
.github/workflows/pr-auto-commit.yaml (1)

78-95: Minor: Consistent script variable handling in PR comment message.

Line 94 also interpolates ${{ github.event.pull_request.head.ref }} directly. While this is in a message/documentation context (lower risk than the git push command), apply the same mitigation for consistency and to establish a pattern:

  - name: Comment on PR
    if: steps.check_changes.outputs.has_changes == 'true'
+   env:
+     HEAD_REF: ${{ github.event.pull_request.head.ref }}
    uses: marocchino/sticky-pull-request-comment@v2
    with:
      number: ${{ github.event.pull_request.number }}
      message: |
        **Code has been automatically formatted**
        
        The code in this PR has been formatted using `cargo fmt`.
        The changes have been committed with `[skip ci]` to avoid triggering another CI run.
        
        **Triggered by commit:** `${{ github.event.pull_request.head.sha }}`  
        **Last formatted:** ${{ github.event.pull_request.updated_at }}
        
        You may need to pull the latest changes before pushing again:
        ```bash
-       git pull origin ${{ github.event.pull_request.head.ref }}
+       git pull origin "$HEAD_REF"
        ```
📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40a778d and 012693f.

📒 Files selected for processing (1)
  • .github/workflows/pr-auto-commit.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ShaharNaveh
Repo: RustPython/RustPython PR: 5932
File: .github/workflows/comment-commands.yml:18-24
Timestamp: 2025-07-10T10:08:43.330Z
Learning: In GitHub Actions workflows for the RustPython project, the maintainer ShaharNaveh prefers to keep workflows simple and doesn't mind if steps fail when the desired state is already achieved (e.g., user already assigned to an issue). Avoid suggesting complex error handling for edge cases they don't consider problematic.
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to **/*.rs : Format Rust code with the default rustfmt style (run `cargo fmt`)
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to **/*.rs : Run clippy and fix any warnings or lints introduced by your changes
📚 Learning: 2025-07-10T10:08:43.330Z
Learnt from: ShaharNaveh
Repo: RustPython/RustPython PR: 5932
File: .github/workflows/comment-commands.yml:18-24
Timestamp: 2025-07-10T10:08:43.330Z
Learning: In GitHub Actions workflows for the RustPython project, the maintainer ShaharNaveh prefers to keep workflows simple and doesn't mind if steps fail when the desired state is already achieved (e.g., user already assigned to an issue). Avoid suggesting complex error handling for edge cases they don't consider problematic.

Applied to files:

  • .github/workflows/pr-auto-commit.yaml
🪛 actionlint (1.7.8)
.github/workflows/pr-auto-commit.yaml

69-69: "github.event.pull_request.head.ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details

(expression)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Check Rust code with clippy
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Ensure compilation on various targets

@youknowone

Copy link
Copy Markdown
Member

I'm a bit concerned about the formatting failure, but let's give it another try.

Hide details View details @youknowone youknowone merged commit 2d46172 into RustPython:main Nov 10, 2025
12 of 13 checks passed
@youknowone

Copy link
Copy Markdown
Member

@youknowone

Copy link
Copy Markdown
Member

Thank you so much! 👍

@youknowone

Copy link
Copy Markdown
Member

@YashSuthar983

YashSuthar983 commented Nov 10, 2025

Copy link
Copy Markdown
Contributor Author

@youknowone i guess its failing because fork using old auto-commit job,
See this test pr #6247 and #6248 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants