|
| 1 | +# Label Automation Tooling |
| 2 | + |
| 3 | +* **Owners:** |
| 4 | + * `@jan--f` |
| 5 | + |
| 6 | +* **Implementation Status:** `Not implemented` |
| 7 | + |
| 8 | +* **Related Issues and PRs:** |
| 9 | + * [PROM-65](https://github.com/prometheus/proposals/pull/65) |
| 10 | + |
| 11 | +* **Other docs or links:** |
| 12 | + * [Prom-Prow Bot Implementation](https://github.com/jan--f/prom-prow) (to be |
| 13 | + moved to `prometheus` org) |
| 14 | + * [GitHub Actions: Add Labels to Issues](https://docs.github.com/en/actions/tutorials/manage-your-work/add-labels-to-issues) |
| 15 | + * [CNCF Hosted Tools](https://contribute.cncf.io/resources/services/hosted-tools/) |
| 16 | + * [Kubernetes Prow](https://docs.prow.k8s.io/) |
| 17 | + * [GitHub CODEOWNERS Documentation](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) |
| 18 | + |
| 19 | +> TL;DR: This proposal recommends using a custom lightweight chat-ops bot |
| 20 | +> (prom-prow) for Prometheus repositories. The bot provides Prow-style commands |
| 21 | +> (`/lgtm`, `/cc`, `/label`, `/hold`) without the complexity of OWNERS files or |
| 22 | +> running a full Prow instance. It uses GitHub's native collaborator permissions |
| 23 | +> for command authorization and CODEOWNERS for automatic review assignment, |
| 24 | +> providing bidirectional sync between `/lgtm` commands and GitHub UI approvals. |
| 25 | +
|
| 26 | +## Why |
| 27 | + |
| 28 | +The label system proposed in PROM-65 introduces structured labels for issue and |
| 29 | +PR workflow management. However, manually applying and managing these labels |
| 30 | +would create significant overhead for maintainers and contributors. Automation |
| 31 | +is essential to make the label system practical and effective. |
| 32 | + |
| 33 | +The Kubernetes ecosystem has demonstrated that chat-ops style label management |
| 34 | +(using `/label`, `/approve`, `/lgtm` commands in PR comments) can provide an |
| 35 | +efficient and intuitive workflow for maintainers. This approach should be |
| 36 | +adopted for Prometheus projects. |
| 37 | + |
| 38 | +### Pitfalls of the current solution |
| 39 | + |
| 40 | +Currently, Prometheus projects rely entirely on manual label application: |
| 41 | + |
| 42 | +- Maintainers must navigate GitHub's UI to apply labels |
| 43 | +- Difficult to enforce consistent labeling practices |
| 44 | +- No automatic labeling based on PR content or actions |
| 45 | + |
| 46 | +## Goals |
| 47 | + |
| 48 | +Goals and use cases for the solution as proposed in [How](#how): |
| 49 | + |
| 50 | +* Enable chat-ops style label management through PR comments |
| 51 | +* Provide a lightweight, maintainable automation solution |
| 52 | +* Support the label taxonomy defined in PROM-65 |
| 53 | +* Align with CNCF's preference for GitHub Actions where possible |
| 54 | + |
| 55 | +### Audience |
| 56 | + |
| 57 | +This proposal targets: |
| 58 | + |
| 59 | +- Prometheus maintainers and contributors who need efficient label management |
| 60 | + tools |
| 61 | + |
| 62 | +## Non-Goals |
| 63 | + |
| 64 | +* Running a full Kubernetes-based Prow instance |
| 65 | +* Implementing all Prow plugins and features |
| 66 | +* Automatic merge functionality (at least initially) |
| 67 | +* Replacing manual label operations |
| 68 | + |
| 69 | +## How |
| 70 | + |
| 71 | +### Proposed Architecture |
| 72 | + |
| 73 | +This proposal recommends using the **prom-prow** bot, a custom lightweight chat-ops bot designed specifically for Prometheus repositories. The bot is implemented as a GitHub Action and provides Prow-style commands without requiring OWNERS files or running a full Prow instance. |
| 74 | + |
| 75 | +### Prom-Prow Bot |
| 76 | + |
| 77 | +The **prom-prow bot** is a custom GitHub Action that provides Prow-style chat-ops commands optimized for Prometheus workflows. Unlike existing Prow GitHub Actions, prom-prow is designed to work seamlessly with GitHub's native permission system and CODEOWNERS without requiring OWNERS files. |
| 78 | + |
| 79 | +#### Supported Commands |
| 80 | + |
| 81 | +The following commands are available in PR comments: |
| 82 | + |
| 83 | +- **`/lgtm`**: Approve the PR |
| 84 | + - Anyone: Submits an approving GitHub review (if repository is configured to |
| 85 | + allow reviews by Actions) |
| 86 | + - Collaborators: Also adds `review/lgtm` label |
| 87 | + - PR authors cannot approve their own changes |
| 88 | +- **`/lgtm cancel`**: Cancel approval |
| 89 | + - Anyone: Dismisses the user's review |
| 90 | + - Collaborators: Also removes `review/lgtm` label (only if no other collaborators have approved) |
| 91 | +- **`/cc @user1 @user2`**: Request reviews from specified users (requires write access) |
| 92 | +- **`/label <label>`**: Add label(s) to the PR (requires write access) |
| 93 | +- **`/hold`**: Add `blocked/hold` label to prevent merging (requires write access) |
| 94 | +- **`/unhold`**: Remove `blocked/hold` label (requires write access) |
| 95 | + |
| 96 | +#### Key Features |
| 97 | + |
| 98 | +- **No OWNERS Files Required**: Uses GitHub's native collaborator permissions |
| 99 | +- **Bidirectional /lgtm Sync**: Both `/lgtm` command and GitHub UI approvals add the `review/lgtm` label |
| 100 | +- **Automatic LGTM Removal**: Removes `review/lgtm` when new commits are pushed |
| 101 | +- **Self-Approval Prevention**: PR authors cannot approve their own changes |
| 102 | +- **Welcome Comments**: Posts helpful command documentation on new PRs |
| 103 | +- **Two-Tier Permissions**: |
| 104 | + - Anyone can submit reviews via `/lgtm` |
| 105 | + - Only collaborators can manage labels |
| 106 | +- **Works alongside CODEOWNERS**: Codeowners can be used for automatic review |
| 107 | + assignment |
| 108 | + |
| 109 | +#### Example Configuration |
| 110 | + |
| 111 | +GitHub Actions workflow (`.github/workflows/prometheus-bot.yml`): |
| 112 | + |
| 113 | +```yaml |
| 114 | +name: Prometheus Bot |
| 115 | + |
| 116 | +on: |
| 117 | + issue_comment: |
| 118 | + types: [created] |
| 119 | + pull_request_review: |
| 120 | + types: [submitted] |
| 121 | + pull_request: |
| 122 | + types: [opened, synchronize] |
| 123 | + |
| 124 | +jobs: |
| 125 | + bot: |
| 126 | + runs-on: ubuntu-latest |
| 127 | + permissions: |
| 128 | + contents: read |
| 129 | + issues: write |
| 130 | + pull-requests: write |
| 131 | + steps: |
| 132 | + - uses: actions/checkout@v4 |
| 133 | + - uses: prometheus/prom-prow@main |
| 134 | + with: |
| 135 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 136 | +``` |
| 137 | +
|
| 138 | +Note that this currently uses the Dockerfile integration, i.e. builds the image |
| 139 | +on every run. For a production setup we wouls push the action image to a |
| 140 | +registry and pull from there. |
| 141 | +
|
| 142 | +#### Why Custom Bot Instead of Prow GitHub Actions or Prow? |
| 143 | +
|
| 144 | +- Works with existing CODEOWNERS (no migration needed) |
| 145 | +- Uses GitHub's native collaborator permissions (no new files) |
| 146 | +- Bidirectional sync: `/lgtm` command ↔ GitHub UI approval both add label |
| 147 | +- Simpler permission model aligned with GitHub's access levels |
| 148 | +- Lightweight and maintainable (single Go binary, ~300 lines of core logic) |
| 149 | + |
| 150 | +See [below for alternatives](#alternatives) considered. |
| 151 | + |
| 152 | +### Component 2: Initial Label Workflows |
| 153 | + |
| 154 | +Simple GitHub Actions workflows automatically apply initial labels to new issues |
| 155 | +and pull requests using the GitHub CLI (`gh`). |
| 156 | + |
| 157 | +#### Issue Labeling |
| 158 | + |
| 159 | +Automatically add `triage/needs-triage` to new issues. |
| 160 | + |
| 161 | +`.github/workflows/label-issues.yml`: |
| 162 | + |
| 163 | +```yaml |
| 164 | +name: Label new issues |
| 165 | +on: |
| 166 | + issues: |
| 167 | + types: |
| 168 | + - opened |
| 169 | +
|
| 170 | +jobs: |
| 171 | + label_issues: |
| 172 | + runs-on: ubuntu-latest |
| 173 | + permissions: |
| 174 | + issues: write |
| 175 | + steps: |
| 176 | + - run: gh issue edit "$NUMBER" --add-label "$LABELS" |
| 177 | + env: |
| 178 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 179 | + GH_REPO: ${{ github.repository }} |
| 180 | + NUMBER: ${{ github.event.issue.number }} |
| 181 | + LABELS: triage/needs-triage |
| 182 | +``` |
| 183 | + |
| 184 | +#### Pull Request Labeling |
| 185 | + |
| 186 | +Automatically add `review/needs-review` to new pull requests. |
| 187 | + |
| 188 | +`.github/workflows/label-prs.yml`: |
| 189 | + |
| 190 | +```yaml |
| 191 | +name: Label new pull requests |
| 192 | +on: |
| 193 | + pull_request: |
| 194 | + types: |
| 195 | + - opened |
| 196 | +
|
| 197 | +jobs: |
| 198 | + label_prs: |
| 199 | + runs-on: ubuntu-latest |
| 200 | + permissions: |
| 201 | + pull-requests: write |
| 202 | + steps: |
| 203 | + - run: gh pr edit "$NUMBER" --add-label "$LABELS" |
| 204 | + env: |
| 205 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 206 | + GH_REPO: ${{ github.repository }} |
| 207 | + NUMBER: ${{ github.event.pull_request.number }} |
| 208 | + LABELS: review/needs-review |
| 209 | +``` |
| 210 | + |
| 211 | +#### Benefits of This Approach |
| 212 | + |
| 213 | +- **Simple**: Uses only GitHub CLI commands, no external actions needed |
| 214 | +- **Maintainable**: Clear, straightforward YAML that's easy to understand |
| 215 | +- **Flexible**: Easy to add multiple labels or conditional logic |
| 216 | +- **Native**: Uses GitHub's built-in CLI tool |
| 217 | +- **Lightweight**: No dependencies on third-party actions |
| 218 | + |
| 219 | +#### Optional: Component Label Automation |
| 220 | + |
| 221 | +If desired, component labels could be added based on file patterns using a simple |
| 222 | +script, but this is optional since maintainers can easily apply component labels |
| 223 | +using `/label component/X` commands during review. |
| 224 | + |
| 225 | +### Integration with CODEOWNERS |
| 226 | + |
| 227 | +The prom-prow bot is designed to work seamlessly with GitHub's native CODEOWNERS: |
| 228 | + |
| 229 | +- **CODEOWNERS handles automatic review assignment**: When a PR is opened, GitHub automatically requests reviews from code owners based on the files changed |
| 230 | +- **Prom-prow handles chat-ops commands**: Maintainers use `/lgtm`, `/cc`, `/label`, etc. for workflow management |
| 231 | +- **Full compatibility**: CODEOWNERS can use teams, complex patterns, and all GitHub features |
| 232 | + |
| 233 | +### Stale Issue Management (Optional) |
| 234 | + |
| 235 | +If lifecycle labels are adopted, GitHub's `actions/stale` can automate stale |
| 236 | +marking: |
| 237 | + |
| 238 | +```yaml |
| 239 | +name: Mark Stale Issues |
| 240 | +on: |
| 241 | + schedule: |
| 242 | + - cron: '0 0 * * *' |
| 243 | +
|
| 244 | +jobs: |
| 245 | + stale: |
| 246 | + runs-on: ubuntu-latest |
| 247 | + steps: |
| 248 | + - uses: actions/stale@v9 |
| 249 | + with: |
| 250 | + stale-issue-label: 'lifecycle/stale' |
| 251 | + exempt-issue-labels: 'lifecycle/frozen' |
| 252 | + days-before-stale: 90 |
| 253 | + days-before-close: 30 |
| 254 | + stale-issue-message: 'This issue has been automatically marked as stale...' |
| 255 | +``` |
| 256 | + |
| 257 | +### Implementation Plan |
| 258 | + |
| 259 | +1. **Pilot in prometheus/prometheus**: |
| 260 | + - Deploy `.github/workflows/prometheus-bot.yml` workflow |
| 261 | + - Deploy simple initial labeling workflows for new issues and PRs |
| 262 | + - Document commands in CONTRIBUTING.md and link to that in welcome message |
| 263 | + |
| 264 | +2. **Evaluate and Iterate**: |
| 265 | + - Gather feedback from maintainers after 1-2 months |
| 266 | + - Adjust bot configuration based on usage patterns |
| 267 | + - Consider additional commands if needed |
| 268 | + |
| 269 | +3. **Roll Out to Other Repositories**: |
| 270 | + - Apply to other prometheus/* repositories |
| 271 | + - Customize per repository as needed (e.g., additional labels) |
| 272 | + |
| 273 | +### Validation |
| 274 | + |
| 275 | +Success will be measured by: |
| 276 | + |
| 277 | +- Increased consistency in label application |
| 278 | +- Positive feedback from maintainers on workflow efficiency |
| 279 | + |
| 280 | +## Alternatives |
| 281 | + |
| 282 | +### Alternative 1: Full Prow Instance |
| 283 | + |
| 284 | +Run a complete Kubernetes-based Prow instance, as offered by CNCF. |
| 285 | + |
| 286 | +**Advantages:** |
| 287 | +- Full feature set including tide (automatic merging), automatic label management |
| 288 | +- Battle-tested in Kubernetes ecosystem |
| 289 | +- Most powerful automation capabilities |
| 290 | +- Full plugin ecosystem |
| 291 | + |
| 292 | +**Disadvantages:** |
| 293 | +- Significant operational overhead (Kubernetes cluster required) |
| 294 | +- CNCF steers projects toward GitHub Actions |
| 295 | +- More complex to maintain and configure |
| 296 | + |
| 297 | +**Rationale for rejection**: Too expensive to run and maintain relative to |
| 298 | +benefits. CNCF recommends GitHub Actions, and prom-prow provides sufficient |
| 299 | +functionality without operational overhead. |
| 300 | + |
| 301 | +### Alternative 2: Prow GitHub Actions |
| 302 | + |
| 303 | +Use the existing [Prow GitHub Actions](https://github.com/jpmcb/prow-github-actions) project. |
| 304 | + |
| 305 | +**Advantages:** |
| 306 | +- Community-maintained tool |
| 307 | +- Provides Prow-style commands |
| 308 | +- No Kubernetes infrastructure needed |
| 309 | + |
| 310 | +**Disadvantages:** |
| 311 | +- Requires OWNERS files (only supports single root OWNERS, no per-directory) |
| 312 | +- No GitHub team support in OWNERS (individual usernames only) |
| 313 | +- Does not interact with CODEOWNERS for review assignment |
| 314 | +- No bidirectional sync (GitHub UI approvals don't trigger label automation) |
| 315 | +- Would require maintaining both OWNERS and CODEOWNERS |
| 316 | + |
| 317 | +**Rationale for rejection**: Requires migrating to OWNERS files or maintaining |
| 318 | +dual configuration. Prom-prow provides better integration with GitHub's native |
| 319 | +features (CODEOWNERS, collaborator permissions, UI approvals) while being |
| 320 | +simpler to maintain. |
| 321 | + |
| 322 | +## Action Plan |
| 323 | + |
| 324 | +* [ ] Review and accept this proposal |
| 325 | +* [ ] Deploy prom-prow bot |
| 326 | + * [ ] Create `.github/workflows/prometheus-bot.yml` |
| 327 | +* [ ] Deploy initial label workflows |
| 328 | + * [ ] Create `.github/workflows/label-issues.yml` (adds `triage/needs-triage`) |
| 329 | + * [ ] Create `.github/workflows/label-prs.yml` (adds `review/needs-review`) |
| 330 | +* [ ] Documentation |
| 331 | + * [ ] Update CONTRIBUTING.md with chat-ops commands |
| 332 | + * [ ] Announce to prometheus-developers mailing list |
| 333 | +* [ ] Pilot period (1-2 months) |
| 334 | + * [ ] Gather maintainer feedback |
| 335 | + * [ ] Monitor for any issues |
| 336 | + * [ ] Adjust if needed |
| 337 | +* [ ] Roll out to other repositories |
| 338 | + * [ ] Apply to alertmanager, client_golang, etc. on maintainers request |
| 339 | +* [ ] Optional: Add stale issue automation (if lifecycle labels adopted) |
0 commit comments