ci: auto-label pull requests by component and area (#2240)

* ci: auto-label pull requests by component and area

Adds a path-based labeler so every pull request arrives routed to the
package it changes and the analyzer subsystem it touches, instead of
being triaged by hand.

Uses pull_request_target for the same reason label-external.yml does:
fork pull requests get a read-only token on pull_request, so the label
call would fail silently. The action never checks out or runs pull
request code, and both the workflow and the config are read from the
base branch, so a pull request cannot alter its own label rules.

sync-labels is left off so hand-applied triage labels are never removed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0183ij1wiTEcd8wA58xY7e6C

* ci: label pull requests touching docs/samples

Samples are documentation but also code that has to keep working, so they
need to be findable on their own rather than only under documentation.
Reuses the existing `samples` label.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0183ij1wiTEcd8wA58xY7e6C

* ci: correct facet documentation in labeler config

The header described two facets while the file defines three, and
`samples` sat under the component heading rather than type.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0183ij1wiTEcd8wA58xY7e6C

* ci: name the labeler step for all three facets

The workflow and step names described component and area only, while the
config also applies type labels.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0183ij1wiTEcd8wA58xY7e6C

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Omri Mendels
2026-09-08 20:50:35 +03:00
committed by GitHub
co-authored by Claude Opus 5
parent 5e2fcea990
commit a7b17c75f3
2 changed files with 170 additions and 0 deletions
+141
View File
@@ -0,0 +1,141 @@
# Path-based labels applied automatically by .github/workflows/label-areas.yml
#
# Three facets are applied here:
# component - which package the change lives in
# area - which subsystem inside the analyzer it touches
# type - what kind of change it is, where the paths make that clear
#
# Labels are not exclusive. A pull request that spans a package and a subsystem
# receives both, which is intended: the component label answers "what does this
# release affect", the area label answers "who should review it".
#
# Triage labels (needs-decision, good first issue, ...) are applied by hand and
# must not be listed here, or sync-labels would eventually remove them.
# ---------------------------------------------------------------------------
# Component
# ---------------------------------------------------------------------------
analyzer:
- changed-files:
- any-glob-to-any-file:
- 'presidio-analyzer/**'
- 'docs/analyzer/**'
anonymizer:
- changed-files:
- any-glob-to-any-file:
- 'presidio-anonymizer/**'
- 'docs/anonymizer/**'
image-anonymization:
- changed-files:
- any-glob-to-any-file:
- 'presidio-image-redactor/**'
- 'docs/image-redactor/**'
dicom:
- changed-files:
- any-glob-to-any-file:
- '**/dicom_*.py'
- '**/*dicom*'
structured-data:
- changed-files:
- any-glob-to-any-file:
- 'presidio-structured/**'
cli:
- changed-files:
- any-glob-to-any-file:
- 'presidio-cli/**'
rest-api:
- changed-files:
- any-glob-to-any-file:
- 'presidio-*/app.py'
- 'docs/api-docs/**'
- 'docs/api.md'
deployment:
- changed-files:
- any-glob-to-any-file:
- '**/Dockerfile*'
- 'docker-compose*.yml'
- 'presidio/**'
- 'scripts/**'
documentation:
- changed-files:
- any-glob-to-any-file:
- 'docs/**'
- 'mkdocs.yml'
- 'overrides/**'
- '*.md'
# ---------------------------------------------------------------------------
# Area (analyzer subsystems)
# ---------------------------------------------------------------------------
# Pattern and predefined recognizers.
# Review rulebook: .github/instructions/recognizers.instructions.md
PII recognizers:
- changed-files:
- any-glob-to-any-file:
- 'presidio-analyzer/presidio_analyzer/predefined_recognizers/**'
- 'presidio-analyzer/presidio_analyzer/conf/default_recognizers.yaml'
- 'docs/supported_entities.md'
# Score boosting from surrounding words, including the lemma matching that
# behaves differently per language.
context-enhancement:
- changed-files:
- any-glob-to-any-file:
- 'presidio-analyzer/presidio_analyzer/context_aware_enhancers/**'
# The pydantic models and registry loading behind YAML configuration.
# Review rulebook: .github/instructions/yaml-config.instructions.md
yaml-config:
- changed-files:
- any-glob-to-any-file:
- 'presidio-analyzer/presidio_analyzer/input_validation/**'
- 'presidio-analyzer/presidio_analyzer/recognizer_registry/**'
- 'presidio-analyzer/presidio_analyzer/conf/**'
# NLP backends: spaCy, Stanza, transformers, GLiNER, LangExtract.
nlp-engine:
- changed-files:
- any-glob-to-any-file:
- 'presidio-analyzer/presidio_analyzer/nlp_engine/**'
- 'presidio-analyzer/presidio_analyzer/chunkers/**'
- 'presidio-analyzer/presidio_analyzer/llm_utils/**'
# ---------------------------------------------------------------------------
# Type
# ---------------------------------------------------------------------------
# Runnable examples and notebooks. Overlaps documentation by design: a sample
# is documentation, but it is also code that has to keep working, so it needs
# to be findable on its own.
samples:
- changed-files:
- any-glob-to-any-file:
- 'docs/samples/**'
test:
- changed-files:
- any-glob-to-any-file:
- '**/tests/**'
- 'e2e-tests/**'
ci:
- changed-files:
- any-glob-to-any-file:
- '.github/workflows/**'
- '.github/pipelines/**'
dependencies:
- changed-files:
- any-glob-to-any-file:
- '**/pyproject.toml'
- '**/uv.lock'
+29
View File
@@ -0,0 +1,29 @@
name: Label pull requests by changed paths
on:
pull_request_target:
types: [opened, synchronize, reopened]
# pull_request_target is required so that pull requests from forks receive a
# token with write access; a pull_request event grants read-only on forks and
# the label call fails silently.
#
# The usual pull_request_target risk does not apply here: this workflow never
# checks out or executes pull request code. It reads the changed file list
# through the API only, and both this file and .github/labeler.yml are read
# from the base branch, so a pull request cannot change its own label rules.
permissions:
contents: read
pull-requests: write
jobs:
label:
runs-on: ubuntu-slim
steps:
- name: Apply component, area and type labels from changed paths
uses: actions/labeler@b8dd2d9be0f68b860e7dae5dae7d772984eacd6d # v6.2.0
with:
# Add labels only. Labels applied by hand are never removed, and a
# pull request that stops touching a path keeps the label a reviewer
# may already have acted on.
sync-labels: false