Skip to content
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

chore: pr reminder for slack #21830

Merged
merged 28 commits into from
Sep 25, 2024
Merged

chore: pr reminder for slack #21830

merged 28 commits into from
Sep 25, 2024

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Sep 20, 2024

Description

testing a pr reminder for open prs on github


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features
    • Introduced a new automated reminder system for open pull requests, sending notifications to a Slack channel every weekday at 9:00 AM UTC.
    • Provides a summary of open pull requests, including titles, links, and assignees, enhancing visibility for team members.

Copy link
Contributor

coderabbitai bot commented Sep 20, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

A new GitHub Actions workflow named pr-reminder.yml has been created to automate reminders for open pull requests. This workflow is scheduled to run every weekday at 9:00 AM UTC. It retrieves a list of open, non-draft pull requests and sends a summary notification to a specified Slack channel if any active pull requests are present.

Changes

File Change Summary
.github/workflows/pr-reminder.yml New workflow added to automate reminders for open pull requests.

Sequence Diagram(s)

sequenceDiagram
    participant Scheduler
    participant GitHub Actions
    participant Slack

    Scheduler->>GitHub Actions: Trigger workflow (daily at 9:00 AM UTC)
    GitHub Actions->>GitHub: List open pull requests (not in draft)
    GitHub Actions->>GitHub Actions: Construct summary table
    alt If open PRs exist
        GitHub Actions->>Slack: Send reminder with PR summary
    end
Loading

📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between dc8846a and 89c1c48.

📒 Files selected for processing (1)
  • .github/workflows/pr-reminder.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/pr-reminder.yml

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tac0turtle tac0turtle force-pushed the marko/prreminder branch 11 times, most recently from fc45071 to 288a221 Compare September 20, 2024 10:48
@tac0turtle tac0turtle marked this pull request as ready for review September 23, 2024 10:40
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4666e1d and 1588446.

Files selected for processing (1)
  • .github/workflows/pr-reminder.yml (1 hunks)
Additional context used
actionlint
.github/workflows/pr-reminder.yml

19-19: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

Additional comments not posted (2)
.github/workflows/pr-reminder.yml (2)

8-9: LGTM: Appropriate permissions set

The permissions are correctly set to the minimum required (read access to pull requests) for this workflow's functionality. This adheres to the principle of least privilege, which is a good security practice.


1-54: Overall assessment: Good implementation with room for improvement

This PR reminder workflow is well-structured and achieves its intended purpose. It effectively lists open pull requests and sends a reminder to a Slack channel. The use of GitHub Script for fetching PR data and the conditional execution of the Slack notification are particularly good practices.

However, there are several areas where the workflow can be improved:

  1. Removing the unnecessary pull request trigger
  2. Updating action versions to the latest available
  3. Fixing a typo in the PR summary
  4. Enhancing the Slack message with more context

By implementing the suggested changes, you'll have a more robust, up-to-date, and informative PR reminder workflow. Great job on setting this up, and thank you for your attention to improving the team's PR review process!

Tools
actionlint

19-19: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

