Skip to content

Commit

Permalink
v3.0.0: More customizable with the new stats column
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmhtr committed Dec 12, 2024
2 parents 0dde6ed + e92c081 commit 593c720
Show file tree
Hide file tree
Showing 116 changed files with 7,616 additions and 4,444 deletions.
20 changes: 0 additions & 20 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: yarn

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: yarn

- run: yarn install
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Changelog
All notable changes to this project will be documented in this file.

## [3.0.0] - 2024-12-12
### Added
- New `stats` option to specify the stats to be calculated.

### Breaking changes
- Deprecated the kebab case options: `publish-as`, `disable-links`, `sort-by`, `slack-webhook`, `slack-channel` and `teams-webhook`. Now you need to use the camel case format: `publishAs`, `disableLinks`, `sortBy`, `slackWebhook`, `slackChannel` and `teamsWebhook`.`
- The values for `sortBy` have changed. `REVIEWS`, `TIME`, `COMMENTS` are invalid. Now you need to use the full name of the stat that will be used for sorting, for example: `totalComments`, `timeToReview`...
- The JSON output for the action and the JSON payload for the webhook have changed. Check the new format in the [webhook documentation](/docs/webhook.md).
- Renamed branch `master` to `main`.

## [2.15.2] - 2024-12-01
### Fixed
- Prevents `githubToken` and `personalToken` from be included in the JSON output.
Expand Down
60 changes: 32 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Just add this action to one of your [workflow files](https://docs.github.com/en/

```yml
- name: Run pull request stats
uses: flowwer-dev/pull-request-stats@master
uses: flowwer-dev/pull-request-stats@main
```
If you are getting an empty table or an error, check the [troubleshooting section](#troubleshooting).
Expand All @@ -45,23 +45,24 @@ If you are getting an empty table or an error, check the [troubleshooting sectio
The possible inputs for this action are:
| Parameter | Description | Default |
| --------- | ----------- | ------- |
| `token` | A [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with `repo` permissions. Required to calculate stats for an organization or multiple repos. | `GITHUB_TOKEN` |
| `repositories` | A 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 |
| `organization` | If 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` |
| `period` | The period used to calculate the stats, expressed in days. | `30` |
| `limit` | The maximum number of rows to display in the table. A value of `0` means unlimited. | `0` |
| `charts` | Whether to add a chart to the start. Possible values: `true` or `false`. | `false` |
| `disableLinks` | If `true`, removes the links to the detailed charts. Possible values: `true` or `false`. | `false` |
| `sortBy` | The column used to sort the data. Possible values: `REVIEWS`, `TIME`, `COMMENTS`. | `REVIEWS` |
| `publishAs` | Where to publish the results. Possible values: as a `COMMENT`, on the pull request `DESCRIPTION`, or publish `NONE`. | `COMMENT` |
| `exclude` | A comma-separated list of usernames (case-insensitive) to be excluded from the results (e.g. `username1,username2`), or a regular expression enclosed between slashes (eg. `/^bot/i` will exclude all usernames that begin with "bot"). | `null` |
| `telemetry` | Indicates if the action is allowed to send monitoring data to the developer. This data is [minimal](/src/services/telemetry/sendStart.js) and helps me improve this action. **This option is a premium feature reserved for [sponsors](#premium-features-).** |`true`|
| `slackWebhook` | **🔥 New.** A Slack webhook URL to post resulting stats. **This option is a premium feature reserved for [sponsors](#premium-features-).** See [full documentation here](/docs/slack.md). | `null` |
| `slackChannel` | The 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](#premium-features-).** See [full documentation here](/docs/teams.md). | `null` |
| `webhook` | **🔥 New.** A webhook URL to send the resulting stats as JSON (integrate with Zapier, IFTTT...). See [full documentation here](/docs/webhook.md). | `null` |
| Parameter | Description | Default |
|-----------------|---------------------------------------------------------------------------------------------------------------|-------------------|
| `token` | A [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with `repo` permissions. Required to calculate stats for an organization or multiple repositories. | `GITHUB_TOKEN` |
| `repositories` | A comma-separated list of GitHub repositories to calculate the stats, e.g. `username/repo1,username/repo2`. If no repositories are specified, the action defaults to the repository where the workflow is running. When specifying other repo(s), **it is mandatory to pass a Personal Access Token** in the `token` parameter. | Current repository |
| `organization` | If you prefer, you may specify your organization's name to calculate the stats across all of its repositories. When specifying an organization, **it is mandatory to pass a Personal Access Token** in the `token` parameter. | `null` |
| `period` | The period used to calculate the stats, expressed in days. | `30` |
| `limit` | The maximum number of rows to display in the table. A value of `0` means unlimited. | `0` |
| `stats` | A comma-separated list of stats to calculate and display. Possible values: `totalReviews`, `timeToReview`, `totalComments`, `commentsPerReview`, `openedPullRequests`. For details on each stats check the [Stats](#stats) section. | `totalReviews,timeToReview,totalComments` |
| `charts` | Whether to add a chart to the start. Possible values: `true` or `false`. | `false` |
| `disableLinks` | If `true`, removes the links to the detailed charts. Possible values: `true` or `false`. | `false` |
| `sortBy` | The column used to sort the data. Possible values: `totalReviews`, `timeToReview`, `totalComments`, `commentsPerReview`, `openedPullRequests`. | `totalReviews` |
| `publishAs` | Where to publish the results. Possible values: `COMMENT`, `DESCRIPTION`, or `NONE`. | `COMMENT` |
| `exclude` | A comma-separated list of usernames (case-insensitive) to be excluded from the results (e.g. `username1,username2`), or a regular expression enclosed between slashes (e.g. `/^bot/i` will exclude all usernames that begin with "bot"). | `null` |
| `telemetry` | Indicates if the action is allowed to send monitoring data to the developer. This data is [minimal](/src/services/telemetry/sendStart.js) and helps improve this action. **This option is a premium feature reserved for [sponsors](#premium-features-).** | `true` |
| `slackWebhook` | A Slack webhook URL to post resulting stats. **This option is a premium feature reserved for [sponsors](#premium-features-).** See [full documentation here](/docs/slack.md). | `null` |
| `slackChannel` | The Slack channel where stats will be posted. Include the `#` character (e.g. `#mychannel`). Required when a `slackWebhook` is configured. | `null` |
| `teamsWebhook` | A Microsoft Teams webhook URL to post resulting stats. **This option is a premium feature reserved for [sponsors](#premium-features-).** See [full documentation here](/docs/teams.md). | `null` |
| `webhook` | A webhook URL to send the resulting stats as JSON (integrate with Zapier, IFTTT...). See [full documentation here](/docs/webhook.md). | `null` |


### Action outputs
Expand Down Expand Up @@ -92,7 +93,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Run pull request stats
uses: flowwer-dev/pull-request-stats@master
uses: flowwer-dev/pull-request-stats@main
```

This config will:
Expand Down Expand Up @@ -128,22 +129,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Run pull request stats
uses: flowwer-dev/pull-request-stats@master
uses: flowwer-dev/pull-request-stats@main
with:
token: ${{ secrets.ADD_A_PERSONAL_ACCESS_TOKEN }}
organization: 'piedpiper'
period: 7
charts: true
disableLinks: true
sortBy: 'COMMENTS'
sortBy: 'totalComments'
stats: 'totalComments,openedPullRequests'
```

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.
* Sort results by the "Total comments" column.
* Show the "Total comments" and "Opened pull requests" columns (in that order).

and print a table like this:

Expand All @@ -161,10 +164,11 @@ and print a table like this:

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 number of comments made while reviewing other users' Pull Requests during the specified period. Comments made on your own PRs or general PR discussions are excluded; only comments directly related to code are counted.
* **Total reviews (`totalReviews`):** The count of all Pull Requests reviewed by a person in the period.
* **Time to review (`timeToReview`):** The **median** 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.
* **Total comments (`totalComments`):** The number of comments made while reviewing other users' Pull Requests during the specified period. Comments made on your own PRs or general PR discussions are excluded; only comments directly related to code are counted.
* **Comments per review (`commentsPerReview`):** The **average** comments the reviewer made on the pull requests.
* **Opened pull requests (`openedPullRequests`):** The number of pull requests opened by the user in the period.

## Integrations 🔌

Expand Down Expand Up @@ -193,7 +197,7 @@ Check the guide for the tool you want to integrate:
pull-requests: write
steps:
- name: Run pull request stats
uses: flowwer-dev/pull-request-stats@master
uses: flowwer-dev/pull-request-stats@main
```
</details>

Expand All @@ -211,7 +215,7 @@ Check the guide for the tool you want to integrate:
pull-requests: write
steps:
- name: Run pull request stats
uses: flowwer-dev/pull-request-stats@master
uses: flowwer-dev/pull-request-stats@main
```
</details>

Expand Down
6 changes: 4 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ inputs:
description: 'The maximum number of rows to display in the table. A value of `0` means unlimited.'
required: false
default: 0
stats:
description: 'A comma separated list of the stats to be calculated and displayed.'
required: false
charts:
description: 'Whether to add charts to the stats or not. Possible values: "true" or "false"'
required: false
default: 'false'
sortBy:
description: 'The column used to sort the data. Possible values: "REVIEWS", "TIME" or "COMMENTS"'
description: 'The column used to sort the data.'
required: false
default: 'REVIEWS'
publishAs:
description: 'Where to publish the results. Possible values: "COMMENT", "DESCRIPTION" or "NONE"'
required: false
Expand Down
Loading

0 comments on commit 593c720

Please sign in to comment.