Skip to content

Commit

Permalink
chore(ci): Add labels to PRs based on LoC / num files changed (#31729)
Browse files Browse the repository at this point in the history
* chore(ci): Add labels to PRs based on LoC / num files changed

* chore(ci): Make label-by-size depend on label by path, only run on opened & syncd PRs against main
  • Loading branch information
bsmth committed Jan 16, 2024
1 parent e92c979 commit 99a0911
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
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

0 comments on commit 99a0911

Please sign in to comment.