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

Add generate PR description workflow #3042

Closed
wants to merge 12 commits into from

Conversation

htahir1
Copy link
Contributor

@htahir1 htahir1 commented Sep 24, 2024

Describe changes

Pull Request Description

This PR introduces a new GitHub Actions workflow and a script for automating pull request description generation.

  • Added .github/workflows/generate-pr-description.yml: This file sets up a GitHub Actions workflow to run the PR description generation script.
  • Added scripts/generate_pr_description.py: This script generates concise and informative pull request descriptions based on the changes made in the repository.

These additions aim to streamline the pull request process and improve clarity in PR documentation.

Pre-requisites

Please ensure you have done the following:

  • I have read the CONTRIBUTING.md document.
  • If my change requires a change to docs, I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • I have based my new branch on develop and the open PR is targeting develop. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop.
  • If my changes require changes to the dashboard, these changes are communicated/requested.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Other (add details above)

Summary by CodeRabbit

  • New Features

    • Introduced an automated workflow for generating pull request descriptions, enhancing management efficiency.
    • New script to create concise pull request summaries based on changes made, improving clarity for reviewers.
  • Bug Fixes

    • Implemented checks to avoid duplicate description generation on pull requests.

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Walkthrough

A new GitHub Actions workflow, generate-pr-description.yml, has been introduced to automate the generation of pull request descriptions. This workflow is triggered by pull request events and includes a concurrency control mechanism. Additionally, a Python script, generate_pr_description.py, has been created to generate PR descriptions based on file changes. It checks for existing descriptions, categorizes changes, and uses the OpenAI API to generate concise summaries.

Changes

File Path Change Summary
.github/workflows/generate-pr-description.yml Added a new GitHub Actions workflow to automate pull request description generation.
scripts/generate_pr_description.py Introduced a script to generate PR descriptions based on file changes, including new methods.

Poem

In the garden of code, a new path we weave,
With workflows and scripts, oh, what we achieve!
Descriptions now sprout, like flowers in bloom,
Automating the process, dispelling the gloom.
Hops of delight, as changes take flight,
A rabbit's soft cheer for the code shining bright! 🐇✨


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.

@github-actions github-actions bot added internal To filter out internal PRs and issues enhancement New feature or request labels Sep 24, 2024
@strickvl
Copy link
Contributor

Doesn't @coderabbitai do this already?

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Tip

For best results, initiate chat on the files or code changes.

@strickvl, yes, CodeRabbit can automatically generate PR descriptions if it's configured to do so. According to your current configuration, the high_level_summary feature is enabled. To use this feature, include the placeholder @coderabbitai summary in your PR description, and CodeRabbit will replace it with an automatically generated summary of your changes.

Additionally, you can use the auto_title_placeholder by setting your PR title to @coderabbitai, and CodeRabbit will generate a title for you based on the content of your PR.

Let me know if you have any questions or need further assistance!

Analysis chain

@strickvl, you're correct—CodeRabbit can automatically generate PR descriptions if it's configured to do so. Let me check the current configuration to see if this feature is enabled for this repository.

Scripts executed

The following scripts were executed for the analysis:


Debug Information Gathered

@htahir1
Copy link
Contributor Author

htahir1 commented Sep 24, 2024

@strickvl can you show me how? Maybe I missed how it does it for sure!

@strickvl
Copy link
Contributor

@coderabbitai review

@htahir1
Copy link
Contributor Author

htahir1 commented Sep 24, 2024

@coderabbitai summary

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Actions performed

Summary regeneration triggered.

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: 7

Outside diff range and nitpick comments (5)
.github/workflows/generate-pr-description.yml (1)

11-18: Job setup and permissions look good, with a minor suggestion.

The job configuration is well-structured:

  • Running only on non-draft PRs is efficient.
  • The permissions are correctly set for the required operations.

Consider adding a comment explaining why these specific permissions are needed. This can help future maintainers understand the security implications:

permissions:
  contents: read  # Needed to check out the repository
  pull-requests: write  # Needed to update the PR description
  issues: write  # Needed to add comments to the PR
scripts/generate_pr_description.py (4)

1-5: Add a module docstring and consider organizing imports.

The imports look good and are necessary for the script's functionality. However, consider adding a module docstring to explain the purpose of this script.

Consider adding a module docstring at the beginning of the file:

"""
This module generates pull request descriptions automatically based on file changes in a GitHub repository.
It uses the GitHub API to fetch PR information and the OpenAI API to generate descriptions.
"""

