|
| 1 | +# Copyright 2025 The HuggingFace Inc. team. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# This workflow automatically labels issues based on their content. |
| 16 | +name: Issue Labeler |
| 17 | +on: |
| 18 | + # Trigger on new issues and edits to existing issues |
| 19 | + issues: |
| 20 | + types: [opened, edited] |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + issues: write |
| 25 | + |
| 26 | +jobs: |
| 27 | + label-issue: |
| 28 | + name: Auto Label Issue |
| 29 | + runs-on: ubuntu-latest |
| 30 | + if: github.repository == 'huggingface/lerobot' |
| 31 | + steps: |
| 32 | + - uses: actions/github-script@v8 |
| 33 | + with: |
| 34 | + script: | |
| 35 | + // Setup Input Text (Unified Title + Body) |
| 36 | + const body = (context.payload.issue.body || ''); |
| 37 | + const title = (context.payload.issue.title || ''); |
| 38 | +
|
| 39 | + // We keep a lowercased version for keyword matching |
| 40 | + const text = `${title}\n${body}`.toLowerCase(); |
| 41 | +
|
| 42 | + const labelsToAdd = new Set(); |
| 43 | +
|
| 44 | + // Helper: Simple regex test |
| 45 | + const matches = (re) => re.test(text); |
| 46 | +
|
| 47 | + // Issue Type Detection (Dropdowns & Explicit Headers) |
| 48 | + if (text.includes('bug report') || /\bissue type:.*bug/.test(text)) { |
| 49 | + labelsToAdd.add('bug'); |
| 50 | + } |
| 51 | + if (text.includes('feature request') || /\bissue type:.*feature/.test(text)) { |
| 52 | + labelsToAdd.add('enhancement'); |
| 53 | + } |
| 54 | + if (text.includes('technical question') || /\bissue type:.*question/.test(text)) { |
| 55 | + labelsToAdd.add('question'); |
| 56 | + } |
| 57 | + if (text.includes('maintenance') || /\bissue type:.*maintenance/.test(text)) { |
| 58 | + labelsToAdd.add('documentation'); |
| 59 | + } |
| 60 | +
|
| 61 | + // Keyword Heuristic |
| 62 | +
|
| 63 | + // Domain Specific |
| 64 | + if (matches(/example(s)?\b|script(s)?\b|sample(s)?\b|demo(s)?\b|notebook(s)?\b/i)) labelsToAdd.add('examples'); |
| 65 | + if (matches(/dataset(s)?\b|data loader|data augmentation|data preprocessing/i)) labelsToAdd.add('dataset'); |
| 66 | + if (matches(/mujoco|isaac|\bsimulation\b|\bsim /i)) labelsToAdd.add('simulation'); |
| 67 | + if (matches(/train|loss|optimizer|backward|gradient|wandb|sac\b/i)) labelsToAdd.add('training'); |
| 68 | + if (matches(/rerun|plot|video|render|visualiz|gif/i)) labelsToAdd.add('visualization'); |
| 69 | + if (matches(/camera|realsense|lidar|depth|sensor|imu|microphone|rgbd/i)) labelsToAdd.add('sensors'); |
| 70 | + if (matches(/aloha|koch|so-100|so100|mobile|teleop|manipulator|robot(s)?\b/i)) labelsToAdd.add('robots'); |
| 71 | + if (matches(/teleop|teleoperator|controller|leader|follower|joystick|gamepad/i)) labelsToAdd.add('teleoperators'); |
| 72 | + if (matches(/policy|policies|p0licy/i)) labelsToAdd.add('policies'); |
| 73 | + if (matches(/processor(s)?\b|implement.*processor|processor pipeline/i)) labelsToAdd.add('processor'); |
| 74 | + if (matches(/eval|evaluate|evaluation|metric(s)?\b|score|benchmark/i)) labelsToAdd.add('evaluation'); |
| 75 | +
|
| 76 | + // Infrastructure & Code Quality |
| 77 | + if (matches(/test|pytest|unittest|failing test/i)) labelsToAdd.add('tests'); |
| 78 | + if (matches(/ci|github actions|workflow|gha|action(s)?\b|pipeline/i)) { |
| 79 | + labelsToAdd.add('CI'); |
| 80 | + labelsToAdd.add('github_actions'); |
| 81 | + } |
| 82 | + if (matches(/perf|latency|benchmark|throughput|fps|speed|performance|benchmarking/i)) labelsToAdd.add('performance'); |
| 83 | + if (matches(/dependency|requirements|pip|conda|install error|importerror|package not found/i)) labelsToAdd.add('dependencies'); |
| 84 | + if (matches(/python\b|pyproject|requirements(\.txt)?|pip install|typing error/i)) labelsToAdd.add('python'); |
| 85 | +
|
| 86 | + // Documentation & Meta |
| 87 | + if (matches(/doc|documentation|docs|readme|typo|how to/i)) labelsToAdd.add('documentation'); |
| 88 | + if (matches(/refactor|cleanup|restructure|rename|modernize code/i)) labelsToAdd.add('refactor'); |
| 89 | + if (matches(/release|changelog|version bump|cut a release|tag v/i)) labelsToAdd.add('release'); |
| 90 | +
|
| 91 | + // Fixed: "BREAKING CHANGE" must be lowercase in regex because 'text' is lowercase |
| 92 | + if (matches(/breaking change|breaking:|major change/i)) labelsToAdd.add('breaking change'); |
| 93 | +
|
| 94 | + // Apply Labels |
| 95 | + const labels = Array.from(labelsToAdd).filter(Boolean); |
| 96 | +
|
| 97 | + if (labels.length > 0) { |
| 98 | + console.log(`Adding labels: ${labels.join(', ')}`); |
| 99 | + await github.rest.issues.addLabels({ |
| 100 | + owner: context.repo.owner, |
| 101 | + repo: context.repo.repo, |
| 102 | + issue_number: context.issue.number, |
| 103 | + labels, |
| 104 | + }); |
| 105 | + } |
0 commit comments