Comment on lines 41 to 54
- name: Send Slack Reminder
if: steps.pr-list.outputs.result != ''
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: pr-github
SLACK_USERNAME: PR-Reminder
SG_MINIMAL: true
SLACK_ICON_EMOJI: ":think:"
SLACK_COLOR: good
SLACKIFY_MARKDOWN: true
SLACK_TITLE: Daily Pull Request Review Reminder
SLACK_MESSAGE: |
${{ steps.pr-list.outputs.result }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance Slack notification step

The Slack notification step is well-structured, but there are a few improvements that could be made:

  1. The rtCamp/action-slack-notify action is not using the latest version.
  2. The message could be enhanced with more context, such as the total number of open PRs.

Consider applying the following changes:

  1. Update the action version:
-        uses: rtCamp/[email protected]
+        uses: rtCamp/[email protected]
  1. Enhance the message with more context:
           SLACK_TITLE: Daily Pull Request Review Reminder
           SLACK_MESSAGE: |
+            There are currently ${{ steps.pr-list.outputs.total }} open pull requests requiring review:
+
             ${{ steps.pr-list.outputs.result }}
  1. Add a step to count the total number of open PRs:
      - name: Count open pull requests
        id: pr-count
        uses: actions/github-script@v7
        with:
          script: |
            const { data: pullRequests } = await github.rest.pulls.list({
              owner: context.repo.owner,
              repo: context.repo.repo,
              state: 'open',
              draft: false
            });
            return pullRequests.length.toString();

      - name: Send Slack Reminder
        if: steps.pr-list.outputs.result != ''
        uses: rtCamp/[email protected]
        env:
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
          SLACK_CHANNEL: pr-github
          SLACK_USERNAME: PR-Reminder
          SG_MINIMAL: true
          SLACK_ICON_EMOJI: ":think:"
          SLACK_COLOR: good
          SLACKIFY_MARKDOWN: true
          SLACK_TITLE: Daily Pull Request Review Reminder
          SLACK_MESSAGE: |
            There are currently ${{ steps.pr-count.outputs.result }} open pull requests requiring review:

            ${{ steps.pr-list.outputs.result }}

These changes will update the action to the latest version and provide more context in the Slack message, making it more informative for the team.

Comment on lines 12 to 16
pr-review:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
Copy link
Contributor

Choose a reason for hiding this comment

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

Update checkout action to the latest version

The job setup looks good, running on the latest Ubuntu version. However, the actions/checkout action is using version 3, which is not the latest.

Consider updating to the latest version (v4) for potential improvements and bug fixes:

       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
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.

Suggested change
pr-review:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
pr-review:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

Comment on lines 1 to 6
name: PR Review Reminder

on:
schedule:
- cron: '0 9 * * 1-5' # Every weekday at 9:00 AM UTC
pull_request:
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider removing the pull request trigger

The workflow name and schedule are well-defined. However, the pull request trigger (line 6) might be unnecessary for a reminder workflow that's intended to run on a schedule. Unless there's a specific reason to run the reminder immediately when a pull request is created or updated, consider removing this trigger to avoid potential noise or unnecessary executions.

You can remove the pull request trigger by applying this diff:

 on:
   schedule:
     - cron: '0 9 * * 1-5'  # Every weekday at 9:00 AM UTC
-  pull_request:
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.

Suggested change
name: PR Review Reminder
on:
schedule:
- cron: '0 9 * * 1-5' # Every weekday at 9:00 AM UTC
pull_request:
name: PR Review Reminder
on:
schedule:
- cron: '0 9 * * 1-5' # Every weekday at 9:00 AM UTC

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1588446 and 44aedeb.

Files selected for processing (1)
  • .github/workflows/pr-reminder.yml (1 hunks)
Additional context used
actionlint
.github/workflows/pr-reminder.yml

19-19: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

Additional comments not posted (3)
.github/workflows/pr-reminder.yml (3)

1-6: Consider removing the pull request trigger

The workflow name and schedule are well-defined. However, the pull request trigger (line 6) might be unnecessary for a reminder workflow that's intended to run on a schedule. Unless there's a specific reason to run the reminder immediately when a pull request is created or updated, consider removing this trigger to avoid potential noise or unnecessary executions.


8-9: LGTM: Appropriate permissions set

The workflow correctly sets read-only permissions for pull requests, which is sufficient for listing open PRs without modifying them.


12-16: Update checkout action to the latest version

The job setup looks good, running on the latest Ubuntu version. However, the actions/checkout action is using version 3, which is not the latest.

Consider updating to the latest version (v4) for potential improvements and bug fixes:

       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4

Comment on lines 18 to 40
- name: List open pull requests using GitHub Script
uses: actions/github-script@v5
id: pr-list
with:
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
draft: false
});

