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

chore(ci): Add labels to PRs based on LoC / num files changed #31729

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/pull-request-size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Configuration for PR Size Labeler

# List of files to exclude from size calculation
# Files matching these patterns will not be considered when calculating PR size
exclude_files:
- "files/en-us/_redirects.txt"
- "files/en-us/_wikihistory.json"

# Configuration for labeling based on the size of the Pull Request
# Each entry defines a size label, along with thresholds for diff and file count
label_configs:
# Configuration for 'extra small' PRs
- size: xs
diff: 10 # Threshold for the total lines of code changed (additions + deletions)
files: 1 # Threshold for the total number of files changed
labels: ["size/xs"] # Labels to be applied for this size

# Configuration for 'small' PRs
- size: s
diff: 25
files: 5
labels: ["size/s"]

# Configuration for 'medium' PRs
- size: m
diff: 100
files: 10
# Additional labels can be added, e.g.;
# labels: ["size/m", "pairing-wanted"]
labels: ["size/m"]

# Configuration for 'large' PRs
- size: l
diff: 250
files: 25
labels: ["size/l"]

# Configuration for 'extra large' PRs
- size: xl
diff: 500
files: 50
labels: ["size/xl"]
29 changes: 26 additions & 3 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
name: "Pull request labeler"
name: Pull request labeler

on:
- pull_request_target
pull_request:
types: [opened, synchronize]
branches:
- "main"

jobs:
triage:
# Docs: https://github.com/actions/labeler
label-by-path:
# do not run on forks
if: github.repository == 'mdn/content'
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

# Docs: https://github.com/cbrgm/pr-size-labeler-action
label-by-size:
# do not run on forks
if: github.repository == 'mdn/content'
needs: label-by-path
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Label PR based on size
uses: cbrgm/pr-size-labeler-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repository: ${{ github.repository }} # Repository name
github_pr_number: ${{ github.event.number }} # Pull request number
config_file_path: ".github/pull-request-size.yml" # Path to pr-size-labeler config
Loading