-
-
Notifications
You must be signed in to change notification settings - Fork 676
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
fix: fixed the notify triager workflow #3460
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request introduces modifications to the workflow file Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
✅ Deploy Preview for asyncapi-website ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Tested the workflow here |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3460 +/- ##
=======================================
Coverage 77.22% 77.22%
=======================================
Files 21 21
Lines 663 663
=======================================
Hits 512 512
Misses 151 151 ☔ View full report in Codecov by Sentry. |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-3460--asyncapi-website.netlify.app/ |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
.github/workflows/notify-triager.yml (4)
20-23
: Consider making the commit message extraction more robustThe current implementation might:
- Remove legitimate characters from commit messages (e.g., brackets in conventional commit scopes)
- Lose important formatting due to aggressive sanitization
Consider this more selective sanitization:
- commit_message=$(echo "$commit_message" | sed 's/[<>|]//g' | sed 's/[][]//g' | sed 's/(//g' | sed 's/)//g' | xargs) + # Only remove characters that could cause issues in GitHub API calls + commit_message=$(echo "$commit_message" | sed 's/[<>|]//g' | tr '\n' ' ' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
46-46
: Remove outdated version commentThe inline comment references version 42.1.0 but the action is using v45.
- uses: tj-actions/changed-files@v45 # version 42.1.0 https://github.com/tj-actions/changed-files/releases/tag/v42.1.0 + uses: tj-actions/changed-files@v45
50-50
: Fix formatting issuesRemove the trailing whitespace and empty lines.
🧰 Tools
🪛 yamllint (1.35.1)
[error] 50-50: trailing spaces
(trailing-spaces)
100-100
: Fix file formattingAdd a newline at the end of the file and remove trailing whitespace.
🧰 Tools
🪛 yamllint (1.35.1)
[error] 100-100: no new line character at the end of file
(new-line-at-end-of-file)
[error] 100-100: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/notify-triager.yml
(5 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/notify-triager.yml
[error] 50-50: trailing spaces
(trailing-spaces)
[error] 100-100: no new line character at the end of file
(new-line-at-end-of-file)
[error] 100-100: trailing spaces
(trailing-spaces)
🔇 Additional comments (3)
.github/workflows/notify-triager.yml (3)
40-43
: LGTM! Good practice using a pinned version.
The addition of this step with a specific version tag improves stability and reliability.
87-87
: LGTM! Consistent with the workflow's purpose.
The condition correctly triggers doc reviewer notifications when markdown files are changed.
72-72
: LGTM! This fixes the core issue.
The condition correctly prevents code reviewer notifications when only markdown files are changed by comparing the total changed files count with markdown files count.
Let's verify the logic works as expected:
✅ Verification successful
Logic verification confirms this is a correct implementation
The workflow implementation correctly handles the core requirement:
- Uses
changed-files
action twice:- First to get all changed files count (
steps.changed-files.outputs.all_changed_files_count
) - Second to get markdown files count (
steps.md-pr-changes.outputs.all_changed_files_count
) with**.md
filter
- First to get all changed files count (
- The condition
steps.changed-files.outputs.all_changed_files_count != steps.md-pr-changes.outputs.all_changed_files_count
will:- Be true when there are non-markdown changes (triggering code reviewer notification)
- Be false when all changes are markdown files (skipping code reviewer notification)
- The merge commit check (
steps.check-merge-branch.outputs.isMergeCommit == 'false'
) properly prevents notifications for merge commits
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Test the condition with different file change scenarios
# Create test PR with only MD changes
cat << EOF > test_changes.json
{
"md_only": {
"changed_files": ["docs/a.md", "docs/b.md"],
"expected": "should_not_notify_code_reviewers"
},
"mixed": {
"changed_files": ["docs/a.md", "src/code.js"],
"expected": "should_notify_code_reviewers"
}
}
EOF
# Verify the workflow handles these cases
gh workflow run notify-triager.yml --json test_changes.json
Length of output: 244
Script:
#!/bin/bash
# Let's verify the workflow logic by examining the actual implementation
# First, check the workflow file content
cat .github/workflows/notify-triager.yml
# Then, let's examine the steps that provide the outputs used in the condition
rg -A 2 "id: changed-files" .github/workflows/notify-triager.yml
rg -A 2 "id: md-pr-changes" .github/workflows/notify-triager.yml
Length of output: 4347
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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
.github/workflows/notify-triager.yml (3)
20-23
: Consider optimizing the commit message sanitization.The current implementation works but could be more efficient. Consider combining the multiple sed commands into a single operation.
- commit_message=$(echo "$commit_message" | sed 's/[<>|]//g' | sed 's/[][]//g' | sed 's/(//g' | sed 's/)//g' | xargs) + commit_message=$(echo "$commit_message" | sed 's/[<>|()[\]]//g' | xargs)
50-50
: Remove unnecessary empty lines in the file pattern section.The empty lines after the file pattern are unnecessary and flagged by the linter.
files: | **.md - -🧰 Tools
🪛 yamllint (1.35.1)
[error] 50-50: trailing spaces
(trailing-spaces)
100-100
: Remove trailing whitespace.Remove the trailing whitespace on line 100 to fix the linting error.
🧰 Tools
🪛 yamllint (1.35.1)
[error] 100-100: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/notify-triager.yml
(5 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/notify-triager.yml
[error] 50-50: trailing spaces
(trailing-spaces)
[error] 100-100: trailing spaces
(trailing-spaces)
🔇 Additional comments (1)
.github/workflows/notify-triager.yml (1)
72-72
: The reviewer assignment logic looks good.
The conditions correctly handle:
- Code reviewers: Only notified when non-markdown files are changed
- Doc reviewers: Only notified when markdown files are changed
This aligns with the PR objective to fix incorrect notifications.
Let's verify the logic works as expected:
Also applies to: 87-87
✅ Verification successful
Let me try a different approach to verify the logic by examining the workflow file directly.
After examining the workflow file, I can now generate the final response:
The reviewer assignment logic is correctly implemented
The conditions for assigning reviewers are properly structured:
-
Code reviewers are notified when:
- The commit is not a merge commit (
isMergeCommit == 'false'
) - There are non-markdown files changed (
all_changed_files_count != md-pr-changes.outputs.all_changed_files_count
)
- The commit is not a merge commit (
-
Doc reviewers are notified when:
- The commit is not a merge commit (
isMergeCommit == 'false'
) - Any markdown files are changed (
any_changed == 'true'
)
- The commit is not a merge commit (
The implementation uses the correct outputs from the changed-files
action and properly handles both scenarios, ensuring reviewers are only notified for relevant changes.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Test the reviewer assignment logic with different file change scenarios
# Scenario 1: Only markdown files
echo "Testing scenario with only markdown files..."
gh pr create --draft --title "test: only md changes" --body "test" --base main
touch test.md
git add test.md
git commit -m "test: add markdown file"
git push
# Scenario 2: Mixed files
echo "Testing scenario with mixed files..."
gh pr create --draft --title "test: mixed changes" --body "test" --base main
touch test.md test.js
git add test.md test.js
git commit -m "test: add mixed files"
git push
# Check the workflow runs
gh run list --workflow=notify-triager.yml --limit 2
Length of output: 2339
Script:
#!/bin/bash
# Check the workflow file content
cat .github/workflows/notify-triager.yml
# Find all workflow runs that used this workflow
gh run list --workflow=notify-triager.yml --json conclusion,event,displayTitle --limit 10
Length of output: 5251
- name: Get all changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@aa08304bd477b800d468db44fe10f6c61f7f7b11 | ||
|
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.
Use version tags instead of commit hashes for action versions.
Using a specific commit hash (aa08304bd477b800d468db44fe10f6c61f7f7b11
) for the action version is risky as the commit could be force-pushed or deleted. The AI summary indicates that this should be using v45
.
- uses: tj-actions/changed-files@aa08304bd477b800d468db44fe10f6c61f7f7b11
+ uses: tj-actions/changed-files@v45
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
- name: Get all changed files | |
id: changed-files | |
uses: tj-actions/changed-files@aa08304bd477b800d468db44fe10f6c61f7f7b11 | |
- name: Get all changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v45 | |
@asyncapi/bounty_team |
@@ -68,7 +69,7 @@ jobs: | |||
echo "codeTriagers=$codeTriagers" >> $GITHUB_ENV | |||
|
|||
- name: Add Reviewers for code files | |||
if: steps.check-merge-branch.outputs.isMergeCommit == 'false' && steps.non-md-pr-changes.outputs.any_changed == 'true' | |||
if: ${{ steps.check-merge-branch.outputs.isMergeCommit == 'false' && steps.changed-files.outputs.all_changed_files_count != steps.md-pr-changes.outputs.all_changed_files_count }} |
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.
What if the changed-files.outputs.all_changed_files_count
is equal to steps.md-pr-changes.outputs.all_changed_files_count
?
Can you please explain exactly what that check means?
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.
For this we are checking for non md files
If the count is not equal that means there are some non md files also which needs to be reviewed by code reviewers
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.
tj-actions doesn't have any mechanism for non md files so that's why I implemented this or else we need to check for many file extensions
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.
Got it. Good catch
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.
Though I am still curious about the ambigious behavior of this workflow. For example, examine this PR
See how MD triagers are getting assigned as PR reviewers even though there was no merge commit or a MD file change
Another instance of this issue:
#3075 (comment)
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.
https://github.com/asyncapi/website/actions/runs/11141478939/job/30962427072
I think this job was surpassed
The current workflow has an error in which it calls the code reviewers also when the changes are only in the md files
Fixed that by adding a check
fixes : #3214
Summary by CodeRabbit
New Features
Bug Fixes