let table = '';
pullRequests.forEach(pr => {
const assignees = pr.assignees.length > 0 ? `Assignees: ${pr.assignees.map(assignee => assignee.login).join(', ')}` : 'No assignees';
table += `
Title: ${pr.title}
Link: <${pr.html_url}>
Assigness: ${assignees}
`;
});
return table;

Copy link
Contributor

Choose a reason for hiding this comment

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

Update GitHub Script action and improve code quality

The GitHub Script step logic is correct, but there are several improvements to be made:

  1. Update the actions/github-script action to the latest version.
  2. Fix the typo in the "Assignees" output.
  3. Improve the indentation in the table construction for better readability.

Apply the following changes:

-        uses: actions/github-script@v5
+        uses: actions/github-script@v7
         id: pr-list
         with:
           script: |
             const { data: pullRequests } = await github.rest.pulls.list({
               owner: context.repo.owner,
               repo: context.repo.repo,
               state: 'open',
               draft: false
             });

             let table = '';
             pullRequests.forEach(pr => {
               const assignees = pr.assignees.length > 0 ? `Assignees: ${pr.assignees.map(assignee => assignee.login).join(', ')}` : 'No assignees';
               table += `
-                      Title: ${pr.title}
-                      Link: <${pr.html_url}>
-                      Assigness: ${assignees}
-                      `;
+                Title: ${pr.title}
+                Link: <${pr.html_url}>
+                Assignees: ${assignees}
+
+              `;
             });
             return table;

These changes will update the action to the latest version, fix the typo, and improve the readability of the output.

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.

Suggested change
- name: List open pull requests using GitHub Script
uses: actions/github-script@v5
id: pr-list
with:
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
draft: false
});
let table = '';
pullRequests.forEach(pr => {
const assignees = pr.assignees.length > 0 ? `Assignees: ${pr.assignees.map(assignee => assignee.login).join(', ')}` : 'No assignees';
table += `
Title: ${pr.title}
Link: <${pr.html_url}>
Assigness: ${assignees}
`;
});
return table;
- name: List open pull requests using GitHub Script
uses: actions/github-script@v7
id: pr-list
with:
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
draft: false
});
let table = '';
pullRequests.forEach(pr => {
const assignees = pr.assignees.length > 0 ? `Assignees: ${pr.assignees.map(assignee => assignee.login).join(', ')}` : 'No assignees';
table += `
Title: ${pr.title}
Link: <${pr.html_url}>
Assignees: ${assignees}
`;
});
return table;
Tools
actionlint

19-19: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

.github/workflows/pr-reminder.yml Show resolved Hide resolved
.github/workflows/pr-reminder.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 44aedeb and e35e3a7.

Files selected for processing (1)
  • .github/workflows/pr-reminder.yml (1 hunks)
Additional context used
actionlint
.github/workflows/pr-reminder.yml

18-18: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

Additional comments not posted (2)
.github/workflows/pr-reminder.yml (2)

1-5: LGTM: Workflow name and trigger are well-defined

The workflow name accurately describes its purpose, and the schedule is appropriate for a daily reminder during the work week. The pull request trigger has been removed, which is correct for this type of reminder workflow.


17-39: ⚠️ Potential issue

Update GitHub Script action and improve code quality

The GitHub Script step logic is correct, but there are several improvements to be made:

  1. Update the actions/github-script action to the latest version.
  2. Fix the typo in the "Assignees" output.
  3. Improve the indentation in the table construction for better readability.

Apply the following changes:

-        uses: actions/github-script@v5
+        uses: actions/github-script@v7
         id: pr-list
         with:
           script: |
             const { data: pullRequests } = await github.rest.pulls.list({
               owner: context.repo.owner,
               repo: context.repo.repo,
               state: 'open',
               draft: false
             });

             let table = '';
             pullRequests.forEach(pr => {
               const assignees = pr.assignees.length > 0 ? `Assignees: ${pr.assignees.map(assignee => assignee.login).join(', ')}` : 'No assignees';
               table += `
-                      Title: ${pr.title}
-                      Link: <${pr.html_url}>
-                      Assigness: ${assignees}
-                      `;
+                Title: ${pr.title}
+                Link: <${pr.html_url}>
+                Assignees: ${assignees}
+
+              `;
             });
             return table;

