Skip to content

Commit cfeb61a

Browse files
committed
[CI] Add file-based auto-labeling for PR components (#3402)
This commit adds a file-based auto-labeling system that complements the existing title-based labeling (auto-tag.yml): New files: - .github/labeler.yml: Path-to-label mappings for all TorchRL components - .github/workflows/auto-labeler.yml: Workflow using actions/labeler@v5 Updated files: - .github/labels.yml: Added missing labels for Environments (gym, sklearn, dm_control, habitat), TorchRL modules (Objectives, Modules, Transforms, Record, Trainers, WeightUpdate, Services, ReplayBuffers), and other categories (sota-implementations/, tutorials/) - .github/workflows/auto-tag.yml: Fixed to only ADD labels (never remove), added support for singular/plural prefix variations (e.g., [Environment] and [Environments] both work) Together these provide complete PR categorization: - Title-based labels capture the INTENT (bug fix, feature, etc.) - File-based labels capture the SCOPE (which components changed) ghstack-source-id: d1f282a Pull-Request: #3402
1 parent e09ee4f commit cfeb61a

File tree

4 files changed

+345
-45
lines changed

4 files changed

+345
-45
lines changed

.github/labeler.yml

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# File-based auto-labeling configuration
2+
# Works with actions/labeler@v5
3+
# This complements auto-tag.yml (title-based labeling) by detecting which files changed
4+
5+
# =============================================================================
6+
# Environment Sub-Labels (trigger specific tests in test-linux-libs.yml)
7+
# =============================================================================
8+
"Environments/brax":
9+
- changed-files:
10+
- any-glob-to-any-file: ['torchrl/envs/libs/brax.py']
11+
12+
"Environments/dm_control":
13+
- changed-files:
14+
- any-glob-to-any-file: ['torchrl/envs/libs/dm_control.py']
15+
16+
"Environments/envpool":
17+
- changed-files:
18+
- any-glob-to-any-file: ['torchrl/envs/libs/envpool.py']
19+
20+
"Environments/gym":
21+
- changed-files:
22+
- any-glob-to-any-file: ['torchrl/envs/libs/gym.py', 'torchrl/envs/libs/_gym_utils.py']
23+
24+
"Environments/habitat":
25+
- changed-files:
26+
- any-glob-to-any-file: ['torchrl/envs/libs/habitat.py']
27+
28+
"Environments/isaaclab":
29+
- changed-files:
30+
- any-glob-to-any-file: ['torchrl/envs/libs/isaac_lab.py', 'torchrl/envs/libs/isaacgym.py']
31+
32+
"Environments/jumanji":
33+
- changed-files:
34+
- any-glob-to-any-file: ['torchrl/envs/libs/jumanji.py']
35+
36+
"Environments/meltingpot":
37+
- changed-files:
38+
- any-glob-to-any-file: ['torchrl/envs/libs/meltingpot.py']
39+
40+
"Environments/open_spiel":
41+
- changed-files:
42+
- any-glob-to-any-file: ['torchrl/envs/libs/openspiel.py']
43+
44+
"Environments/pettingzoo":
45+
- changed-files:
46+
- any-glob-to-any-file: ['torchrl/envs/libs/pettingzoo.py']
47+
48+
"Environments/procgen":
49+
- changed-files:
50+
- any-glob-to-any-file: ['torchrl/envs/libs/procgen.py']
51+
52+
"Environments/robohive":
53+
- changed-files:
54+
- any-glob-to-any-file: ['torchrl/envs/libs/robohive.py']
55+
56+
"Environments/smacv2":
57+
- changed-files:
58+
- any-glob-to-any-file: ['torchrl/envs/libs/smacv2.py']
59+
60+
"Environments/unity_mlagents":
61+
- changed-files:
62+
- any-glob-to-any-file: ['torchrl/envs/libs/unity_mlagents.py']
63+
64+
"Environments/vmas":
65+
- changed-files:
66+
- any-glob-to-any-file: ['torchrl/envs/libs/vmas.py']
67+
68+
"Environments/chess":
69+
- changed-files:
70+
- any-glob-to-any-file: ['torchrl/envs/custom/chess.py']
71+
72+
# Parent Environments label (any env lib change)
73+
"Environments":
74+
- changed-files:
75+
- any-glob-to-any-file:
76+
- 'torchrl/envs/libs/**'
77+
- 'test/test_libs.py'
78+
79+
# =============================================================================
80+
# Data Sub-Labels (trigger specific tests in test-linux-libs.yml)
81+
# =============================================================================
82+
"Data/gendgrl":
83+
- changed-files:
84+
- any-glob-to-any-file: ['torchrl/data/datasets/gen_dgrl.py']
85+
86+
"Data/minari":
87+
- changed-files:
88+
- any-glob-to-any-file: ['torchrl/data/datasets/minari_data.py']
89+
90+
"Data/openx":
91+
- changed-files:
92+
- any-glob-to-any-file: ['torchrl/data/datasets/openx.py']
93+
94+
"Data/roboset":
95+
- changed-files:
96+
- any-glob-to-any-file: ['torchrl/data/datasets/roboset.py']
97+
98+
"Data/vd4rl":
99+
- changed-files:
100+
- any-glob-to-any-file: ['torchrl/data/datasets/vd4rl.py']
101+
102+
# Parent Data label
103+
"Data":
104+
- changed-files:
105+
- any-glob-to-any-file:
106+
- 'torchrl/data/datasets/**'
107+
108+
# =============================================================================
109+
# LLM (triggers test-linux-llm.yml)
110+
# =============================================================================
111+
"llm/":
112+
- changed-files:
113+
- any-glob-to-any-file:
114+
- 'torchrl/envs/llm/**'
115+
- 'torchrl/objectives/llm/**'
116+
- 'torchrl/data/llm/**'
117+
- 'torchrl/weight_update/llm/**'
118+
- 'torchrl/modules/llm/**'
119+
- 'torchrl/collectors/llm/**'
120+
- 'test/llm/**'
121+
122+
# =============================================================================
123+
# Core Module Labels (informational, core tests always run)
124+
# =============================================================================
125+
"Collectors":
126+
- changed-files:
127+
- any-glob-to-any-file:
128+
- 'torchrl/collectors/**'
129+
- 'test/test_collectors.py'
130+
131+
"Objectives":
132+
- changed-files:
133+
- any-glob-to-any-file:
134+
- 'torchrl/objectives/**'
135+
- 'test/test_objectives.py'
136+
137+
"Modules":
138+
- changed-files:
139+
- any-glob-to-any-file:
140+
- 'torchrl/modules/**'
141+
- 'test/test_modules.py'
142+
- 'test/test_tensordictmodules.py'
143+
- 'test/test_actors.py'
144+
145+
"Transforms":
146+
- changed-files:
147+
- any-glob-to-any-file:
148+
- 'torchrl/envs/transforms/**'
149+
- 'test/test_transforms.py'
150+
151+
"Trainers":
152+
- changed-files:
153+
- any-glob-to-any-file:
154+
- 'torchrl/trainers/**'
155+
- 'test/test_trainer.py'
156+
157+
"Record":
158+
- changed-files:
159+
- any-glob-to-any-file:
160+
- 'torchrl/record/**'
161+
- 'test/test_loggers.py'
162+
163+
"WeightUpdate":
164+
- changed-files:
165+
- any-glob-to-any-file:
166+
- 'torchrl/weight_update/**'
167+
168+
"ReplayBuffers":
169+
- changed-files:
170+
- any-glob-to-any-file:
171+
- 'torchrl/data/replay_buffers/**'
172+
- 'test/test_rb.py'
173+
- 'test/test_storage_map.py'
174+
175+
"Services":
176+
- changed-files:
177+
- any-glob-to-any-file:
178+
- 'torchrl/services/**'
179+
- 'test/services/**'
180+
181+
"distributions":
182+
- changed-files:
183+
- any-glob-to-any-file:
184+
- 'torchrl/modules/distributions/**'
185+
- 'test/test_distributions.py'
186+
187+
# =============================================================================
188+
# Documentation & CI
189+
# =============================================================================
190+
"Documentation":
191+
- changed-files:
192+
- any-glob-to-any-file:
193+
- 'docs/**'
194+
- '*.md'
195+
- '*.rst'
196+
197+
"CI":
198+
- changed-files:
199+
- any-glob-to-any-file:
200+
- '.github/**'
201+
202+
"sota-implementations/":
203+
- changed-files:
204+
- any-glob-to-any-file:
205+
- 'sota-implementations/**'
206+
207+
"tutorials/":
208+
- changed-files:
209+
- any-glob-to-any-file:
210+
- 'tutorials/**'
211+
212+
"Examples":
213+
- changed-files:
214+
- any-glob-to-any-file:
215+
- 'examples/**'
216+
217+
"Benchmarks":
218+
- changed-files:
219+
- any-glob-to-any-file:
220+
- 'benchmarks/**'

.github/labels.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,22 @@
132132
description: "Triggers chess environment tests only"
133133
color: "0E8A16"
134134

135+
- name: Environments/dm_control
136+
description: "Triggers dm_control environment tests"
137+
color: "0E8A16"
138+
135139
- name: Environments/envpool
136140
description: "Triggers envpool environment tests only"
137141
color: "0E8A16"
138142

143+
- name: Environments/gym
144+
description: "Triggers gym environment tests only"
145+
color: "0E8A16"
146+
147+
- name: Environments/habitat
148+
description: "Triggers habitat environment tests"
149+
color: "0E8A16"
150+
139151
- name: Environments/isaaclab
140152
description: "Triggers Isaac Lab environment tests only"
141153
color: "0E8A16"
@@ -164,6 +176,10 @@
164176
description: "Triggers robohive environment tests only"
165177
color: "0E8A16"
166178

179+
- name: Environments/sklearn
180+
description: "Triggers sklearn tests only"
181+
color: "0E8A16"
182+
167183
- name: Environments/smacv2
168184
description: "Triggers smacv2 environment tests only"
169185
color: "0E8A16"
@@ -230,3 +246,49 @@
230246
- name: benchmarks/upload
231247
description: "Upload results of the PR to benchmarks"
232248
color: "5319E7"
249+
250+
# =============================================================================
251+
# TorchRL Module Component Labels
252+
# =============================================================================
253+
- name: Objectives
254+
description: "Changes to torchrl/objectives/"
255+
color: "1D76DB"
256+
257+
- name: Modules
258+
description: "Changes to torchrl/modules/"
259+
color: "1D76DB"
260+
261+
- name: Transforms
262+
description: "Changes to torchrl/envs/transforms/"
263+
color: "1D76DB"
264+
265+
- name: Record
266+
description: "Changes to torchrl/record/"
267+
color: "1D76DB"
268+
269+
- name: Trainers
270+
description: "Changes to torchrl/trainers/"
271+
color: "1D76DB"
272+
273+
- name: WeightUpdate
274+
description: "Changes to torchrl/weight_update/"
275+
color: "1D76DB"
276+
277+
- name: Services
278+
description: "Changes to torchrl/services/"
279+
color: "1D76DB"
280+
281+
- name: ReplayBuffers
282+
description: "Changes to torchrl/data/replay_buffers/"
283+
color: "1D76DB"
284+
285+
# =============================================================================
286+
# Other Useful Labels
287+
# =============================================================================
288+
- name: sota-implementations/
289+
description: "Changes to sota-implementations/"
290+
color: "5319E7"
291+
292+
- name: tutorials/
293+
description: "Changes to tutorials/"
294+
color: "0075ca"

.github/workflows/auto-labeler.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Automatically add labels to PRs based on which files changed
2+
#
3+
# This complements auto-tag.yml (title-based labeling):
4+
# - auto-tag.yml: Labels based on PR title prefix ([BugFix], [Feature], etc.)
5+
# - auto-labeler.yml: Labels based on which files/directories changed
6+
#
7+
# Together they provide complete PR categorization:
8+
# - Title-based labels capture the INTENT (bug fix, feature, etc.)
9+
# - File-based labels capture the SCOPE (which components changed)
10+
#------------------------------------------------------------
11+
12+
name: Auto Label PR (File-Based)
13+
14+
on:
15+
pull_request_target:
16+
types: [opened, synchronize]
17+
18+
jobs:
19+
label:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
pull-requests: write
23+
contents: read
24+
steps:
25+
- name: Apply labels based on changed files
26+
uses: actions/labeler@v5
27+
with:
28+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
29+
# Don't remove labels that aren't in the config
30+
# This preserves manually-added labels and title-based labels from auto-tag.yml
31+
sync-labels: false

0 commit comments

Comments
 (0)