Also, consider organizing imports according to PEP 8 guidelines:

import os

import openai
import requests
Tools
Ruff

1-1: Missing docstring in public module

(D100)


7-21: Approve function with suggestion for improved docstring.

The truncate_changes function is well-implemented and serves its purpose effectively. It ensures that the changes summary doesn't exceed the maximum character limit while maintaining readability.

Consider expanding the docstring to provide more details about the function's behavior:

def truncate_changes(changes_summary):
    """
    Truncates the changes summary to fit within MAX_CHARS.

    Args:
    changes_summary (list): A list of strings representing changes.

    Returns:
    list: A truncated list of changes, ensuring the total character count
          doesn't exceed MAX_CHARS. If truncation occurs, the last included
          change will end with "...".
    """

90-91: Approve main block with suggestion for error handling.

The main execution block is correct and straightforward. However, it could benefit from basic error handling to catch and log any unexpected exceptions.

Consider adding error handling to the main block:

if __name__ == "__main__":
    try:
        result = generate_pr_description()
        if result:
            print("PR description updated successfully.")
        else:
            print("No changes were made to the PR description.")
    except Exception as e:
        print(f"An error occurred: {e}")

1-91: Overall assessment: Good implementation with room for improvement.

The script successfully implements PR description generation using GitHub and OpenAI APIs. It handles file changes, truncates long summaries, and updates PR descriptions effectively. The overall structure and logic are sound.

However, there are several areas for improvement:

  1. Error handling: Add comprehensive error handling for API calls and potential exceptions.
  2. Code organization: Break down the generate_pr_description function into smaller, more focused functions.
  3. Security: Implement proper validation and error handling for environment variables.
  4. Documentation: Add more detailed docstrings to functions and the module.
  5. Type hints: Consider adding type hints to improve code readability and catch potential type-related errors.

To improve the overall architecture and maintainability of the script, consider:

  1. Creating a GitHubClient class to encapsulate GitHub API interactions.
  2. Implementing a PRDescriptionGenerator class to handle the main logic of generating and updating PR descriptions.
  3. Using a configuration file or environment variables with proper validation for API keys and other sensitive information.
  4. Implementing logging instead of using print statements for better debugging and monitoring.

Example structure:

class GitHubClient:
    # Handle GitHub API interactions

class PRDescriptionGenerator:
    # Handle PR description generation and updating

def main():
    # Set up clients and run the main logic

if __name__ == "__main__":
    main()

These changes would make the script more modular, easier to test, and more maintainable in the long run.

Tools
Ruff

1-1: Missing docstring in public module

(D100)


23-23: Missing docstring in public function

(D103)


25-25: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


26-26: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


27-27: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


28-28: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


28-28: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


29-29: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


33-33: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


33-33: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


40-40: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


46-46: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


47-47: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


49-49: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


51-51: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


53-53: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


54-54: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


57-57: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


57-57: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


61-61: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


69-69: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


79-79: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


82-82: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


84-84: f-string without any placeholders

Remove extraneous f prefix

(F541)

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 33dca27 and cee2803.

Files selected for processing (2)
  • .github/workflows/generate-pr-description.yml (1 hunks)
  • scripts/generate_pr_description.py (1 hunks)
Additional context used
actionlint
.github/workflows/generate-pr-description.yml

29-29: shellcheck reported issue in this script: SC2086:info:2:8: Double quote to prevent globbing and word splitting

(shellcheck)


36-36: shellcheck reported issue in this script: SC2086:info:5:23: Double quote to prevent globbing and word splitting

(shellcheck)


36-36: shellcheck reported issue in this script: SC2086:info:7:24: Double quote to prevent globbing and word splitting

(shellcheck)

Ruff
scripts/generate_pr_description.py

1-1: Missing docstring in public module

(D100)


23-23: Missing docstring in public function

(D103)


25-25: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


26-26: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


27-27: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


28-28: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


28-28: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


29-29: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


33-33: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


33-33: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


40-40: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


46-46: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


47-47: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


49-49: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


51-51: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


53-53: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


54-54: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


57-57: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


57-57: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


61-61: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


69-69: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


79-79: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


82-82: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


84-84: f-string without any placeholders

Remove extraneous f prefix

(F541)

Additional comments not posted (4)
.github/workflows/generate-pr-description.yml (4)

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

The workflow name "Auto PR Description" clearly describes its purpose, and the trigger events (pull request opened or edited) are appropriate for automatically generating PR descriptions.


7-9: Excellent use of concurrency settings.

