-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Clarify commit message from pr-auto-commit #6706
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
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 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,42 +34,77 @@ jobs: | |||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||
| components: rustfmt | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Configure git | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| git config user.name "github-actions[bot]" | ||||||||||||||||||||||||||||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||||||||||||||||||||||||||||
| echo "" > /tmp/committed_commands.txt | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
+37
to
+42
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. Avoid writing a leading blank line to Proposed fix - name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- echo "" > /tmp/committed_commands.txt
+ : > /tmp/committed_commands.txt🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| - name: Run cargo fmt | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| echo "Running cargo fmt --all on PR #${{ github.event.pull_request.number }}" | ||||||||||||||||||||||||||||
| cargo fmt --all | ||||||||||||||||||||||||||||
| if [ -n "$(git status --porcelain)" ]; then | ||||||||||||||||||||||||||||
| git add -u | ||||||||||||||||||||||||||||
| git commit -m "Auto-format: cargo fmt --all" | ||||||||||||||||||||||||||||
| echo "- \`cargo fmt --all\`" >> /tmp/committed_commands.txt | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Install ruff | ||||||||||||||||||||||||||||
| uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1 | ||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||
| version: "0.14.9" | ||||||||||||||||||||||||||||
| args: "--version" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - run: ruff format | ||||||||||||||||||||||||||||
| - run: ruff check --select I --fix | ||||||||||||||||||||||||||||
| - run: python scripts/generate_opcode_metadata.py | ||||||||||||||||||||||||||||
| - name: Run ruff format | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| ruff format | ||||||||||||||||||||||||||||
| if [ -n "$(git status --porcelain)" ]; then | ||||||||||||||||||||||||||||
| git add -u | ||||||||||||||||||||||||||||
| git commit -m "Auto-format: ruff format" | ||||||||||||||||||||||||||||
| echo "- \`ruff format\`" >> /tmp/committed_commands.txt | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Configure git | ||||||||||||||||||||||||||||
| - name: Run ruff check import sorting | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| git config user.name "github-actions[bot]" | ||||||||||||||||||||||||||||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||||||||||||||||||||||||||||
| ruff check --select I --fix | ||||||||||||||||||||||||||||
| if [ -n "$(git status --porcelain)" ]; then | ||||||||||||||||||||||||||||
| git add -u | ||||||||||||||||||||||||||||
| git commit -m "Auto-format: ruff check --select I --fix" | ||||||||||||||||||||||||||||
| echo "- \`ruff check --select I --fix\`" >> /tmp/committed_commands.txt | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Run generate_opcode_metadata.py | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| python scripts/generate_opcode_metadata.py | ||||||||||||||||||||||||||||
| if [ -n "$(git status --porcelain)" ]; then | ||||||||||||||||||||||||||||
| git add -u | ||||||||||||||||||||||||||||
| git commit -m "Auto-generate: generate_opcode_metadata.py" | ||||||||||||||||||||||||||||
| echo "- \`python scripts/generate_opcode_metadata.py\`" >> /tmp/committed_commands.txt | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
43
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. Fix conditional-commit staging: Proposed fix (apply to all 4 commit blocks) - name: Run cargo fmt
run: |
echo "Running cargo fmt --all on PR #${{ github.event.pull_request.number }}"
cargo fmt --all
if [ -n "$(git status --porcelain)" ]; then
- git add -u
- git commit -m "Auto-format: cargo fmt --all"
+ git add -A
+ if ! git diff --cached --quiet; then
+ git commit -m "Auto-format: cargo fmt --all"
+ fi
echo "- \`cargo fmt --all\`" >> /tmp/committed_commands.txt
fi - name: Run ruff format
run: |
ruff format
if [ -n "$(git status --porcelain)" ]; then
- git add -u
- git commit -m "Auto-format: ruff format"
+ git add -A
+ if ! git diff --cached --quiet; then
+ git commit -m "Auto-format: ruff format"
+ fi
echo "- \`ruff format\`" >> /tmp/committed_commands.txt
fi - name: Run ruff check import sorting
run: |
ruff check --select I --fix
if [ -n "$(git status --porcelain)" ]; then
- git add -u
- git commit -m "Auto-format: ruff check --select I --fix"
+ git add -A
+ if ! git diff --cached --quiet; then
+ git commit -m "Auto-format: ruff check --select I --fix"
+ fi
echo "- \`ruff check --select I --fix\`" >> /tmp/committed_commands.txt
fi - name: Run generate_opcode_metadata.py
run: |
python scripts/generate_opcode_metadata.py
if [ -n "$(git status --porcelain)" ]; then
- git add -u
- git commit -m "Auto-generate: generate_opcode_metadata.py"
+ git add -A
+ if ! git diff --cached --quiet; then
+ git commit -m "Auto-generate: generate_opcode_metadata.py"
+ fi
echo "- \`python scripts/generate_opcode_metadata.py\`" >> /tmp/committed_commands.txt
fi🤖 Prompt for AI Agents
Comment on lines
+77
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. Critical: Minimal mitigation (keeps the workflow simple): skip this step for fork PRs. Proposed fix - name: Run generate_opcode_metadata.py
+ if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
run: |
python scripts/generate_opcode_metadata.py
if [ -n "$(git status --porcelain)" ]; then
git add -u
git commit -m "Auto-generate: generate_opcode_metadata.py"
echo "- \`python scripts/generate_opcode_metadata.py\`" >> /tmp/committed_commands.txt
fi🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| - name: Check for changes | ||||||||||||||||||||||||||||
| id: check-changes | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| if [ -n "$(git status --porcelain)" ]; then | ||||||||||||||||||||||||||||
| if [ "$(git rev-parse HEAD)" != "${{ github.event.pull_request.head.sha }}" ]; then | ||||||||||||||||||||||||||||
| echo "has_changes=true" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||
| echo "has_changes=false" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Commit and push formatting changes | ||||||||||||||||||||||||||||
| - name: Push formatting changes | ||||||||||||||||||||||||||||
| if: steps.check-changes.outputs.has_changes == 'true' | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| git add -u | ||||||||||||||||||||||||||||
| git commit -m "Auto-format: cargo fmt --all" | ||||||||||||||||||||||||||||
| git push origin HEAD:${{ github.event.pull_request.head.ref }} | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
+95
to
99
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. Fix potential script-injection via Proposed fix - name: Push formatting changes
if: steps.check-changes.outputs.has_changes == 'true'
+ env:
+ PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
- git push origin HEAD:${{ github.event.pull_request.head.ref }}
+ git push origin "HEAD:refs/heads/${PR_HEAD_REF}"📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.10)97-97: "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) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| - name: Read committed commands | ||||||||||||||||||||||||||||
| id: committed-commands | ||||||||||||||||||||||||||||
| if: steps.check-changes.outputs.has_changes == 'true' | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| echo "list<<EOF" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||
| cat /tmp/committed_commands.txt >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||
| echo "EOF" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Comment on PR | ||||||||||||||||||||||||||||
| if: steps.check-changes.outputs.has_changes == 'true' | ||||||||||||||||||||||||||||
| uses: marocchino/sticky-pull-request-comment@v2 | ||||||||||||||||||||||||||||
|
|
@@ -78,7 +113,8 @@ jobs: | |||||||||||||||||||||||||||
| message: | | ||||||||||||||||||||||||||||
| **Code has been automatically formatted** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| The code in this PR has been formatted using `cargo fmt --all`. | ||||||||||||||||||||||||||||
| The code in this PR has been formatted using: | ||||||||||||||||||||||||||||
| ${{ steps.committed-commands.outputs.list }} | ||||||||||||||||||||||||||||
| Please pull the latest changes before pushing again: | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| git pull origin ${{ github.event.pull_request.head.ref }} | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
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.
Can you please adjust the message at line 103?
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.
Oh, I missed it. I fixed it! Thanks for letting me know it 🙏🏻