-
Notifications
You must be signed in to change notification settings - Fork 353
ci(pr-coments): handle partial successes in pr-comments workflow #15294
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
base: release-2.13
Are you sure you want to change the base?
Conversation
Signed-off-by: slonka <[email protected]>
Reviewer Checklist🔍 Each of these sections need to be checked by the reviewer of the PR 🔍:
|
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.
Pull request overview
This PR enhances the pr-comments workflow to better handle partial failures when formatting code or updating golden files via PR comments. Previously, if any step failed, no changes would be pushed. Now, the workflow can push successful changes even if some steps fail, and provides better feedback through GitHub reactions (👍 for success, 👎 for failure).
Key changes:
- Split formatting and golden file update steps into separate execution and commit phases with
continue-on-error: true - Added conditional logic to commit and push changes only when the corresponding step doesn't skip
- Implemented dual reaction system: success reaction when no failures occur, failure reaction when any step fails
.github/workflows/pr-comments.yaml
Outdated
| echo "FORMAT_PUSHED=true" >> "$GITHUB_ENV" | ||
| 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 and push golden files changes" | ||
| if: contains(github.event.comment.body, '/golden_files') && steps.golden-files.outcome != 'skipped' | ||
| continue-on-error: true | ||
| env: | ||
| GITHUB_TOKEN: ${{ steps.github-app-token.outputs.token }} | ||
| run: | | ||
| if git diff --exit-code --stat; then | ||
| echo "No golden files changes detected" | ||
| else | ||
| git config user.name "${GH_USER}" | ||
| git config user.email "${GH_EMAIL}" | ||
| git commit -s -m "fix(ci): update golden files" . | ||
| git push | ||
| echo "GOLDEN_FILES_PUSHED=true" >> "$GITHUB_ENV" | ||
| 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 | ||
| - name: "Commit and push transparent proxy golden files changes" | ||
| if: contains(github.event.comment.body, '/golden_files_tproxy') && steps.golden-files-tproxy.outcome != 'skipped' | ||
| continue-on-error: true | ||
| env: | ||
| GITHUB_TOKEN: ${{ steps.github-app-token.outputs.token }} | ||
| run: | | ||
| if git diff --exit-code --stat; then | ||
| echo "No change detected, skipping git push" | ||
| echo "No transparent proxy golden files changes detected" | ||
| else | ||
| git config user.name "${GH_USER}" | ||
| git config user.email "${GH_EMAIL}" | ||
| git commit -s -m "fix(ci): format files" . | ||
| git commit -s -m "fix(ci): update transparent proxy golden files" . | ||
| git push | ||
| echo "TPROXY_GOLDEN_FILES_PUSHED=true" >> "$GITHUB_ENV" |
Copilot
AI
Dec 16, 2025
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.
The environment variables FORMAT_PUSHED, GOLDEN_FILES_PUSHED, and TPROXY_GOLDEN_FILES_PUSHED are set but never used. If these were intended for tracking or debugging purposes, they would not be visible in subsequent workflow runs or steps since environment variables set with GITHUB_ENV only persist within the current job.
If these variables are not needed, consider removing them to reduce complexity. If they are needed for future use, add a comment explaining their purpose.
Signed-off-by: slonka <[email protected]>
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.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
| if [ "${{ steps.format.outcome }}" != "" ]; then | ||
| if [ "${{ steps.format.outcome }}" == "success" ]; then | ||
| SUMMARY="${SUMMARY}✅ **Format**: Succeeded and pushed\n" | ||
| 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 | ||
| SUMMARY="${SUMMARY}✅ **Golden files**: Succeeded and pushed\n" | ||
| 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 | ||
| SUMMARY="${SUMMARY}✅ **Transparent proxy golden files**: Succeeded and pushed\n" | ||
| elif [ "${{ steps.golden-files-tproxy.outcome }}" == "failure" ]; then | ||
| SUMMARY="${SUMMARY}❌ **Transparent proxy golden files**: Failed\n" | ||
| fi | ||
| fi |
Copilot
AI
Dec 16, 2025
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.
The condition checking for empty outcome (!= "") doesn't distinguish between a step that was skipped versus one that ran. When a step is skipped (because its if condition is false), the outcome will be an empty string, but this check will treat it the same as if it never existed. This means if someone comments /format only, the summary will incorrectly show results for golden files steps that were never triggered.
Consider checking if the step was actually triggered by verifying the corresponding comment body contains the command, or use the conclusion field which differentiates between skipped and not-run steps.
| if [ "${{ steps.format.outcome }}" == "success" ]; then | ||
| SUMMARY="${SUMMARY}✅ **Format**: Succeeded and pushed\n" | ||
| 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 | ||
| SUMMARY="${SUMMARY}✅ **Golden files**: Succeeded and pushed\n" | ||
| 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 | ||
| SUMMARY="${SUMMARY}✅ **Transparent proxy golden files**: Succeeded and pushed\n" | ||
| elif [ "${{ steps.golden-files-tproxy.outcome }}" == "failure" ]; then | ||
| SUMMARY="${SUMMARY}❌ **Transparent proxy golden files**: Failed\n" |
Copilot
AI
Dec 16, 2025
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.
The summary message incorrectly states "Succeeded and pushed" for all successful outcomes, but the commit-and-push steps have continue-on-error: true, meaning they could fail silently after the main step succeeds. If the git push fails (e.g., due to permissions or conflicts), the summary will still show "Succeeded and pushed" even though nothing was actually pushed.
Consider checking the outcome of the commit-and-push steps as well, or remove continue-on-error from those steps so failures are properly reported. Alternatively, update the message to say "Succeeded" without implying the push completed successfully.
| steps.format.outcome != 'failure' && | ||
| steps.golden-files.outcome != 'failure' && | ||
| steps.golden-files-tproxy.outcome != 'failure' |
Copilot
AI
Dec 16, 2025
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.
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.
| 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' | |
| ) |
Signed-off-by: slonka <[email protected]>
Motivation
If there is a partial failure like this https://github.com/kumahq/kuma/actions/runs/20259928702 it still might be valid to push format changes.
Implementation information
Made it possible to submit partial success, added 👎 when failure.