diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000000..5bebcb9924c --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,220 @@ +# File-based auto-labeling configuration +# Works with actions/labeler@v5 +# This complements auto-tag.yml (title-based labeling) by detecting which files changed + +# ============================================================================= +# Environment Sub-Labels (trigger specific tests in test-linux-libs.yml) +# ============================================================================= +"Environments/brax": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/brax.py'] + +"Environments/dm_control": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/dm_control.py'] + +"Environments/envpool": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/envpool.py'] + +"Environments/gym": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/gym.py', 'torchrl/envs/libs/_gym_utils.py'] + +"Environments/habitat": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/habitat.py'] + +"Environments/isaaclab": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/isaac_lab.py', 'torchrl/envs/libs/isaacgym.py'] + +"Environments/jumanji": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/jumanji.py'] + +"Environments/meltingpot": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/meltingpot.py'] + +"Environments/open_spiel": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/openspiel.py'] + +"Environments/pettingzoo": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/pettingzoo.py'] + +"Environments/procgen": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/procgen.py'] + +"Environments/robohive": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/robohive.py'] + +"Environments/smacv2": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/smacv2.py'] + +"Environments/unity_mlagents": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/unity_mlagents.py'] + +"Environments/vmas": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/libs/vmas.py'] + +"Environments/chess": + - changed-files: + - any-glob-to-any-file: ['torchrl/envs/custom/chess.py'] + +# Parent Environments label (any env lib change) +"Environments": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/envs/libs/**' + - 'test/test_libs.py' + +# ============================================================================= +# Data Sub-Labels (trigger specific tests in test-linux-libs.yml) +# ============================================================================= +"Data/gendgrl": + - changed-files: + - any-glob-to-any-file: ['torchrl/data/datasets/gen_dgrl.py'] + +"Data/minari": + - changed-files: + - any-glob-to-any-file: ['torchrl/data/datasets/minari_data.py'] + +"Data/openx": + - changed-files: + - any-glob-to-any-file: ['torchrl/data/datasets/openx.py'] + +"Data/roboset": + - changed-files: + - any-glob-to-any-file: ['torchrl/data/datasets/roboset.py'] + +"Data/vd4rl": + - changed-files: + - any-glob-to-any-file: ['torchrl/data/datasets/vd4rl.py'] + +# Parent Data label +"Data": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/data/datasets/**' + +# ============================================================================= +# LLM (triggers test-linux-llm.yml) +# ============================================================================= +"llm/": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/envs/llm/**' + - 'torchrl/objectives/llm/**' + - 'torchrl/data/llm/**' + - 'torchrl/weight_update/llm/**' + - 'torchrl/modules/llm/**' + - 'torchrl/collectors/llm/**' + - 'test/llm/**' + +# ============================================================================= +# Core Module Labels (informational, core tests always run) +# ============================================================================= +"Collectors": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/collectors/**' + - 'test/test_collectors.py' + +"Objectives": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/objectives/**' + - 'test/test_objectives.py' + +"Modules": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/modules/**' + - 'test/test_modules.py' + - 'test/test_tensordictmodules.py' + - 'test/test_actors.py' + +"Transforms": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/envs/transforms/**' + - 'test/test_transforms.py' + +"Trainers": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/trainers/**' + - 'test/test_trainer.py' + +"Record": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/record/**' + - 'test/test_loggers.py' + +"WeightUpdate": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/weight_update/**' + +"ReplayBuffers": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/data/replay_buffers/**' + - 'test/test_rb.py' + - 'test/test_storage_map.py' + +"Services": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/services/**' + - 'test/services/**' + +"distributions": + - changed-files: + - any-glob-to-any-file: + - 'torchrl/modules/distributions/**' + - 'test/test_distributions.py' + +# ============================================================================= +# Documentation & CI +# ============================================================================= +"Documentation": + - changed-files: + - any-glob-to-any-file: + - 'docs/**' + - '*.md' + - '*.rst' + +"CI": + - changed-files: + - any-glob-to-any-file: + - '.github/**' + +"sota-implementations/": + - changed-files: + - any-glob-to-any-file: + - 'sota-implementations/**' + +"tutorials/": + - changed-files: + - any-glob-to-any-file: + - 'tutorials/**' + +"Examples": + - changed-files: + - any-glob-to-any-file: + - 'examples/**' + +"Benchmarks": + - changed-files: + - any-glob-to-any-file: + - 'benchmarks/**' diff --git a/.github/labels.yml b/.github/labels.yml index 4feb216866d..81625977ad4 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -132,10 +132,22 @@ description: "Triggers chess environment tests only" color: "0E8A16" +- name: Environments/dm_control + description: "Triggers dm_control environment tests" + color: "0E8A16" + - name: Environments/envpool description: "Triggers envpool environment tests only" color: "0E8A16" +- name: Environments/gym + description: "Triggers gym environment tests only" + color: "0E8A16" + +- name: Environments/habitat + description: "Triggers habitat environment tests" + color: "0E8A16" + - name: Environments/isaaclab description: "Triggers Isaac Lab environment tests only" color: "0E8A16" @@ -164,6 +176,10 @@ description: "Triggers robohive environment tests only" color: "0E8A16" +- name: Environments/sklearn + description: "Triggers sklearn tests only" + color: "0E8A16" + - name: Environments/smacv2 description: "Triggers smacv2 environment tests only" color: "0E8A16" @@ -230,3 +246,49 @@ - name: benchmarks/upload description: "Upload results of the PR to benchmarks" color: "5319E7" + +# ============================================================================= +# TorchRL Module Component Labels +# ============================================================================= +- name: Objectives + description: "Changes to torchrl/objectives/" + color: "1D76DB" + +- name: Modules + description: "Changes to torchrl/modules/" + color: "1D76DB" + +- name: Transforms + description: "Changes to torchrl/envs/transforms/" + color: "1D76DB" + +- name: Record + description: "Changes to torchrl/record/" + color: "1D76DB" + +- name: Trainers + description: "Changes to torchrl/trainers/" + color: "1D76DB" + +- name: WeightUpdate + description: "Changes to torchrl/weight_update/" + color: "1D76DB" + +- name: Services + description: "Changes to torchrl/services/" + color: "1D76DB" + +- name: ReplayBuffers + description: "Changes to torchrl/data/replay_buffers/" + color: "1D76DB" + +# ============================================================================= +# Other Useful Labels +# ============================================================================= +- name: sota-implementations/ + description: "Changes to sota-implementations/" + color: "5319E7" + +- name: tutorials/ + description: "Changes to tutorials/" + color: "0075ca" diff --git a/.github/workflows/auto-labeler.yml b/.github/workflows/auto-labeler.yml new file mode 100644 index 00000000000..d38374e6f6d --- /dev/null +++ b/.github/workflows/auto-labeler.yml @@ -0,0 +1,31 @@ +# Automatically add labels to PRs based on which files changed +# +# This complements auto-tag.yml (title-based labeling): +# - auto-tag.yml: Labels based on PR title prefix ([BugFix], [Feature], etc.) +# - auto-labeler.yml: Labels based on which files/directories changed +# +# Together they provide complete PR categorization: +# - Title-based labels capture the INTENT (bug fix, feature, etc.) +# - File-based labels capture the SCOPE (which components changed) +#------------------------------------------------------------ + +name: Auto Label PR (File-Based) + +on: + pull_request_target: + types: [opened, synchronize] + +jobs: + label: + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: read + steps: + - name: Apply labels based on changed files + uses: actions/labeler@v5 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + # Don't remove labels that aren't in the config + # This preserves manually-added labels and title-based labels from auto-tag.yml + sync-labels: false diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml index 087c234c786..87d6d17ddfe 100644 --- a/.github/workflows/auto-tag.yml +++ b/.github/workflows/auto-tag.yml @@ -1,23 +1,23 @@ # Automatically add a label to PRs based on the [Label] prefix in the title # # Usage: -# - PR title must start with an EXACT [Label] prefix (case-sensitive) +# - PR title must start with a [Label] prefix in brackets # - Example: "[BugFix] Fix memory leak" will add the "BugFix" label # - Fails if no valid prefix is found -# - When title is edited, old auto-label is replaced with the new one +# - Labels are ONLY ADDED, never removed (preserves manual labels) # -# Supported prefixes (CASE-SENSITIVE - must match exactly): -# - [BugFix] → BugFix -# - [Feature] → Feature -# - [Doc] → Documentation -# - [Refactor] → Refactoring +# Supported prefixes (supports common variations): +# - [BugFix], [Bugfix] → BugFix +# - [Feature], [Features] → Feature +# - [Doc], [Docs], [Documentation] → Documentation +# - [Refactor], [Refactoring] → Refactoring # - [CI] → CI -# - [Tests] → Tests -# - [Environments] → Environments +# - [Test], [Tests] → Tests +# - [Environment], [Environments] → Environments # - [Data] → Data -# - [Performance] → Performance -# - [BC-Breaking] → bc breaking -# - [Deprecation] → Deprecation +# - [Performance], [Perf] → Performance +# - [BC-Breaking], [BCBreaking] → bc breaking +# - [Deprecation], [Deprecated] → Deprecation #------------------------------------------------------------ name: PR Label @@ -40,8 +40,6 @@ jobs: PR_TITLE: ${{ github.event.pull_request.title }} PR_NUMBER: ${{ github.event.pull_request.number }} REPO: ${{ github.repository }} - # Known auto-labels that this workflow manages (actual GitHub label names) - AUTO_LABELS: "BugFix Feature Documentation Refactoring CI Tests Environments Data Performance bc breaking Deprecation" run: | set -euo pipefail @@ -63,17 +61,17 @@ jobs: |--------|---------------|---------| | `[BugFix]` | BugFix | `[BugFix] Fix memory leak in collector` | | `[Feature]` | Feature | `[Feature] Add new optimizer` | - | `[Doc]` | Documentation | `[Doc] Update installation guide` | + | `[Doc]` or `[Docs]` | Documentation | `[Doc] Update installation guide` | | `[Refactor]` | Refactoring | `[Refactor] Clean up module imports` | | `[CI]` | CI | `[CI] Fix workflow permissions` | - | `[Tests]` | Tests | `[Tests] Add unit tests for buffer` | - | `[Environments]` | Environments | `[Environments] Add Gymnasium support` | + | `[Test]` or `[Tests]` | Tests | `[Tests] Add unit tests for buffer` | + | `[Environment]` or `[Environments]` | Environments | `[Environments] Add Gymnasium support` | | `[Data]` | Data | `[Data] Fix replay buffer sampling` | - | `[Performance]` | Performance | `[Performance] Optimize tensor ops` | + | `[Performance]` or `[Perf]` | Performance | `[Performance] Optimize tensor ops` | | `[BC-Breaking]` | bc breaking | `[BC-Breaking] Remove deprecated API` | | `[Deprecation]` | Deprecation | `[Deprecation] Mark old function` | - **Note:** Prefixes are case-sensitive. Use `[BugFix]` not `[bugfix]` or `[Bugfix]`. + **Note:** Common variations like singular/plural are supported (e.g., `[Doc]` or `[Docs]`). COMMENT_EOF # Strip leading spaces from heredoc (YAML indentation artifact) sed -i 's/^ //' /tmp/pr_comment.md @@ -96,62 +94,51 @@ jobs: echo "Extracted prefix: $PREFIX" - # Map EXACT prefixes to GitHub label names (case-sensitive) + # Map prefixes to GitHub label names (supports common variations) case "$PREFIX" in - BugFix) + BugFix|Bugfix|bugfix) LABEL="BugFix" ;; - Feature) + Feature|Features|feature|features) LABEL="Feature" ;; - Doc) + Doc|Docs|Documentation|doc|docs) LABEL="Documentation" ;; - Refactor) + Refactor|Refactoring|refactor|refactoring) LABEL="Refactoring" ;; - CI) + CI|ci) LABEL="CI" ;; - Tests) + Test|Tests|test|tests) LABEL="Tests" ;; - Environments) + Environment|Environments|environment|environments) LABEL="Environments" ;; - Data) + Data|data) LABEL="Data" ;; - Performance) + Performance|Perf|performance|perf) LABEL="Performance" ;; - BC-Breaking) + BC-Breaking|BCBreaking|bc-breaking) LABEL="bc breaking" ;; - Deprecation) + Deprecation|Deprecated|deprecation|deprecated) LABEL="Deprecation" ;; *) - echo "::error::Unknown or invalid prefix '[$PREFIX]'. Prefixes are case-sensitive." - post_help_comment "Unknown or invalid prefix \`[$PREFIX]\`. Prefixes are case-sensitive." "$PR_TITLE" + echo "::error::Unknown or invalid prefix '[$PREFIX]'." + post_help_comment "Unknown or invalid prefix \`[$PREFIX]\`." "$PR_TITLE" exit 1 ;; esac echo "Mapped to label: $LABEL" - # Get current labels on the PR - CURRENT_LABELS=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json labels --jq '.labels[].name' 2>/dev/null || echo "") - - # Remove any existing auto-labels that don't match the new one - for existing in $CURRENT_LABELS; do - if [[ "$existing" != "$LABEL" && " $AUTO_LABELS " == *" $existing "* ]]; then - echo "Removing old auto-label: $existing" - gh pr edit "$PR_NUMBER" --repo "$REPO" --remove-label "$existing" 2>/dev/null || true - fi - done - - # Add the label to the PR + # Add the label to the PR (never remove existing labels) gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "$LABEL" echo "Successfully added label '$LABEL' to PR #$PR_NUMBER"