The concurrency configuration effectively prevents race conditions by ensuring only one instance of the workflow runs per PR. Cancelling in-progress runs is a good practice to always process the latest changes.


20-26: Setup steps are well-configured.

The use of recent versions for both the checkout action (v4.1.1) and Python setup action (v5.0.0) is commendable. Python 3.11 is a good choice for its performance improvements and new features.


1-70: Overall, this is a well-structured workflow with some areas for improvement.

The "Auto PR Description" workflow is a creative solution for automating PR descriptions. Here's a summary of the main points:

  1. The workflow structure, triggers, and concurrency settings are well-defined.
  2. Consider standardizing the dependency installation process using a requirements.txt file.
  3. Address the shellcheck warnings by using double quotes in shell commands.
  4. Provide more information about the OpenAI API usage and consider adding error handling for API calls.
  5. Enhance the error checking step with more detailed troubleshooting information.

These improvements will make the workflow more robust, maintainable, and user-friendly. Great job on implementing this automated solution!

Tools
actionlint

29-29: shellcheck reported issue in this script: SC2086:info:2:8: Double quote to prevent globbing and word splitting

(shellcheck)


36-36: shellcheck reported issue in this script: SC2086:info:5:23: Double quote to prevent globbing and word splitting

(shellcheck)


36-36: shellcheck reported issue in this script: SC2086:info:7:24: Double quote to prevent globbing and word splitting

(shellcheck)

.github/workflows/generate-pr-description.yml Show resolved Hide resolved
.github/workflows/generate-pr-description.yml Show resolved Hide resolved
Comment on lines 34 to 57
- name: Check for previous successful run
id: check_comment
run: |
PR_NUMBER="${{ github.event.pull_request.number }}"
COMMENT=$(gh api -X GET "/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" | jq '.[] | select(.body | contains("Auto PR description generated successfully")) | .id')
if [ -n "$COMMENT" ]; then
echo "Workflow has already run successfully for this PR."
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Wait for potential edits
if: steps.check_comment.outputs.skip == 'false'
run: sleep 300 # Wait for 5 minutes

- name: Generate PR description
if: steps.check_comment.outputs.skip == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: python scripts/generate_pr_description.py
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Issues Identified in generate_pr_description.py:

  1. Incorrect OpenAI Model Name:

    • The script specifies the model as "gpt-4o-mini", which is likely a typo. It should be updated to a valid model name, such as "gpt-4".
  2. Lack of Error Handling:

    • The OpenAI API calls do not include error handling. This can lead to unhandled exceptions if the API request fails or returns an error.
    • Consider adding try-except blocks to manage potential errors gracefully.
  3. Rate Limiting and Retry Mechanism:

    • The script does not account for API rate limits or implement a retry mechanism. Implementing exponential backoff strategies can improve reliability.
  4. Excessive Truncation Limit:

    • MAX_CHARS is set to 400000, which may be unnecessarily high for PR descriptions. A more reasonable limit can ensure concise and relevant descriptions.

Category:

Analysis chain

Good workflow logic, but some improvements needed.

The steps for checking previous runs, waiting, and generating the PR description are well thought out. However, there are a few points to address:

  1. In the "Check for previous successful run" step, address the shellcheck warnings by using double quotes:

    run: |
      PR_NUMBER="${{ github.event.pull_request.number }}"
      COMMENT=$(gh api -X GET "/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" | jq '.[] | select(.body | contains("Auto PR description generated successfully")) | .id')
      if [ -n "$COMMENT" ]; then
        echo "Workflow has already run successfully for this PR."
        echo "skip=true" >> "$GITHUB_OUTPUT"
      else
        echo "skip=false" >> "$GITHUB_OUTPUT"
      fi
  2. The use of OpenAI's API for generating PR descriptions is intriguing.

Could you provide more information about how this is implemented? Here's a script to check the content of the Python script:

  1. Consider adding error handling and rate limiting considerations when using external APIs like OpenAI.

Would you like me to propose some error handling improvements for the Python script or open a GitHub issue to track this task?

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the content of the generate_pr_description.py script
cat scripts/generate_pr_description.py

Length of output: 3663

Tools
actionlint

36-36: shellcheck reported issue in this script: SC2086:info:5:23: Double quote to prevent globbing and word splitting

(shellcheck)


36-36: shellcheck reported issue in this script: SC2086:info:7:24: Double quote to prevent globbing and word splitting

(shellcheck)

