A GitHub Action that automatically estimates the time required to review a pull request and adds an appropriate time-based label.
This action analyzes pull requests and applies labels like 1 min review
, 5 min review
, etc., to help reviewers prioritize their work. It considers several factors:
- Number of files changed
- Lines of code added and deleted
- File complexity based on file extensions
- Quality of commit messages (Conventional Commits check)
- Size of individual commits
- Quality of pull request description
- Commit type (feat, fix, refactor, revert, docs)
- Documentation and metadata file changes
-
Documentation and metadata files: Pull requests containing only documentation or metadata files are automatically assigned the minimum review time (1 minute). In mixed PRs, changes to documentation files are weighted at only 20% compared to code changes.
-
Commit types: Different commit types receive different review time weights:
feat
: +2 minutes (new features need more review time)fix
: +1.5 minutes (bug fixes need careful review)refactor
: +2.5 minutes (refactorings need thorough review)revert
: +1 minute (reverts typically need less review time)docs
: +0.5 minutes (documentation changes need minimal review)
Add this to your workflow file (e.g., .github/workflows/time-to-review.yml
):
name: Time to Review
on:
pull_request:
types: [opened, synchronize]
jobs:
time-to-review:
runs-on: ubuntu-latest
name: Calculate review time
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Calculate review time
uses: srajasimman/time-to-review@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
The action will add one of the following labels to your pull request:
1 min review
(🟢 Green)5 min review
(🟡 Yellow)10 min review
(🟡 Yellow)15 min review
(🔴 Red)20 min review
(🔴 Red)30 min review
(🔴 Red)
The labels are color-coded for quick visual priority assessment:
- Green: Quick reviews (1 minute)
- Yellow: Medium reviews (5-10 minutes)
- Red: Longer reviews (>10 minutes)
This project is licensed under the MIT License. See the LICENSE file for details.