These changes will update the action to the latest version, fix the typo, and improve the readability of the output.

Regarding the comment about draft PRs being included, let's verify if the filter is working correctly:

If you'd like to skip PRs without assignees, we can discuss adding this feature. It would require modifying the script to filter out PRs without assignees before adding them to the table.

Verification successful

Draft PRs are correctly excluded from the list

The pr-reminder.yml workflow properly excludes draft pull requests by setting draft: false in the GitHub API call. No draft PRs are included in the listed reminders.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that draft PRs are excluded from the list

# Test: Search for the draft filter in the GitHub API call
rg --type yaml 'draft: false' .github/workflows/pr-reminder.yml

# Test: Check if there are any occurrences where draft PRs might be included
rg --type yaml 'draft: true' .github/workflows/pr-reminder.yml

Length of output: 157

Tools
actionlint

18-18: the runner of "actions/github-script@v5" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

Comment on lines 40 to 53
- name: Send Slack Reminder
if: steps.pr-list.outputs.result != ''
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: pr-github
SLACK_USERNAME: PR-Reminder
MSG_MINIMAL: true
SLACK_ICON_EMOJI: ":think:"
SLACK_COLOR: good
SLACKIFY_MARKDOWN: true
SLACK_TITLE: Daily Pull Request Review Reminder
SLACK_MESSAGE: |
${{ steps.pr-list.outputs.result }}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Enhance Slack notification step

The Slack notification step needs some improvements:

  1. Update the rtCamp/action-slack-notify action to the latest stable version.
  2. Fix the environment variable name for minimal output.
  3. Enhance the message with more context, such as the total number of open PRs.

Apply the following changes:

  1. Update the action version:
-        uses: rtCamp/[email protected]
+        uses: rtCamp/[email protected]
  1. Fix the environment variable name:
-          MSG_MINIMAL: true
+          SG_MINIMAL: true
  1. Add a step to count the total number of open PRs and enhance the message:
      - name: Count open pull requests
        id: pr-count
        uses: actions/github-script@v7
        with:
          script: |
            const { data: pullRequests } = await github.rest.pulls.list({
              owner: context.repo.owner,
              repo: context.repo.repo,
              state: 'open',
              draft: false
            });
            return pullRequests.length.toString();

      - name: Send Slack Reminder
        if: steps.pr-list.outputs.result != ''
        uses: rtCamp/[email protected]
        env:
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
          SLACK_CHANNEL: pr-github
          SLACK_USERNAME: PR-Reminder
          SG_MINIMAL: true
          SLACK_ICON_EMOJI: ":think:"
          SLACK_COLOR: good
          SLACKIFY_MARKDOWN: true
          SLACK_TITLE: Daily Pull Request Review Reminder
          SLACK_MESSAGE: |
            There are currently ${{ steps.pr-count.outputs.result }} open pull requests requiring review:

            ${{ steps.pr-list.outputs.result }}

These changes will update the action to the latest stable version, fix the environment variable name, and provide more context in the Slack message, making it more informative for the team.

Comment on lines 7 to 15
permissions:
pull-requests: read

jobs:
pr-review:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update checkout action to the latest version

The job setup and permissions look good. However, consider updating the actions/checkout action to the latest version for potential improvements and bug fixes:

       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
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.

Suggested change
permissions:
pull-requests: read
jobs:
pr-review:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
permissions:
pull-requests: read
jobs:
pr-review:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

@tac0turtle tac0turtle added this pull request to the merge queue Sep 25, 2024
Merged via the queue into main with commit e52d3b1 Sep 25, 2024
68 checks passed
@tac0turtle tac0turtle deleted the marko/prreminder branch September 25, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants