mirror of
https://github.com/actions/labeler
synced 2026-05-05 03:07:49 +02:00
Add 'changed-files-labels-limit' and 'max-files-changed' configs to allow capping number of labels added (#923)
* README.md: drop trailing whitespace * Add 'changed-files-labels-limit' config to allow capping number of labels added When a repository has many components, each with a changed-files label, a large refactor ends up with the labeler spamming the pull request with label changes. The end result is not very useful as it's not very readable, and due to how github automatically hides comments when label changes overflow the discussion tab, it means useful information is hidden and one has to manually click "Load more..." dozens of time every time the page is loaded. Add a changed-files-labels-limit top level config knob. If more than the configured limit of labels is set to be added, none are added. This only affects changed-files labels. * Add 'max-files-changed' config to allow capping number of files for labelling When a PR modifies a very large number of files (e.g., tree-wide refactors, automated code formatting), this new options allows skipping file-based labeling entirely when the number of files that are changed hits the configured limit. Fixes https://github.com/actions/labeler/issues/486
This commit is contained in:
18
__tests__/fixtures/limit_0.yml
Normal file
18
__tests__/fixtures/limit_0.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
# Limit to 0 changed-files labels (none allowed)
|
||||
changed-files-labels-limit: 0
|
||||
|
||||
# Labels based on changed files
|
||||
component-a:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/a/**']
|
||||
|
||||
component-b:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/b/**']
|
||||
|
||||
# Labels based on branch patterns only
|
||||
test-branch:
|
||||
- head-branch: '^test/'
|
||||
|
||||
feature-branch:
|
||||
- head-branch: '/feature/'
|
||||
26
__tests__/fixtures/limit_1.yml
Normal file
26
__tests__/fixtures/limit_1.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
# Limit to 1 changed-files label
|
||||
changed-files-labels-limit: 1
|
||||
|
||||
# Labels based on changed files
|
||||
component-a:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/a/**']
|
||||
|
||||
component-b:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/b/**']
|
||||
|
||||
component-c:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/c/**']
|
||||
|
||||
component-d:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/d/**']
|
||||
|
||||
# Labels based on branch patterns only
|
||||
test-branch:
|
||||
- head-branch: '^test/'
|
||||
|
||||
feature-branch:
|
||||
- head-branch: '/feature/'
|
||||
26
__tests__/fixtures/limit_2.yml
Normal file
26
__tests__/fixtures/limit_2.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
# Limit to 2 changed-files labels
|
||||
changed-files-labels-limit: 2
|
||||
|
||||
# Labels based on changed files
|
||||
component-a:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/a/**']
|
||||
|
||||
component-b:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/b/**']
|
||||
|
||||
component-c:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/c/**']
|
||||
|
||||
component-d:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/d/**']
|
||||
|
||||
# Labels based on branch patterns only
|
||||
test-branch:
|
||||
- head-branch: '^test/'
|
||||
|
||||
feature-branch:
|
||||
- head-branch: '/feature/'
|
||||
26
__tests__/fixtures/limit_3.yml
Normal file
26
__tests__/fixtures/limit_3.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
# Limit to 3 changed-files labels
|
||||
changed-files-labels-limit: 3
|
||||
|
||||
# Labels based on changed files
|
||||
component-a:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/a/**']
|
||||
|
||||
component-b:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/b/**']
|
||||
|
||||
component-c:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/c/**']
|
||||
|
||||
component-d:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/d/**']
|
||||
|
||||
# Labels based on branch patterns only
|
||||
test-branch:
|
||||
- head-branch: '^test/'
|
||||
|
||||
feature-branch:
|
||||
- head-branch: '/feature/'
|
||||
15
__tests__/fixtures/max_files_5.yml
Normal file
15
__tests__/fixtures/max_files_5.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
# Skip file-based labeling if more than 5 files changed
|
||||
max-files-changed: 5
|
||||
|
||||
# Labels based on changed files
|
||||
component-a:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/a/**']
|
||||
|
||||
component-b:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/b/**']
|
||||
|
||||
component-c:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/c/**']
|
||||
15
__tests__/fixtures/max_files_with_branch.yml
Normal file
15
__tests__/fixtures/max_files_with_branch.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
# Skip file-based labeling if more than 3 files changed
|
||||
max-files-changed: 3
|
||||
|
||||
# Labels based on changed files
|
||||
component-a:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/a/**']
|
||||
|
||||
component-b:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/b/**']
|
||||
|
||||
# Branch-based label (should not be affected)
|
||||
test-branch:
|
||||
- head-branch: ['^test/']
|
||||
23
__tests__/fixtures/mixed_labels.yml
Normal file
23
__tests__/fixtures/mixed_labels.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
# Labels based on changed files
|
||||
component-a:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/a/**']
|
||||
|
||||
component-b:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/b/**']
|
||||
|
||||
component-c:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/c/**']
|
||||
|
||||
component-d:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/d/**']
|
||||
|
||||
# Labels based on branch patterns only
|
||||
test-branch:
|
||||
- head-branch: '^test/'
|
||||
|
||||
feature-branch:
|
||||
- head-branch: '/feature/'
|
||||
16
__tests__/fixtures/mixed_rules.yml
Normal file
16
__tests__/fixtures/mixed_rules.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
# Test fixture for mixed rules behavior
|
||||
# A label with both branch and changed-files rules is considered a "changed-files label"
|
||||
# and is subject to the limit, even if it matches via the branch rule
|
||||
changed-files-labels-limit: 0
|
||||
|
||||
# This label has both branch and changed-files rules
|
||||
# It should be subject to the limit even if matched via branch
|
||||
mixed-label:
|
||||
- any:
|
||||
- head-branch: '^test/'
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ['components/a/**']
|
||||
|
||||
# Pure branch-based label - not subject to limit
|
||||
pure-branch-label:
|
||||
- head-branch: '^test/'
|
||||
Reference in New Issue
Block a user