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 Script to Generate CONTRIBUTORS.md with Shields.io Badges Based on Merged PRs #600

Merged
merged 2 commits into from
Sep 5, 2024

Conversation

dylanpulver
Copy link
Collaborator

@dylanpulver dylanpulver commented Sep 4, 2024

This PR introduces two new files:

1. generate_contributors.py:

  • Automates the process of generating a CONTRIBUTORS.md file based on merged pull requests in the pyupio/safety repository.
  • Uses the GitHub API to fetch closed and merged PRs and categorizes contributors into three tiers:
    • Valued Contributor (10+ PRs)
    • Frequent Contributor (5-9 PRs)
    • First Contributor (1-4 PRs)
  • Generates personalized Shields.io badges for each contributor and lists them under the appropriate tier in CONTRIBUTORS.md.
    • Each badge indicates the contributor's username and tier.

2. CONTRIBUTORS.md:

  • Contains a categorized list of contributors with badges based on their contribution levels.
  • This file will be automatically updated by running generate_contributors.py to reflect the latest contributions.
    This addition aims to recognize and showcase contributors in a visually engaging way while encouraging further community involvement.

Summary by CodeRabbit

  • New Features
    • Introduced a new section in the CONTRIBUTORS.md file to acknowledge contributors with badges, enhancing community recognition.
    • Automated generation of the CONTRIBUTORS.md file to streamline contributor acknowledgment based on merged pull requests.

Copy link

coderabbitai bot commented Sep 4, 2024

Walkthrough

This update introduces a new section in CONTRIBUTORS.md that categorizes contributors into "Valued Contributor," "Frequent Contributor," and "First Contributor," displaying their usernames and merged pull request counts with visually distinct badges. Additionally, a new script, generate_contributors.py, automates the generation of this file by retrieving merged pull request data from a GitHub repository and categorizing contributors based on their contributions.

Changes

File Change Summary
CONTRIBUTORS.md Added a new section for contributors, including categories "Valued Contributor," "Frequent Contributor," and "First Contributor" with badges.
scripts/generate_contributors.py Introduced a script to automate the generation of CONTRIBUTORS.md, including functions for fetching merged PRs, counting contributions, categorizing contributors, generating badges, and writing the markdown file.

Poem

🐇 In the meadow, hop and play,
New badges shine, bright as day!
Contributors, come take a bow,
Your hard work shows, we cheer you now!
Together we build, side by side,
In this project, let’s take pride! 🌼


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 01c2c28 and 645f98f.

Files selected for processing (2)
  • CONTRIBUTORS.md (1 hunks)
  • scripts/generate_contributors.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • CONTRIBUTORS.md
Additional comments not posted (10)
scripts/generate_contributors.py (10)

1-4: LGTM!

The imports are correct and necessary for the script.


5-12: LGTM!

The constants are correctly defined and using an environment variable for the GitHub token is a good practice.


14-21: LGTM!

The get_merged_prs function is correctly implemented and handles potential API errors.


23-31: LGTM!

The count_contributions function is correctly implemented and using a defaultdict simplifies the code.


33-42: LGTM!

The categorize_contributors function is correctly implemented and uses a dictionary comprehension for conciseness. Breaking out of the loop ensures that each contributor is assigned to only one tier.


44-48: LGTM!

The generate_badge function is correctly implemented and replaces certain characters to ensure a valid URL.


50-60: LGTM!

The generate_contributors_md function is correctly implemented. Sorting the contributors based on their contribution count in descending order and generating the markdown content by appending lines to a list are effective approaches.


62-66: LGTM!

The write_contributors_file function is correctly implemented.


68-75: LGTM!

The main function is correctly implemented and orchestrates the execution of the script.


77-78: LGTM!

The code segment correctly checks if the script is being run as the main program and calls the main function.

Copy link

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 645f98f and d08179b.

Files selected for processing (2)
  • CONTRIBUTORS.md (1 hunks)
  • scripts/generate_contributors.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • scripts/generate_contributors.py
Files skipped from review as they are similar to previous changes (1)
  • CONTRIBUTORS.md

@dylanpulver dylanpulver merged commit af7fa27 into main Sep 5, 2024
12 checks passed
@dylanpulver dylanpulver deleted the feature/contributor-script branch September 5, 2024 20:55
@coderabbitai coderabbitai bot mentioned this pull request Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants