Skip to content
Open
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
119 changes: 112 additions & 7 deletions .github/workflows/pr-comments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,136 @@ jobs:
# Automatically update code formatting if /format is in the comment
- name: "Auto-format code"
if: contains(github.event.comment.body, '/format')
id: format
continue-on-error: true
run: make clean/generated check

- name: "Commit format changes"
if: contains(github.event.comment.body, '/format') && steps.format.outcome == 'success'
id: commit-format
continue-on-error: true
run: |
if git diff --exit-code --stat; then
echo "No format changes detected"
echo "committed=false" >> "$GITHUB_OUTPUT"
else
git config user.name "${GH_USER}"
git config user.email "${GH_EMAIL}"
git commit -s -m "fix(ci): format files" .
echo "committed=true" >> "$GITHUB_OUTPUT"
fi

# Update all golden files except transparent proxy tests if /golden_files is in the comment
- name: "Update golden files (excluding transparent proxy)"
if: contains(github.event.comment.body, '/golden_files')
id: golden-files
continue-on-error: true
run: make test UPDATE_GOLDEN_FILES=true

- name: "Commit golden files changes"
if: contains(github.event.comment.body, '/golden_files') && steps.golden-files.outcome == 'success'
id: commit-golden-files
continue-on-error: true
run: |
if git diff --exit-code --stat; then
echo "No golden files changes detected"
echo "committed=false" >> "$GITHUB_OUTPUT"
else
git config user.name "${GH_USER}"
git config user.email "${GH_EMAIL}"
git commit -s -m "fix(ci): update golden files" .
echo "committed=true" >> "$GITHUB_OUTPUT"
fi

# Update only transparent proxy golden files if /golden_files_tproxy is in the comment
- name: "Update transparent proxy golden files"
if: contains(github.event.comment.body, '/golden_files_tproxy')
id: golden-files-tproxy
continue-on-error: true
run: make test/transparentproxy UPDATE_GOLDEN_FILES=true

- name: commit and push fixes
env:
GITHUB_TOKEN: ${{ steps.github-app-token.outputs.token }}
- name: "Commit transparent proxy golden files changes"
if: contains(github.event.comment.body, '/golden_files_tproxy') && steps.golden-files-tproxy.outcome == 'success'
id: commit-golden-files-tproxy
continue-on-error: true
run: |
if git diff --exit-code --stat; then
echo "No change detected, skipping git push"
echo "No transparent proxy golden files changes detected"
echo "committed=false" >> "$GITHUB_OUTPUT"
else
git config user.name "${GH_USER}"
git config user.email "${GH_EMAIL}"
git commit -s -m "fix(ci): format files" .
git push
git commit -s -m "fix(ci): update transparent proxy golden files" .
echo "committed=true" >> "$GITHUB_OUTPUT"
fi

- name: "Push all commits"
if: |
always() &&
(steps.commit-format.outputs.committed == 'true' ||
steps.commit-golden-files.outputs.committed == 'true' ||
steps.commit-golden-files-tproxy.outputs.committed == 'true')
env:
GITHUB_TOKEN: ${{ steps.github-app-token.outputs.token }}
run: git push

- name: "Post summary comment"
if: always()
env:
GITHUB_TOKEN: ${{ steps.github-app-token.outputs.token }}
run: |
SUMMARY="## Workflow Results\n\n"

if [ "${{ steps.format.outcome }}" != "" ]; then
if [ "${{ steps.format.outcome }}" == "success" ]; then
if [ "${{ steps.commit-format.outputs.committed }}" == "true" ]; then
SUMMARY="${SUMMARY}✅ **Format**: Succeeded and committed\n"
else
SUMMARY="${SUMMARY}✅ **Format**: Succeeded (no changes)\n"
fi
elif [ "${{ steps.format.outcome }}" == "failure" ]; then
SUMMARY="${SUMMARY}❌ **Format**: Failed\n"
fi
fi

if [ "${{ steps.golden-files.outcome }}" != "" ]; then
if [ "${{ steps.golden-files.outcome }}" == "success" ]; then
if [ "${{ steps.commit-golden-files.outputs.committed }}" == "true" ]; then
SUMMARY="${SUMMARY}✅ **Golden files**: Succeeded and committed\n"
else
SUMMARY="${SUMMARY}✅ **Golden files**: Succeeded (no changes)\n"
fi
elif [ "${{ steps.golden-files.outcome }}" == "failure" ]; then
SUMMARY="${SUMMARY}❌ **Golden files**: Failed\n"
fi
fi

if [ "${{ steps.golden-files-tproxy.outcome }}" != "" ]; then
if [ "${{ steps.golden-files-tproxy.outcome }}" == "success" ]; then
if [ "${{ steps.commit-golden-files-tproxy.outputs.committed }}" == "true" ]; then
SUMMARY="${SUMMARY}✅ **Transparent proxy golden files**: Succeeded and committed\n"
else
SUMMARY="${SUMMARY}✅ **Transparent proxy golden files**: Succeeded (no changes)\n"
fi
elif [ "${{ steps.golden-files-tproxy.outcome }}" == "failure" ]; then
SUMMARY="${SUMMARY}❌ **Transparent proxy golden files**: Failed\n"
fi
fi
- run: gh api --method POST -f content='hooray' ${{ github.event.comment.url }}/reactions

gh pr comment ${{ github.event.issue.number }} --repo ${{ github.repository }} --body "$SUMMARY"

- name: "Add success reaction"
if: |
always() &&
steps.format.outcome != 'failure' &&
steps.golden-files.outcome != 'failure' &&
steps.golden-files-tproxy.outcome != 'failure'
Comment on lines +174 to +176
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The condition uses string inequality checks that could be simplified and made more explicit. Currently, checking steps.format.outcome != 'failure' for each step means that skipped steps (with empty outcomes) are treated as successes.

Consider using explicit positive checks like (steps.format.outcome == 'success' || steps.golden-files.outcome == 'success' || steps.golden-files-tproxy.outcome == 'success') to only add the success reaction when at least one operation actually succeeded.

Suggested change
steps.format.outcome != 'failure' &&
steps.golden-files.outcome != 'failure' &&
steps.golden-files-tproxy.outcome != 'failure'
(
steps.format.outcome == 'success' ||
steps.golden-files.outcome == 'success' ||
steps.golden-files-tproxy.outcome == 'success'
)

Copilot uses AI. Check for mistakes.
run: gh api --method POST -f content='hooray' ${{ github.event.comment.url }}/reactions
env:
GITHUB_TOKEN: ${{ steps.github-app-token.outputs.token }}

- name: "Add failure reaction"
if: always() && (steps.format.outcome == 'failure' || steps.golden-files.outcome == 'failure' || steps.golden-files-tproxy.outcome == 'failure')
run: gh api --method POST -f content='-1' ${{ github.event.comment.url }}/reactions
env:
GITHUB_TOKEN: ${{ steps.github-app-token.outputs.token }}
Loading