scripts/generate_pr_description.py Show resolved Hide resolved
Comment on lines 25 to 29
token = os.environ['GITHUB_TOKEN']
repo = os.environ['GITHUB_REPOSITORY']
pr_number = os.environ['GITHUB_EVENT_NUMBER']
headers = {'Authorization': f'token {token}'}
api_url = f'https://api.github.com/repos/{repo}/pulls/{pr_number}'
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

Improve security and error handling for API setup.

The current implementation directly uses environment variables without any validation. This could lead to runtime errors if the variables are not set. Additionally, there's no error handling for the API calls.

Consider adding validation for environment variables and error handling:

import os
from typing import Dict

def get_github_headers() -> Dict[str, str]:
    token = os.environ.get('GITHUB_TOKEN')
    if not token:
        raise ValueError("GITHUB_TOKEN environment variable is not set")
    return {'Authorization': f'token {token}'}

def get_pr_api_url() -> str:
    repo = os.environ.get('GITHUB_REPOSITORY')
    pr_number = os.environ.get('GITHUB_EVENT_NUMBER')
    if not repo or not pr_number:
        raise ValueError("GITHUB_REPOSITORY or GITHUB_EVENT_NUMBER environment variable is not set")
    return f'https://api.github.com/repos/{repo}/pulls/{pr_number}'

# Use these functions in generate_pr_description()
headers = get_github_headers()
api_url = get_pr_api_url()
Tools
Ruff

25-25: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


26-26: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


27-27: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


28-28: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


28-28: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)


29-29: Single quotes found but double quotes preferred

Replace single quotes with double quotes

(Q000)

scripts/generate_pr_description.py Show resolved Hide resolved
scripts/generate_pr_description.py Show resolved Hide resolved
Copy link
Contributor

Auto PR description generated successfully

@htahir1
Copy link
Contributor Author

htahir1 commented Sep 24, 2024

Cant rely on coderabbit so id still ask @schustmi and @bcdurak to merge it in if they like it :-)

@schustmi
Copy link
Contributor

I hope this doesn't accidentally overwrite actual pr descriptions, but other than that at least it won't do any harm

@htahir1
Copy link
Contributor Author

htahir1 commented Sep 24, 2024

@schustmi actually this is my only concern. Im wondering how I can make that foolproof. Currently, it will only write if the default PR description is matched and if it hasn't successfully done it before... but there is an edge case that if somebody opens up a PR and then edits their PR description while this is running, there's a chance it gets overwritten

@schustmi
Copy link
Contributor

Yep exactly. One option would be to just run this when a certain tag is applied? Similar to the slow CI?

@htahir1
Copy link
Contributor Author

htahir1 commented Sep 24, 2024

@schustmi hmm but then nobody will do it I think :-( I like the automated feel of this. What I can do is that in the beginning of the script get the PR description, wait 5 mins, and then get it again and see if anything changes. This will mitigate but not eliminate the risk.

The other thing I can do is just append the auto generated description rather than replacing anything

@htahir1
Copy link
Contributor Author

htahir1 commented Sep 24, 2024

@schustmi added some logic for the latter option. check it out

@schustmi
Copy link
Contributor

Yeah let's see, still seems pretty fragile but only in some pretty rare cases

Copy link
Contributor

@bcdurak bcdurak left a comment

Choose a reason for hiding this comment

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

Looks nice as a concept. I would love to take it for a spin 😄

Since our PRs usually go through significant changes during development, I would love to have a mechanism in place that can also refresh the description.

Proposal for a solution: Perhaps we can change the trigger for the workflow. Instead of triggering it when the PR is opened, maybe we can trigger it with each change (or when it is marked ready for release). This would also solve some of the problem I mentioned in my comments.

filename = file['filename']
status = file['status']

if status == 'added':
Copy link
Contributor

Choose a reason for hiding this comment

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

Usually, if there is a new file, there is some meaningful code in there. That's why it might be nice to add the patch for the new files as well.

source $HOME/.cargo/env
uv pip install --system requests openai

- name: Check for previous successful run
Copy link
Contributor

Choose a reason for hiding this comment

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

This workflow would run only when the PR is opened. So, it will only be run once. That's why the step here does not make much sense. When it runs for the first and only time, the comment won't be there, and thus the code will execute.

jobs:
auto-describe:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
Copy link
Contributor

Choose a reason for hiding this comment

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

If I open the PR as a draft and then later change it to "Ready for Review", this code will not run again.

@htahir1 htahir1 closed this Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request internal To filter out internal PRs and issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants