2.12.0 • Published 3 months ago

pull-request-stats v2.12.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

Pull Request Stats

CI GitHub Marketplace

Github action to print relevant stats about Pull Request reviewers.

The objective of this action is to:

  • Reduce the time taken to review the pull requests.
  • Encourage quality on reviews.
  • Help to decide which people to assign as reviewers.

Running this action will add a section at the bottom of your pull requests description:

npm.io

Each reviewer has a link pointing to their historical behavior of each reviewer:

npm.io

Or send the data to your favorite tools by using the integrations available:

SlackMS TeamsWebhooks

Privacy

  • No repository data is collected, stored, or distributed by this GitHub action. This action is state-less.
  • Charts data is sent over the URL and never stored or transmitted anywhere else.
  • Minimal data is sent to Mixpanel in order to improve this action. However, you can opt-out using the telemetry option.

Usage

Just add this action to one of your workflow files:

      - name: Run pull request stats
        uses: flowwer-dev/pull-request-stats@master

Action inputs

The possible inputs for this action are:

ParameterDescriptionDefault
tokenA Personal Access Token with repo permissions. Required to calculate stats for an organization or multiple repos.GITHUB_TOKEN
repositoriesA comma-separated list of GitHub repositories to calculate the stats, e.g. username/repo1,username/repo2. When specifying other repo(s), it is mandatory to pass a Personal Access Token in the token parameter.Current repository
organizationIf you prefer, you may specify your organization's name to calculate the stats across all of its repos. When specifying an organization, it is mandatory to pass a Personal Access Token in the token parameter.null
periodThe period used to calculate the stats, expressed in days.30
limitThe maximum number of rows to display in the table. A value of 0 means unlimited.0
chartsWhether to add a chart to the start. Possible values: true or false.false
disableLinksIf true, removes the links to the detailed charts. Possible values: true or false.false
sortByThe column used to sort the data. Possible values: REVIEWS, TIME, COMMENTS.REVIEWS
publishAsWhere to publish the results. Possible values: as a COMMENT, on the pull request DESCRIPTION, or publish NONE.COMMENT
telemetryIndicates if the action is allowed to send monitoring data to the developer. This data is minimal and helps me improve this action. This option is a premium feature reserved for sponsors.true
slackWebhook🔥 New. A Slack webhook URL to post resulting stats. This option is a premium feature reserved for sponsors. See full documentation here.null
slackChannelThe Slack channel where stats will be posted. Include the # character (eg. #mychannel). Required when a slackWebhook is configured.null
teamsWebhook🔥 New. A Microsoft Teams webhook URL to post resulting stats. This option is a premium feature reserved for sponsors. See full documentation here.null
webhook🔥 New. A webhook URL to send the resulting stats as JSON (integrate with Zapier, IFTTT...). See full documentation here.null

Action outputs

This action outputs the following variables:

VariableDescription
resultsMdThe resulting stats stored as a step output variable in Markdown format.
resultsJsonThe resulting stats stored as a step output variable in JSON format.

Examples

Minimal config

Add this to the file .github/workflows/stats.yml in your repo:

name: Pull Request Stats

on:
  pull_request:
    types: [opened]

jobs:
  stats:
    runs-on: ubuntu-latest
    steps:
      - name: Run pull request stats
        uses: flowwer-dev/pull-request-stats@master

This config will:

  • Calculate the reviewer stats for the current repo in the lasts 30 days.
  • Add links to the historical data.
  • Sort results by the "total reviews" column by default.

and print a table like this:

UserTotal reviewsMedian time to reviewTotal comments
jartmez3722m13
manuelmhtr3548m96
ernestognw251h 27m63
javierbyte1230m0
Phaze1D434m1

Visual config

Add this to the file .github/workflows/stats.yml:

name: Pull Request Stats

on:
  pull_request:
    types: [opened]

jobs:
  stats:
    runs-on: ubuntu-latest
    steps:
      - name: Run pull request stats
        uses: flowwer-dev/pull-request-stats@master
        with:
          token: ${{ secrets.ADD_A_PERSONAL_ACCESS_TOKEN }}
          organization: 'piedpiper'
          period: 7
          charts: true
          disableLinks: true
          sortBy: 'COMMENTS'

This config will:

  • Calculate the reviewer stats for all the repos in the "piedpiper" organization in the lasts 7 days.
  • Display charts for the metrics.
  • Remove the links to detailed charts.
  • Sort results by the "comments" column.

and print a table like this:

UserTotal commentsTotal reviewsMedian time to review
manuelmhtr🥇12▀▀▀▀▀▀▀▀8▀▀▀▀53m
jartmez🥈3▀▀4▀▀58m
JohanAlvarado🥉121d 16h 18m▀▀▀▀▀▀
Estebes101119m
ernestognw022h 15m
Phaze1D031h 28m
javierbyte0121h 24m▀▀▀

Stats

The stats are calculated as follows:

  • Time to review: The time a reviewer takes from the Pull Request publication or the last Commit push (whatever happens last) to the first time the pull request is reviewed.
  • Time to review: The median of the times to review of all Pull Requests reviewed by a person in the period.
  • Total reviews: The count of all Pull Requests reviewed by a person in the period.
  • Total comments: The count of all the comments while reviewing other users' Pull Requests in the period (comments in own PRs don't count).

Integrations 🔌

Check the guide for the tool you want to integrate:

Troubleshooting

  1. Make sure the repositories have pull request reviews during the configured period.
  2. When specifying repositories or organization parameters, a Personal Access Token is required in the token parameter.
  3. If providing a Personal Access Token, ensure it has the repo permission for the projects you want.

This error happens when the organization configures the action's permissions as read. To fix it, overwrite them by adding a permissions configuration in the workflow file. The minimum required permissions are contents: read and pull-requests: write:

jobs:
  stats:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - name: Run pull request stats
        uses: flowwer-dev/pull-request-stats@master
  1. Check the sponsorship comes from the account that owns the configured repos (usually an organization).
  2. Make sure the sponsorship is configured as public, otherwise, the action cannot access the sponsorship information. If you prefer to keep it private, please reach me out to make it work for you that way 😉.

Premium features ✨

This action offers some premium features only for sponsors:

  • Disabling telemetry.
  • Slack integration.
  • Microsoft Teams integration.
  • Coming soon: Discord integration, web version.

The suggested sponsorship is $20 USD / month. However, if it's not possible for you or your organization, please consider supporting it with any amount you can. Even a one-time sponsorship will enable the Premium features and encourage the progress of this project.

Being a sponsor will also give you access to the premium features in all of my other projects.

Thanks for your support! 💙

Related projects 🔥

  • Recap: Tired of writing pull request descriptions? Let GPT do it for you.

Used by

Used by hundreds of successful teams:

SixtLululemonDelivery HJOKRLegoLOOPHatchZenfi
IntelAuth0AdditionFaunaCDCWecasaBoltRepublic

Author

@manuelmhtr🇲🇽 Guadalajara, MX

Help

This project is maintained by a single person, considering supporting the project by:

License

MIT